Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Cqs\Queries\Faqs\GetPaginatedFaqsQuery;
|
|
use App\Cqs\Queries\Faqs\GetPaginatedFaqsQueryInput;
|
|
use App\Dto\FaqDto;
|
|
use App\Models\Faq;
|
|
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);
|
|
});
|
|
});
|