1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM;
use Doctrine\ORM\EntityNotFoundException;
use PHPUnit\Framework\TestCase;
/**
* Tests for {@see \Doctrine\ORM\EntityNotFoundException}
*
* @covers \Doctrine\ORM\EntityNotFoundException
*/
class EntityNotFoundExceptionTest extends TestCase
{
public function testFromClassNameAndIdentifier(): void
{
$exception = EntityNotFoundException::fromClassNameAndIdentifier(
'foo',
['foo' => 'bar']
);
self::assertInstanceOf(EntityNotFoundException::class, $exception);
self::assertSame('Entity of type \'foo\' for IDs foo(bar) was not found', $exception->getMessage());
$exception = EntityNotFoundException::fromClassNameAndIdentifier(
'foo',
[]
);
self::assertInstanceOf(EntityNotFoundException::class, $exception);
self::assertSame('Entity of type \'foo\' was not found', $exception->getMessage());
}
public function testNoIdentifierFound(): void
{
$exception = EntityNotFoundException::noIdentifierFound('foo');
self::assertInstanceOf(EntityNotFoundException::class, $exception);
self::assertSame('Unable to find "foo" entity identifier associated with the UnitOfWork', $exception->getMessage());
}
}
|