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
70 lines
2.4 KiB
PHP
70 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Dto\PageDto;
|
|
use App\Models\Page;
|
|
use App\Queries\Pages\GetPageQuery;
|
|
use App\Queries\Pages\GetPageQueryInput;
|
|
use Domain\Enums\StaticPageSlug;
|
|
use Domain\Models\ValueObjects\Slug;
|
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
|
|
describe('GetPageBySlugQuery', function (): void {
|
|
it('returns a PageDto when page exists by enum slug', function (): void {
|
|
// GIVEN
|
|
$page = new Page();
|
|
$page->slug = StaticPageSlug::LEGALS;
|
|
$page->seo_title = 'Mentions légales SEO';
|
|
$page->seo_description = 'Mentions légales description SEO';
|
|
$page->title = 'Mentions légales';
|
|
$page->content = '<p>Contenu des mentions légales</p>';
|
|
$page->save();
|
|
|
|
/** @var GetPageQuery $query */
|
|
$query = app(GetPageQuery::class);
|
|
|
|
// WHEN
|
|
$dto = $query(new GetPageQueryInput(new Slug(StaticPageSlug::LEGALS->value)));
|
|
|
|
// THEN
|
|
expect($dto)->toBeInstanceOf(PageDto::class)
|
|
->and($dto->id)->toBe($page->id)
|
|
->and($dto->slug)->toBe(StaticPageSlug::LEGALS)
|
|
->and($dto->seo_title)->toBe('Mentions légales SEO')
|
|
->and($dto->title)->toBe('Mentions légales');
|
|
});
|
|
|
|
it('returns a PageDto when page exists by string slug', function (): void {
|
|
// GIVEN
|
|
$page = new Page();
|
|
$page->slug = StaticPageSlug::TERMS;
|
|
$page->seo_title = 'CGV SEO Title';
|
|
$page->seo_description = 'CGV SEO Description';
|
|
$page->title = 'Conditions Générales de Vente';
|
|
$page->content = '<p>Contenu CGV</p>';
|
|
$page->save();
|
|
|
|
/** @var GetPageQuery $query */
|
|
$query = app(GetPageQuery::class);
|
|
|
|
// WHEN
|
|
$dto = $query(new GetPageQueryInput(new Slug('cgv')));
|
|
|
|
// THEN
|
|
expect($dto)->toBeInstanceOf(PageDto::class)
|
|
->and($dto->id)->toBe($page->id)
|
|
->and($dto->slug)->toBe(StaticPageSlug::TERMS);
|
|
});
|
|
|
|
it('throws ModelNotFoundException when page does not exist', function (): void {
|
|
// GIVEN
|
|
/** @var GetPageQuery $query */
|
|
$query = app(GetPageQuery::class);
|
|
|
|
// WHEN
|
|
expect(fn () => $query(new GetPageQueryInput(new Slug('non-existent-slug'))))
|
|
// THEN
|
|
->toThrow(ModelNotFoundException::class);
|
|
});
|
|
});
|