test(casts): add tests for ShopperEstablishmentCodeCast functionality test(casts): add tests for ShopperServiceCodeCast functionality test(casts): add tests for ShopperSiteCodeCast functionality test(dto): update ProductDtoTest to include additional fields test(dto): update SettingDtoTest to remove arcadiaSites assertions test(events): update AnOrderHasBeenPlacedTest to use value objects test(entities): update OrderTest to use value objects for employee details test(value-objects): update EmployeeUpsertDataTest to use value objects test(pagination): update PaginationTest to access value properties test(services): update AppCustomerAuthServiceTest to use CrmHashcode test(services): update CrmServiceTest to use CrmHashcode for customer retrieval
90 lines
3.2 KiB
PHP
90 lines
3.2 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;
|
|
use Ramsey\Uuid\Uuid;
|
|
use Shared\ValueObjects\CrmHashcode;
|
|
|
|
describe('CustomerController', function () {
|
|
it('can access get /compte', 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');
|
|
|
|
// 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);
|
|
});
|
|
});
|