|
@@ 47-59 (lines=13) @@
|
| 44 |
|
* @expectedException \RuntimeException |
| 45 |
|
* @expectedExceptionMessage The service "my_repo" must extend EntityRepository (or a base class, like ServiceEntityRepository). |
| 46 |
|
*/ |
| 47 |
|
public function testServiceRepositoriesMustExtendEntityRepository() |
| 48 |
|
{ |
| 49 |
|
$repo = new \stdClass(); |
| 50 |
|
$container = $this->createContainer(array( |
| 51 |
|
'my_repo' => $repo |
| 52 |
|
)); |
| 53 |
|
$em = $this->createEntityManager(array( |
| 54 |
|
'Foo\CoolEntity' => 'my_repo' |
| 55 |
|
)); |
| 56 |
|
|
| 57 |
|
$factory = new ContainerRepositoryFactory($container); |
| 58 |
|
$factory->getRepository($em, 'Foo\CoolEntity'); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
/** |
| 62 |
|
* @expectedException \RuntimeException |
|
@@ 65-74 (lines=10) @@
|
| 62 |
|
* @expectedException \RuntimeException |
| 63 |
|
* @expectedExceptionMessage Could not find the repository service for the "Foo\CoolEntity" entity. Make sure the "my_repo" service exists and is tagged with "doctrine.repository_service". |
| 64 |
|
*/ |
| 65 |
|
public function testIfServiceDoesNotExist() |
| 66 |
|
{ |
| 67 |
|
$container = $this->createContainer(array()); |
| 68 |
|
$em = $this->createEntityManager(array( |
| 69 |
|
'Foo\CoolEntity' => 'my_repo' |
| 70 |
|
)); |
| 71 |
|
|
| 72 |
|
$factory = new ContainerRepositoryFactory($container); |
| 73 |
|
$factory->getRepository($em, 'Foo\CoolEntity'); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
private function createContainer(array $services) |
| 77 |
|
{ |