1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace Portiny\Doctrine\Tests\Adapter\Nette\DI; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\EventManager; |
6
|
|
|
use Doctrine\DBAL\Types\Type; |
7
|
|
|
use Doctrine\ORM\EntityManager; |
8
|
|
|
use Portiny\Doctrine\Tests\AbstractContainerTestCase; |
9
|
|
|
use Portiny\Doctrine\Tests\Source\CastFunction; |
10
|
|
|
use Portiny\Doctrine\Tests\Source\DateTimeImmutableType; |
11
|
|
|
use Portiny\Doctrine\Tests\Source\IntervalType; |
12
|
|
|
|
13
|
|
|
class DoctrineExtensionTest extends AbstractContainerTestCase |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
public function testLoadConfiguration(): void |
17
|
|
|
{ |
18
|
|
|
/** @var EntityManager $entityManager */ |
19
|
|
|
$entityManager = $this->container->getByType(EntityManager::class); |
20
|
|
|
self::assertInstanceOf(EntityManager::class, $entityManager); |
21
|
|
|
|
22
|
|
|
/** @var EventManager $eventManager */ |
23
|
|
|
$eventManager = $this->container->getByType(EventManager::class); |
24
|
|
|
self::assertInstanceOf(EventManager::class, $eventManager); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
public function testBeforeCompile(): void |
29
|
|
|
{ |
30
|
|
|
self::assertArrayHasKey('interval', Type::getTypesMap()); |
31
|
|
|
self::assertInstanceOf(IntervalType::class, Type::getType('interval')); |
32
|
|
|
|
33
|
|
|
self::assertArrayHasKey('datetime', Type::getTypesMap()); |
34
|
|
|
self::assertInstanceOf(DateTimeImmutableType::class, Type::getType('datetime')); |
35
|
|
|
|
36
|
|
|
/** @var EntityManager $entityManager */ |
37
|
|
|
$entityManager = $this->container->getByType(EntityManager::class); |
38
|
|
|
$configuration = $entityManager->getConfiguration(); |
39
|
|
|
self::assertNull($configuration->getCustomStringFunction('nonExistsFunctionName')); |
40
|
|
|
self::assertSame(CastFunction::class, $configuration->getCustomStringFunction('cast')); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
} |
44
|
|
|
|