43 lines
1.6 KiB
PHP
43 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Dto\PageDto;
|
|
use App\Models\Page;
|
|
use Domain\Enums\StaticPageSlug;
|
|
|
|
describe('PageDto', function (): void {
|
|
it('creates a DTO from Page model', function (): void {
|
|
// GIVEN
|
|
$page = new Page();
|
|
$page->id = 1;
|
|
$page->slug = StaticPageSlug::FAQ;
|
|
$page->seo_title = 'FAQ SEO Title';
|
|
$page->seo_description = 'FAQ SEO Description';
|
|
$page->title = 'Foire aux questions';
|
|
$page->content = '<p>Questions et réponses</p>';
|
|
|
|
// WHEN
|
|
$dto = PageDto::fromModel($page);
|
|
|
|
// THEN
|
|
expect($dto->id)->toBe(1)
|
|
->and($dto->slug)->toBe(StaticPageSlug::FAQ)
|
|
->and($dto->seo_title)->toBe('FAQ SEO Title')
|
|
->and($dto->seo_description)->toBe('FAQ SEO Description')
|
|
->and($dto->title)->toBe('Foire aux questions')
|
|
->and($dto->content)->toBe('<p>Questions et réponses</p>')
|
|
->and($dto->getRouteKey())->toBe('faq')
|
|
->and($dto->getRouteKeyName())->toBe('slug')
|
|
->and($dto->resolveRouteBinding('faq'))->toBeNull()
|
|
->and($dto->resolveChildRouteBinding('child', 'val', 'field'))->toBeNull()
|
|
->and($dto->toArray())->toBe([
|
|
'id' => 1,
|
|
'slug' => StaticPageSlug::FAQ,
|
|
'seo_title' => 'FAQ SEO Title',
|
|
'seo_description' => 'FAQ SEO Description',
|
|
'title' => 'Foire aux questions',
|
|
'content' => '<p>Questions et réponses</p>',
|
|
]);
|
|
});
|
|
});
|