parent
13bfbbe528
commit
eb40f1df49
10 changed files with 388 additions and 44 deletions
33
tests/Unit/UlidGeneratorTest.php
Normal file
33
tests/Unit/UlidGeneratorTest.php
Normal 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);
|
||||
},
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue