seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); Cache::flush(); // WHEN $response = $this->get('/ajax/shops/1/pickup-timeslots'); // THEN $response->assertRedirectToRoute('fo.auth.connexion'); }); it('returns 404 for unknown shop when authenticated active employee requests pickup timeslots', function (): void { /** @var \Tests\TestCase $this */ // GIVEN $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); Cache::flush(); $customer = new Customer(); $customer->email = new Email('employee@example.com'); $customer->hashcode = new CrmHashcode(UuidHelper::v4()); $customer->save(); $this->actingAs($customer, 'frontend'); $this->withoutMiddleware([ EnsureCustomerEmailIsVerified::class, CustomerIsEmployed::class, ]); // WHEN $response = $this->get('/ajax/shops/99999/pickup-timeslots'); // THEN $response->assertStatus(404); }); it('returns pickup timeslots for an existing shop when authenticated active employee', function (): void { /** @var \Tests\TestCase $this */ // GIVEN $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); Cache::flush(); $shop = Shop::factory()->create(); $customer = new Customer(); $customer->email = new Email('employee2@example.com'); $customer->hashcode = new CrmHashcode(UuidHelper::v4()); $customer->save(); $this->actingAs($customer, 'frontend'); $this->withoutMiddleware([ EnsureCustomerEmailIsVerified::class, CustomerIsEmployed::class, ]); // WHEN $response = $this->get(route('ajax.shops.pickup-timeslots', $shop)); // THEN $response->assertStatus(200); }); });