|
@@ 88-102 (lines=15) @@
|
| 85 |
|
* @expectedException \RuntimeException |
| 86 |
|
* @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". |
| 87 |
|
*/ |
| 88 |
|
public function testRepositoryMatchesServiceInterfaceButServiceNotFound() |
| 89 |
|
{ |
| 90 |
|
if (! interface_exists(ContainerInterface::class)) { |
| 91 |
|
$this->markTestSkipped('Symfony 3.3 is needed for this feature.'); |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
$container = $this->createContainer([]); |
| 95 |
|
|
| 96 |
|
$em = $this->createEntityManager([ |
| 97 |
|
'Foo\CoolEntity' => StubServiceRepository::class, |
| 98 |
|
]); |
| 99 |
|
|
| 100 |
|
$factory = new ContainerRepositoryFactory($container); |
| 101 |
|
$factory->getRepository($em, 'Foo\CoolEntity'); |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
/** |
| 105 |
|
* @expectedException \RuntimeException |
|
@@ 108-123 (lines=16) @@
|
| 105 |
|
* @expectedException \RuntimeException |
| 106 |
|
* @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". |
| 107 |
|
*/ |
| 108 |
|
public function testCustomRepositoryIsNotAValidClass() |
| 109 |
|
{ |
| 110 |
|
if (interface_exists(ContainerInterface::class)) { |
| 111 |
|
$container = $this->createContainer([]); |
| 112 |
|
} else { |
| 113 |
|
// Symfony 3.2 and lower support |
| 114 |
|
$container = null; |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
$em = $this->createEntityManager(['Foo\CoolEntity' => 'not_a_real_class']); |
| 118 |
|
|
| 119 |
|
$factory = new ContainerRepositoryFactory($container); |
| 120 |
|
$factory->getRepository($em, 'Foo\CoolEntity'); |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
private function createContainer(array $services) |
| 124 |
|
{ |
| 125 |
|
$container = $this->getMockBuilder(ContainerInterface::class)->getMock(); |
| 126 |
|
$container->expects($this->any()) |