seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); Cache::flush(); $user = \Mockery::mock(Customer::class)->makePartial(); $user->shouldReceive('getAuthIdentifier')->andReturn(1); $user->hashcode = new CrmHashcode(Uuid::uuid4()); $user->shouldReceive('getAuthPassword')->andReturn('dummy'); $this->actingAs($user, 'frontend'); $crmMock = \Mockery::mock(CrmService::class)->makePartial(); $crmMock->shouldReceive('getCustomerFromHashCode')->andReturn(null); App::instance(CrmService::class, $crmMock); // WHEN $response = $this->get('/compte'); // THEN $response->assertStatus(302); }); it('can access get /compte/profil', function () { // GIVEN /** @var \Tests\TestCase $this */ $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); Cache::flush(); $user = \Mockery::mock(Customer::class)->makePartial(); $user->shouldReceive('getAuthIdentifier')->andReturn(1); $user->hashcode = new CrmHashcode(Uuid::uuid4()); $user->shouldReceive('getAuthPassword')->andReturn('dummy'); $this->actingAs($user, 'frontend'); $crmMock = \Mockery::mock(CrmService::class)->makePartial(); $crmMock->shouldReceive('getCustomerFromHashCode')->andReturn(null); App::instance(CrmService::class, $crmMock); // WHEN $response = $this->get('/compte/profil'); // THEN $response->assertStatus(302); }); it('can access post /compte/profil', function () { // GIVEN /** @var \Tests\TestCase $this */ $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); Cache::flush(); $user = \Mockery::mock(Customer::class)->makePartial(); $user->shouldReceive('getAuthIdentifier')->andReturn(1); $user->hashcode = new CrmHashcode(Uuid::uuid4()); $user->shouldReceive('getAuthPassword')->andReturn('dummy'); $this->actingAs($user, 'frontend'); $crmMock = \Mockery::mock(CrmService::class)->makePartial(); $crmMock->shouldReceive('getCustomerFromHashCode')->andReturn(null); App::instance(CrmService::class, $crmMock); // WHEN $response = $this->post('/compte/profil', []); // THEN $response->assertStatus(302); }); });