ldc-cocotte/tests/Feature/App/Http/Controllers/Fo/Ajax/BasketControllerTest.php
2026-10-27 09:58:12 +01:00

74 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\Page;
use Database\Seeders\ContentSeeder;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\View;
describe('BasketController', function () {
it('can access post /ajax/basket/add', function () {
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->post('/ajax/basket/add', []);
// THEN
$response->assertStatus(403);
});
it('can access post /ajax/basket/empty', function () {
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->post('/ajax/basket/empty', []);
// THEN
$response->assertStatus(200);
});
it('can access get /ajax/basket/get', function () {
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->get('/ajax/basket/get');
// THEN
$response->assertStatus(200);
});
it('can access post /ajax/basket/remove', function () {
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->post('/ajax/basket/remove', []);
// THEN
$response->assertStatus(302);
});
});