|
@@ 117-156 (lines=40) @@
|
| 114 |
|
/** |
| 115 |
|
* @test |
| 116 |
|
*/ |
| 117 |
|
public function shouldListEntities() |
| 118 |
|
{ |
| 119 |
|
/** @var Request $request */ |
| 120 |
|
$request = $this->createMock(Request::class); |
| 121 |
|
|
| 122 |
|
/** @var string $expectedResponseContent */ |
| 123 |
|
$expectedResponseContent = '[{"lorem":false,"ipsum":"foo"},{"lorem":false,"ipsum":"foo"}]'; |
| 124 |
|
|
| 125 |
|
/** @var SampleEntity $entityA */ |
| 126 |
|
$entityA = $this->createMock(SampleEntity::class); |
| 127 |
|
|
| 128 |
|
/** @var SampleEntity $entityB */ |
| 129 |
|
$entityB = $this->createMock(SampleEntity::class); |
| 130 |
|
|
| 131 |
|
$this->controllerHelper->expects($this->once())->method('findEntities')->with( |
| 132 |
|
$this->equalTo(SampleEntity::class), |
| 133 |
|
$this->equalTo(['blah' => 'blubb']) |
| 134 |
|
)->willReturn([$entityA, $entityB]); |
| 135 |
|
|
| 136 |
|
$this->argumentCompiler->expects($this->once())->method('buildArguments')->with( |
| 137 |
|
$this->equalTo(['foo' => 'bar']), |
| 138 |
|
$this->identicalTo($request) |
| 139 |
|
)->willReturn(['blah' => 'blubb']); |
| 140 |
|
|
| 141 |
|
$controller = new GenericEntityListingController($this->controllerHelper, $this->argumentCompiler, [ |
| 142 |
|
'entity-class' => SampleEntity::class, |
| 143 |
|
'data-template' => [ |
| 144 |
|
'lorem' => 'fooCalled', |
| 145 |
|
'ipsum' => 'constructArgument' |
| 146 |
|
], |
| 147 |
|
'criteria' => [ |
| 148 |
|
'foo' => 'bar' |
| 149 |
|
] |
| 150 |
|
]); |
| 151 |
|
|
| 152 |
|
/** @var Response $actualResponse */ |
| 153 |
|
$actualResponse = $controller->listEntities($request); |
| 154 |
|
|
| 155 |
|
$this->assertEquals($expectedResponseContent, $actualResponse->getContent()); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
/** |
| 159 |
|
* @test |
|
@@ 220-261 (lines=42) @@
|
| 217 |
|
/** |
| 218 |
|
* @test |
| 219 |
|
*/ |
| 220 |
|
public function shouldBeCallableByInvokingController() |
| 221 |
|
{ |
| 222 |
|
/** @var Request $request */ |
| 223 |
|
$request = $this->createMock(Request::class); |
| 224 |
|
|
| 225 |
|
/** @var string $expectedResponseContent */ |
| 226 |
|
$expectedResponseContent = '[{"lorem":false,"ipsum":"foo"},{"lorem":false,"ipsum":"foo"}]'; |
| 227 |
|
|
| 228 |
|
/** @var SampleEntity $entityA */ |
| 229 |
|
$entityA = $this->createMock(SampleEntity::class); |
| 230 |
|
|
| 231 |
|
/** @var SampleEntity $entityB */ |
| 232 |
|
$entityB = $this->createMock(SampleEntity::class); |
| 233 |
|
|
| 234 |
|
$this->controllerHelper->expects($this->once())->method('findEntities')->with( |
| 235 |
|
$this->equalTo(SampleEntity::class), |
| 236 |
|
$this->equalTo(['blah' => 'blubb']) |
| 237 |
|
)->willReturn([$entityA, $entityB]); |
| 238 |
|
|
| 239 |
|
$this->argumentCompiler->expects($this->once())->method('buildArguments')->with( |
| 240 |
|
$this->equalTo(['foo' => 'bar']), |
| 241 |
|
$this->identicalTo($request) |
| 242 |
|
)->willReturn(['blah' => 'blubb']); |
| 243 |
|
|
| 244 |
|
$controller = new GenericEntityListingController($this->controllerHelper, $this->argumentCompiler, [ |
| 245 |
|
'entity-class' => SampleEntity::class, |
| 246 |
|
'data-template' => [ |
| 247 |
|
'lorem' => 'fooCalled', |
| 248 |
|
'ipsum' => 'constructArgument' |
| 249 |
|
], |
| 250 |
|
'criteria' => [ |
| 251 |
|
'foo' => 'bar' |
| 252 |
|
] |
| 253 |
|
]); |
| 254 |
|
|
| 255 |
|
$this->controllerHelper->method('getCurrentRequest')->willReturn($request); |
| 256 |
|
|
| 257 |
|
/** @var Response $actualResponse */ |
| 258 |
|
$actualResponse = $controller(); |
| 259 |
|
|
| 260 |
|
$this->assertEquals($expectedResponseContent, $actualResponse->getContent()); |
| 261 |
|
} |
| 262 |
|
|
| 263 |
|
/** |
| 264 |
|
* @test |