diff --git a/tests/Feature/App/Http/Controllers/Fo/TunnelControllerTest.php b/tests/Feature/App/Http/Controllers/Fo/TunnelControllerTest.php index d6b17fb6..a4a9c920 100644 --- a/tests/Feature/App/Http/Controllers/Fo/TunnelControllerTest.php +++ b/tests/Feature/App/Http/Controllers/Fo/TunnelControllerTest.php @@ -7,88 +7,8 @@ use Database\Seeders\ContentSeeder; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\View; -describe('TunnelController', function () { - it('can access get /commande/confirmation', function () { - // 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'); - - // THEN - $response->assertStatus(302); - }); - - it('can access post /commande/confirmation', function () { - // 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', []); - - // THEN - $response->assertStatus(302); - }); - - it('can access get /commande/confirmation/1', function () { - // 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'); - - // THEN - $response->assertStatus(302); - }); - - it('can access get /commande/creneaux', function () { - // 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'); - - // THEN - $response->assertStatus(302); - }); - - it('can access post /commande/creneaux', function () { - // 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', []); - - // THEN - $response->assertStatus(302); - }); - - it('can access get /commande/panier', function () { +describe('TunnelController', function (): void { + it('redirects unauthenticated guest accessing basket summary to login', function (): void { // GIVEN $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached() @@ -101,10 +21,10 @@ describe('TunnelController', function () { $response = $this->get('/commande/panier'); // THEN - $response->assertStatus(302); + $response->assertRedirectToRoute('fo.auth.connexion'); }); - it('can access post /commande/panier', function () { + it('redirects unauthenticated guest submitting basket summary to login', function (): void { // GIVEN $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached() @@ -117,6 +37,86 @@ describe('TunnelController', function () { $response = $this->post('/commande/panier', []); // THEN - $response->assertStatus(302); + $response->assertRedirectToRoute('fo.auth.connexion'); + }); + + it('redirects unauthenticated guest accessing pick time slot to login', function (): void { + // 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'); + + // THEN + $response->assertRedirectToRoute('fo.auth.connexion'); + }); + + it('redirects unauthenticated guest submitting pick time slot to login', function (): void { + // 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', []); + + // THEN + $response->assertRedirectToRoute('fo.auth.connexion'); + }); + + it('redirects unauthenticated guest accessing confirmation to login', function (): void { + // 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'); + + // THEN + $response->assertRedirectToRoute('fo.auth.connexion'); + }); + + it('redirects unauthenticated guest submitting confirmation to login', function (): void { + // 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', []); + + // THEN + $response->assertRedirectToRoute('fo.auth.connexion'); + }); + + it('redirects unauthenticated guest accessing confirmed order to login', function (): void { + // 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'); + + // THEN + $response->assertRedirectToRoute('fo.auth.connexion'); }); });