|
@@ 123-145 (lines=23) @@
|
| 120 |
|
* @covers Netdudes\DataSourceryBundle\DataSource\Util\ChoicesBuilder::build |
| 121 |
|
* @covers Netdudes\DataSourceryBundle\DataSource\Util\ChoicesBuilder::getChoicesFromRepositoryWithMethod |
| 122 |
|
*/ |
| 123 |
|
public function testBuildingChoicesFromRepositoryMethodWhenMethodDoesNotExist() |
| 124 |
|
{ |
| 125 |
|
$methodName = 'a_method'; |
| 126 |
|
$repositoryName = 'a_test_repository'; |
| 127 |
|
|
| 128 |
|
$repositoryMock = $this->prepareRepositoryMock([$methodName]); |
| 129 |
|
$repositoryMock->expects($this->never()) |
| 130 |
|
->method($methodName); |
| 131 |
|
|
| 132 |
|
$emMock = $this->prepareEntityManagerMock(); |
| 133 |
|
$emMock->expects($this->once()) |
| 134 |
|
->method('getRepository') |
| 135 |
|
->with($this->equalTo($repositoryName)) |
| 136 |
|
->willReturn($repositoryMock); |
| 137 |
|
|
| 138 |
|
$builder = new ChoicesBuilder($emMock); |
| 139 |
|
|
| 140 |
|
$this->setExpectedException('Exception', 'Specified repository does not have \'other_method\' method'); |
| 141 |
|
$builder->build([ |
| 142 |
|
'repository' => $repositoryName, |
| 143 |
|
'method' => 'other_method', |
| 144 |
|
]); |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
/** |
| 148 |
|
* @covers Netdudes\DataSourceryBundle\DataSource\Util\ChoicesBuilder::build |
|
@@ 151-174 (lines=24) @@
|
| 148 |
|
* @covers Netdudes\DataSourceryBundle\DataSource\Util\ChoicesBuilder::build |
| 149 |
|
* @covers Netdudes\DataSourceryBundle\DataSource\Util\ChoicesBuilder::getChoicesFromRepositoryWithMethod |
| 150 |
|
*/ |
| 151 |
|
public function testBuildingChoicesFromRepositoryMethodWhenMethodDoesNotReturnAnArray() |
| 152 |
|
{ |
| 153 |
|
$methodName = 'a_method'; |
| 154 |
|
$repositoryName = 'a_test_repository'; |
| 155 |
|
|
| 156 |
|
$repositoryMock = $this->prepareRepositoryMock([$methodName]); |
| 157 |
|
$repositoryMock->expects($this->once()) |
| 158 |
|
->method($methodName) |
| 159 |
|
->willReturn('not an array'); |
| 160 |
|
|
| 161 |
|
$emMock = $this->prepareEntityManagerMock(); |
| 162 |
|
$emMock->expects($this->once()) |
| 163 |
|
->method('getRepository') |
| 164 |
|
->with($this->equalTo($repositoryName)) |
| 165 |
|
->willReturn($repositoryMock); |
| 166 |
|
|
| 167 |
|
$builder = new ChoicesBuilder($emMock); |
| 168 |
|
|
| 169 |
|
$this->setExpectedException('Exception', 'Choices repository method defined in table configurations must return array'); |
| 170 |
|
$builder->build([ |
| 171 |
|
'repository' => $repositoryName, |
| 172 |
|
'method' => $methodName, |
| 173 |
|
]); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
/** |
| 177 |
|
* @covers Netdudes\DataSourceryBundle\DataSource\Util\ChoicesBuilder::build |