61 lines
2.1 KiB
PHP
61 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Customer;
|
|
use App\Models\Page;
|
|
use App\Services\CrmService;
|
|
use Database\Seeders\ContentSeeder;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
describe('OrderController', function () {
|
|
it('can access get /compte/commandes', function () {
|
|
// GIVEN
|
|
$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 = 'dummy_hashcode';
|
|
$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/commandes');
|
|
|
|
// THEN
|
|
$response->assertStatus(302);
|
|
});
|
|
|
|
it('can access get /compte/commandes/1', function () {
|
|
// GIVEN
|
|
$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 = 'dummy_hashcode';
|
|
$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/commandes/1');
|
|
|
|
// THEN
|
|
$response->assertStatus(404);
|
|
});
|
|
});
|