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