add tests
All checks were successful
/ ls (push) Successful in 20s

This commit is contained in:
lubiana 2024-06-02 11:20:20 +02:00
parent 13bfbbe528
commit eb40f1df49
Signed by: lubiana
SSH key fingerprint: SHA256:gkqM8DUX4Blf6P52fycW8ISTd+4eAHH+Uzu9iyc8hAM
10 changed files with 388 additions and 44 deletions

View file

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
use Doctrine\ORM\EntityManager;
use Lubiana\DoctrineUlid\IdGenerator\UlidGenerator;
use Symfony\Component\Uid\Factory\UlidFactory;
use Symfony\Component\Uid\Ulid;
test(
'UlidGenerator constructs without factory and generate Id',
function (): void {
$ulidGenerator = new UlidGenerator;
$em = createMock(EntityManager::class);
$id = $ulidGenerator->generateId($em, null);
expect($id)
->toBeInstanceOf(Ulid::class);
},
);
test(
'UlidGenerator constructs with factory and generate Id',
function (): void {
$factory = Mockery::mock(UlidFactory::class);
$ulid = new Ulid;
$factory->shouldReceive('create')
->andReturn($ulid)
->once();
$ulidGenerator = new UlidGenerator($factory);
$em = Mockery::mock(EntityManager::class);
$id = $ulidGenerator->generateId($em, null);
expect($id)
->toBe($ulid);
},
);