/
EntityManagerTest.php
48 lines (42 loc) · 1.21 KB
/
EntityManagerTest.php
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
44
45
46
47
48
<?php
namespace DoctrineORMModuleTest\Di;
use DoctrineORMModuleTest\Framework\TestCase;
use Doctrine\ORM\EntityManager;
class EntityManagerTest extends TestCase
{
/**
* Verifying that the EntityManager that is injected into a custom object is actually the same that can be
* retrieved directly or from the locator
*/
public function testCanInjectEntityManager()
{
$locator = $this->getLocator();
/* @var $target EntityManagerTestInjectTarget */
$target = $locator->get('DoctrineORMModuleTest\Di\\EntityManagerTestInjectTarget');
$this->assertInstanceOf('DoctrineORMModuleTest\Di\\EntityManagerTestInjectTarget', $target);
$em = $target->getEntityManager();
$this->assertInstanceOf('Doctrine\ORM\EntityManager', $em);
$this->assertSame($em, $locator->get('Doctrine\ORM\EntityManager'));
}
}
class EntityManagerTestInjectTarget
{
/**
* @var EntityManager
*/
protected $em;
/**
* @param EntityManager $em
*/
public function __construct(EntityManager $em)
{
$this->em = $em;
}
/**
* @return EntityManager
*/
public function getEntityManager()
{
return $this->em;
}
}