43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Dto\RangeDto;
|
||
|
|
use App\Models\Range;
|
||
|
|
use App\Queries\Ranges\GetPaginatedRangesQuery;
|
||
|
|
use App\Services\DataTableService;
|
||
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
|
|
|
||
|
|
uses(RefreshDatabase::class);
|
||
|
|
|
||
|
|
describe('GetPaginatedRangesQuery', function () {
|
||
|
|
test('it executes and returns paginated RangeDto collection', function () {
|
||
|
|
// GIVEN
|
||
|
|
$range1 = new Range();
|
||
|
|
$range1->name = 'Gamme Alpha';
|
||
|
|
$range1->picture_alt = 'Alt 1';
|
||
|
|
$range1->picture_title = 'Title 1';
|
||
|
|
$range1->status = true;
|
||
|
|
$range1->save();
|
||
|
|
|
||
|
|
$range2 = new Range();
|
||
|
|
$range2->name = 'Gamme Beta';
|
||
|
|
$range2->picture_alt = 'Alt 2';
|
||
|
|
$range2->picture_title = 'Title 2';
|
||
|
|
$range2->status = true;
|
||
|
|
$range2->save();
|
||
|
|
|
||
|
|
$dataTableService = resolve(DataTableService::class);
|
||
|
|
$query = new GetPaginatedRangesQuery($dataTableService);
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$result = $query->execute();
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($result->total())->toBe(2)
|
||
|
|
->and($result->items())->toHaveCount(2)
|
||
|
|
->and($result->items()[0])->toBeInstanceOf(RangeDto::class)
|
||
|
|
->and($result->items()[1])->toBeInstanceOf(RangeDto::class);
|
||
|
|
});
|
||
|
|
});
|