ldc-cocotte/tests/Feature/App/Http/Controllers/Fo/TunnelControllerTest.php

123 lines
3.6 KiB
PHP
Raw Normal View History

2026-06-14 21:32:07 +02:00
<?php
declare(strict_types=1);
use App\Models\Page;
use Database\Seeders\ContentSeeder;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\View;
describe('TunnelController', function (): void {
it('redirects unauthenticated guest accessing basket summary to login', function (): void {
2026-06-14 21:32:07 +02:00
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->get('/commande/panier');
2026-06-14 21:32:07 +02:00
// THEN
$response->assertRedirectToRoute('fo.auth.connexion');
2026-06-14 21:32:07 +02:00
});
it('redirects unauthenticated guest submitting basket summary to login', function (): void {
2026-06-14 21:32:07 +02:00
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->post('/commande/panier', []);
2026-06-14 21:32:07 +02:00
// THEN
$response->assertRedirectToRoute('fo.auth.connexion');
2026-06-14 21:32:07 +02:00
});
it('redirects unauthenticated guest accessing pick time slot to login', function (): void {
2026-06-14 21:32:07 +02:00
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->get('/commande/creneaux');
2026-06-14 21:32:07 +02:00
// THEN
$response->assertRedirectToRoute('fo.auth.connexion');
2026-06-14 21:32:07 +02:00
});
it('redirects unauthenticated guest submitting pick time slot to login', function (): void {
2026-06-14 21:32:07 +02:00
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->post('/commande/creneaux', []);
2026-06-14 21:32:07 +02:00
// THEN
$response->assertRedirectToRoute('fo.auth.connexion');
2026-06-14 21:32:07 +02:00
});
it('redirects unauthenticated guest accessing confirmation to login', function (): void {
2026-06-14 21:32:07 +02:00
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->get('/commande/confirmation');
2026-06-14 21:32:07 +02:00
// THEN
$response->assertRedirectToRoute('fo.auth.connexion');
2026-06-14 21:32:07 +02:00
});
it('redirects unauthenticated guest submitting confirmation to login', function (): void {
2026-06-14 21:32:07 +02:00
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->post('/commande/confirmation', []);
2026-06-14 21:32:07 +02:00
// THEN
$response->assertRedirectToRoute('fo.auth.connexion');
2026-06-14 21:32:07 +02:00
});
it('redirects unauthenticated guest accessing confirmed order to login', function (): void {
2026-06-14 21:32:07 +02:00
// GIVEN
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->get('/commande/confirmation/1');
2026-06-14 21:32:07 +02:00
// THEN
$response->assertRedirectToRoute('fo.auth.connexion');
2026-06-14 21:32:07 +02:00
});
});