test sets list endpoint

This commit is contained in:
Yisroel Baum 2026-08-03 20:24:01 +03:00
parent 5b9df7d02a
commit 61ab8c09dc
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
3 changed files with 191 additions and 0 deletions

View file

@ -0,0 +1,40 @@
<?php
namespace Tests\Unit\Set\UseCases;
use App\Set\CreateSetDto;
use App\Set\UseCases\ListSets\ListSets;
use App\Shared\ValueObject\EmailAddress;
use App\User\User;
use PHPUnit\Framework\TestCase;
use Tests\Fakes\FakeSetRepository;
class ListSetsTest extends TestCase
{
public function test_it_lists_every_available_set_alphabetically(): void
{
$creator = new User(
id: 7,
email: new EmailAddress('creator@example.com'),
passwordHash: 'hashed-password',
);
$repository = new FakeSetRepository;
$repository->create(new CreateSetDto(
name: 'Course',
creator: $creator,
));
$repository->create(new CreateSetDto(
name: 'Bible',
creator: $creator,
));
$sets = (new ListSets($repository))->execute();
$this->assertSame(
['Bible', 'Course'],
array_map(function ($set): string {
return $set->getName();
}, $sets),
);
}
}