|
@@ 30-46 (lines=17) @@
|
| 27 |
|
$this->assertSame($repo, $factory->getRepository($em, 'Foo\CoolEntity')); |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
public function testGetRepositoryReturnsEntityRepository() |
| 31 |
|
{ |
| 32 |
|
if (! interface_exists(ContainerInterface::class)) { |
| 33 |
|
$this->markTestSkipped('Symfony 3.3 is needed for this feature.'); |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
$container = $this->createContainer([]); |
| 37 |
|
$em = $this->createEntityManager(['Foo\BoringEntity' => null]); |
| 38 |
|
|
| 39 |
|
$factory = new ContainerRepositoryFactory($container); |
| 40 |
|
$actualRepo = $factory->getRepository($em, 'Foo\BoringEntity'); |
| 41 |
|
$this->assertInstanceOf(EntityRepository::class, $actualRepo); |
| 42 |
|
// test the same instance is returned |
| 43 |
|
$this->assertSame($actualRepo, $factory->getRepository($em, 'Foo\BoringEntity')); |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
public function testCustomRepositoryIsReturned() |
| 47 |
|
{ |
| 48 |
|
if (! interface_exists(ContainerInterface::class)) { |
| 49 |
|
$this->markTestSkipped('Symfony 3.3 is needed for this feature.'); |
|
@@ 46-62 (lines=17) @@
|
| 43 |
|
$this->assertSame($actualRepo, $factory->getRepository($em, 'Foo\BoringEntity')); |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
public function testCustomRepositoryIsReturned() |
| 47 |
|
{ |
| 48 |
|
if (! interface_exists(ContainerInterface::class)) { |
| 49 |
|
$this->markTestSkipped('Symfony 3.3 is needed for this feature.'); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
$container = $this->createContainer([]); |
| 53 |
|
$em = $this->createEntityManager([ |
| 54 |
|
'Foo\CustomNormalRepoEntity' => StubRepository::class, |
| 55 |
|
]); |
| 56 |
|
|
| 57 |
|
$factory = new ContainerRepositoryFactory($container); |
| 58 |
|
$actualRepo = $factory->getRepository($em, 'Foo\CustomNormalRepoEntity'); |
| 59 |
|
$this->assertInstanceOf(StubRepository::class, $actualRepo); |
| 60 |
|
// test the same instance is returned |
| 61 |
|
$this->assertSame($actualRepo, $factory->getRepository($em, 'Foo\CustomNormalRepoEntity')); |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
/** |
| 65 |
|
* @expectedException \RuntimeException |