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