Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
repl6669 committed Mar 8, 2024
1 parent cc41551 commit a94d8fe
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/Feature/Domain/Brands/DeleteBrandsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Dystcz\LunarApi\Domain\Brands\Models\Brand;
use Dystcz\LunarApi\Domain\Customers\Models\Customer;
use Dystcz\LunarApi\Tests\Stubs\Users\User;
use Dystcz\LunarApi\Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(TestCase::class, RefreshDatabase::class);

beforeEach(function () {
/** @var TestCase $this */
$this->user = User::factory()
->has(Customer::factory())
->create();
});

test('brands cannot be deleted', function () {
/** @var TestCase $this */
$response = $this->deleteTest('brands', Brand::class);

$response->assertErrorStatus([
'status' => '405',
'title' => 'Method Not Allowed',
]);
})->group('brands', 'policies');
26 changes: 26 additions & 0 deletions tests/Feature/Domain/Cart/DeleteCartTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Dystcz\LunarApi\Domain\Carts\Models\Cart;
use Dystcz\LunarApi\Domain\Customers\Models\Customer;
use Dystcz\LunarApi\Tests\Stubs\Users\User;
use Dystcz\LunarApi\Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(TestCase::class, RefreshDatabase::class);

beforeEach(function () {
/** @var TestCase $this */
$this->user = User::factory()
->has(Customer::factory())
->create();
});

test('carts cannot be deleted', function () {
/** @var TestCase $this */
$response = $this->deleteTest('carts', Cart::class);

$response->assertErrorStatus([
'status' => '405',
'title' => 'Method Not Allowed',
]);
})->group('carts', 'policies');
31 changes: 31 additions & 0 deletions tests/Feature/Domain/CartAddresses/DeleteCartAddressTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Dystcz\LunarApi\Domain\CartAddresses\Models\CartAddress;
use Dystcz\LunarApi\Domain\Carts\Models\Cart;
use Dystcz\LunarApi\Domain\Customers\Models\Customer;
use Dystcz\LunarApi\Tests\Stubs\Users\User;
use Dystcz\LunarApi\Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(TestCase::class, RefreshDatabase::class);

beforeEach(function () {
/** @var TestCase $this */
$this->user = User::factory()
->has(Customer::factory())
->create();

$this->cart = Cart::factory()->create();

$this->cartAddress = CartAddress::factory()->for($this->cart)->create();
});

test('cart addresses cannot be deleted', function () {
/** @var TestCase $this */
$response = $this->deleteTest('cart-addresses', $this->cartAddress);

$response->assertErrorStatus([
'status' => '405',
'title' => 'Method Not Allowed',
]);
})->group('cart-addresses', 'policies');

0 comments on commit a94d8fe

Please sign in to comment.