|
@@ 108-122 (lines=15) @@
|
| 105 |
|
* @expectedException \RuntimeException |
| 106 |
|
* @expectedExceptionMessage The "Doctrine\Bundle\DoctrineBundle\Tests\Repository\StubServiceRepository" entity repository implements "Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface", but its service could not be found. Make sure the service exists and is tagged with "doctrine.repository_service". |
| 107 |
|
*/ |
| 108 |
|
public function testRepositoryMatchesServiceInterfaceButServiceNotFound() |
| 109 |
|
{ |
| 110 |
|
if (! interface_exists(ContainerInterface::class)) { |
| 111 |
|
$this->markTestSkipped('Symfony 3.3 is needed for this feature.'); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
$container = $this->createContainer([]); |
| 115 |
|
|
| 116 |
|
$em = $this->createEntityManager([ |
| 117 |
|
'Foo\CoolEntity' => StubServiceRepository::class, |
| 118 |
|
]); |
| 119 |
|
|
| 120 |
|
$factory = new ContainerRepositoryFactory($container); |
| 121 |
|
$factory->getRepository($em, 'Foo\CoolEntity'); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
/** |
| 125 |
|
* @expectedException \RuntimeException |
|
@@ 128-143 (lines=16) @@
|
| 125 |
|
* @expectedException \RuntimeException |
| 126 |
|
* @expectedExceptionMessage The "Foo\CoolEntity" entity has a repositoryClass set to "not_a_real_class", but this is not a valid class. Check your class naming. If this is meant to be a service id, make sure this service exists and is tagged with "doctrine.repository_service". |
| 127 |
|
*/ |
| 128 |
|
public function testCustomRepositoryIsNotAValidClass() |
| 129 |
|
{ |
| 130 |
|
if (interface_exists(ContainerInterface::class)) { |
| 131 |
|
$container = $this->createContainer([]); |
| 132 |
|
} else { |
| 133 |
|
// Symfony 3.2 and lower support |
| 134 |
|
$container = null; |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
$em = $this->createEntityManager(['Foo\CoolEntity' => 'not_a_real_class']); |
| 138 |
|
|
| 139 |
|
$factory = new ContainerRepositoryFactory($container); |
| 140 |
|
$factory->getRepository($em, 'Foo\CoolEntity'); |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
private function createContainer(array $services) |
| 144 |
|
{ |
| 145 |
|
$container = $this->getMockBuilder(ContainerInterface::class)->getMock(); |
| 146 |
|
$container->expects($this->any()) |