Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
repl6669 committed Mar 8, 2024
1 parent a94d8fe commit e42d983
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/Feature/Domain/Addresses/DeleteAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
'id' => $id,
]);

})->group('addresses');
})->group('addresses', 'policies');
2 changes: 1 addition & 1 deletion tests/Feature/Domain/Addresses/ListAddressesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
->assertSuccessful()
->assertFetchedNone();

})->group('addresses');
})->group('addresses', 'policies');

it('can list addresses with country included', function () {
/** @var TestCase $this */
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Domain/Addresses/ReadAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
'title' => 'Forbidden',
]);

})->group('addresses');
})->group('addresses', 'policies');

it('returns error response when address does not exists', function () {
/** @var TestCase $this */
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/Domain/Addresses/UpdateAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,4 @@
),
),
]);

})->group('addresses');
})->group('addresses', 'policies');
10 changes: 10 additions & 0 deletions tests/Feature/Domain/Brands/ListBrandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,13 @@
$response = $this->indexWithIncludesTest('brands', Brand::class, 5, $includes);

})->group('brands');

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');
19 changes: 14 additions & 5 deletions tests/Feature/Domain/Cart/ClearCartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
use Dystcz\LunarApi\Domain\ProductVariants\Models\ProductVariant;
use Dystcz\LunarApi\Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Lunar\Facades\CartSession;
use Illuminate\Support\Facades\App;
use Lunar\Base\CartSessionInterface;
use Lunar\Managers\CartSessionManager;

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

it('can empty the cart', function () {
beforeEach(function () {
/** @var TestCase $this */
$currency = Currency::factory()->create([
'decimal_places' => 2,
]);
Expand All @@ -37,15 +40,21 @@
'quantity' => 1,
]);

CartSession::use($cart);
/** @property CartSessionManager $cartSession */
$this->cartSession = App::make(CartSessionInterface::class);

expect(CartSession::current()->lines->count())->toBe(1);
$this->cartSession->use($cart);
});

it('can clear the cart which is currently in session', function () {
/** @var TestCase $this */
expect($this->cartSession->current()->lines->count())->toBe(1);

$response = $this
->jsonApi()
->delete('/api/v1/carts/-actions/clear');

$response->assertNoContent();

expect(CartSession::current()->lines->count())->toBe(0);
expect($this->cartSession->current()->lines->count())->toBe(0);
})->group('carts');

0 comments on commit e42d983

Please sign in to comment.