122 lines
3.6 KiB
PHP
122 lines
3.6 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('TunnelController', function (): void {
|
|
it('redirects unauthenticated guest accessing basket summary 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/panier');
|
|
|
|
// THEN
|
|
$response->assertRedirectToRoute('fo.auth.connexion');
|
|
});
|
|
|
|
it('redirects unauthenticated guest submitting basket summary 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/panier', []);
|
|
|
|
// THEN
|
|
$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');
|
|
});
|
|
});
|