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
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Dto\FaqDto;
|
|
use App\Models\Faq;
|
|
use App\Queries\Faqs\GetPaginatedFaqsQuery;
|
|
use App\Queries\Faqs\GetPaginatedFaqsQueryInput;
|
|
use Shared\Pagination\PageNumber;
|
|
use Shared\Pagination\PageSize;
|
|
use Shared\Pagination\Pagination;
|
|
|
|
describe('GetPaginatedFaqsQuery', function (): void {
|
|
it('returns a paginator of FaqDto instances', function (): void {
|
|
// GIVEN
|
|
$faq1 = new Faq();
|
|
$faq1->question = 'First question?';
|
|
$faq1->answer = 'First answer.';
|
|
$faq1->save();
|
|
|
|
$faq2 = new Faq();
|
|
$faq2->question = 'Second question?';
|
|
$faq2->answer = 'Second answer.';
|
|
$faq2->save();
|
|
|
|
/** @var GetPaginatedFaqsQuery $query */
|
|
$query = app(GetPaginatedFaqsQuery::class);
|
|
$input = new GetPaginatedFaqsQueryInput(
|
|
pagination: Pagination::ofPage(new PageNumber(1), new PageSize(10)),
|
|
);
|
|
|
|
// WHEN
|
|
$paginator = $query($input);
|
|
|
|
// THEN
|
|
expect($paginator->total())->toBe(2);
|
|
expect($paginator->items())->toHaveCount(2);
|
|
expect($paginator->items()[0])->toBeInstanceOf(FaqDto::class)
|
|
->and($paginator->items()[1])->toBeInstanceOf(FaqDto::class);
|
|
});
|
|
});
|