2016-04-17 21:27:24 +03:00
|
|
|
<?php
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-08-02 20:28:10 +03:00
|
|
|
namespace ShlinkioTest\Shlink\Common\Doctrine;
|
2016-04-17 21:27:24 +03:00
|
|
|
|
|
|
|
use Doctrine\ORM\EntityManager;
|
2017-03-24 22:34:18 +03:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-08-02 20:28:10 +03:00
|
|
|
use Shlinkio\Shlink\Common\Doctrine\EntityManagerFactory;
|
|
|
|
use Shlinkio\Shlink\Common\Type\ChronosDateTimeType;
|
2016-04-17 21:27:24 +03:00
|
|
|
use Zend\ServiceManager\ServiceManager;
|
|
|
|
|
|
|
|
class EntityManagerFactoryTest extends TestCase
|
|
|
|
{
|
2018-11-20 21:30:27 +03:00
|
|
|
/** @var EntityManagerFactory */
|
2018-11-20 21:37:22 +03:00
|
|
|
private $factory;
|
2016-04-17 21:27:24 +03:00
|
|
|
|
2019-02-16 12:53:45 +03:00
|
|
|
public function setUp(): void
|
2016-04-17 21:27:24 +03:00
|
|
|
{
|
|
|
|
$this->factory = new EntityManagerFactory();
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:28:34 +03:00
|
|
|
/** @test */
|
2019-08-02 20:28:10 +03:00
|
|
|
public function serviceIsCreated(): void
|
2016-04-17 21:27:24 +03:00
|
|
|
{
|
|
|
|
$sm = new ServiceManager(['services' => [
|
|
|
|
'config' => [
|
|
|
|
'debug' => true,
|
2016-08-06 13:40:31 +03:00
|
|
|
'entity_manager' => [
|
2019-08-02 20:28:10 +03:00
|
|
|
'orm' => [
|
|
|
|
'types' => [
|
|
|
|
ChronosDateTimeType::CHRONOS_DATETIME => ChronosDateTimeType::class,
|
|
|
|
],
|
|
|
|
],
|
2016-08-06 13:40:31 +03:00
|
|
|
'connection' => [
|
|
|
|
'driver' => 'pdo_sqlite',
|
|
|
|
],
|
2016-04-17 21:27:24 +03:00
|
|
|
],
|
|
|
|
],
|
|
|
|
]]);
|
|
|
|
|
2019-08-02 20:28:10 +03:00
|
|
|
$em = ($this->factory)($sm, EntityManager::class);
|
2016-04-17 21:27:24 +03:00
|
|
|
$this->assertInstanceOf(EntityManager::class, $em);
|
|
|
|
}
|
|
|
|
}
|