@@ 222-279 (lines=58) @@ | ||
219 | /** |
|
220 | * @dataProvider renderProvider |
|
221 | */ |
|
222 | public function testRenderColumn($gridTemplate = null, $rendererTemplate = null) |
|
223 | { |
|
224 | $template = 'column'; |
|
225 | ||
226 | if ($rendererTemplate !== null) { |
|
227 | $this->renderer = new Renderer( |
|
228 | $this->twig, |
|
229 | $this->actionRenderer, |
|
230 | $this->columnRenderer, |
|
231 | $this->sorterRenderer, |
|
232 | [$template => $rendererTemplate] |
|
233 | ); |
|
234 | } |
|
235 | ||
236 | $view = $this->createGridViewMock(); |
|
237 | $view |
|
238 | ->expects($this->once()) |
|
239 | ->method('getDefinition') |
|
240 | ->will($this->returnValue($grid = $this->createGridMock())); |
|
241 | ||
242 | $grid |
|
243 | ->expects($this->once()) |
|
244 | ->method('hasOption') |
|
245 | ->with($this->identicalTo($option = $template.'_template')) |
|
246 | ->will($this->returnValue($gridTemplate !== null)); |
|
247 | ||
248 | $grid |
|
249 | ->expects($gridTemplate !== null ? $this->once() : $this->never()) |
|
250 | ->method('getOption') |
|
251 | ->with($this->identicalTo($option)) |
|
252 | ->will($this->returnValue($gridTemplate)); |
|
253 | ||
254 | $this->columnRenderer |
|
255 | ->expects($this->once()) |
|
256 | ->method('render') |
|
257 | ->with( |
|
258 | $this->identicalTo($view), |
|
259 | $this->identicalTo($column = $this->createColumnMock()), |
|
260 | $this->identicalTo($data = new \stdClass()) |
|
261 | ) |
|
262 | ->will($this->returnValue($value = 'value')); |
|
263 | ||
264 | $this->twig |
|
265 | ->expects($this->once()) |
|
266 | ->method('render') |
|
267 | ->with( |
|
268 | $this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/'.$template.'.html.twig')), |
|
269 | $this->identicalTo([ |
|
270 | 'column' => $column, |
|
271 | 'data' => $data, |
|
272 | 'value' => $value, |
|
273 | 'grid' => $view, |
|
274 | ]) |
|
275 | ) |
|
276 | ->will($this->returnValue($result = 'result')); |
|
277 | ||
278 | $this->assertSame($result, $this->renderer->renderColumn($view, $column, $data)); |
|
279 | } |
|
280 | ||
281 | /** |
|
282 | * @dataProvider renderProvider |
|
@@ 447-504 (lines=58) @@ | ||
444 | /** |
|
445 | * @dataProvider renderProvider |
|
446 | */ |
|
447 | public function testRenderColumnAction($gridTemplate = null, $rendererTemplate = null) |
|
448 | { |
|
449 | $template = 'column_action'; |
|
450 | ||
451 | if ($rendererTemplate !== null) { |
|
452 | $this->renderer = new Renderer( |
|
453 | $this->twig, |
|
454 | $this->actionRenderer, |
|
455 | $this->columnRenderer, |
|
456 | $this->sorterRenderer, |
|
457 | [$template => $rendererTemplate] |
|
458 | ); |
|
459 | } |
|
460 | ||
461 | $view = $this->createGridViewMock(); |
|
462 | $view |
|
463 | ->expects($this->once()) |
|
464 | ->method('getDefinition') |
|
465 | ->will($this->returnValue($grid = $this->createGridMock())); |
|
466 | ||
467 | $grid |
|
468 | ->expects($this->once()) |
|
469 | ->method('hasOption') |
|
470 | ->with($this->identicalTo($option = $template.'_template')) |
|
471 | ->will($this->returnValue($gridTemplate !== null)); |
|
472 | ||
473 | $grid |
|
474 | ->expects($gridTemplate !== null ? $this->once() : $this->never()) |
|
475 | ->method('getOption') |
|
476 | ->with($this->identicalTo($option)) |
|
477 | ->will($this->returnValue($gridTemplate)); |
|
478 | ||
479 | $this->actionRenderer |
|
480 | ->expects($this->once()) |
|
481 | ->method('render') |
|
482 | ->with( |
|
483 | $this->identicalTo($view), |
|
484 | $this->identicalTo($action = $this->createActionMock()), |
|
485 | $this->identicalTo($data = new \stdClass()) |
|
486 | ) |
|
487 | ->will($this->returnValue($value = 'value')); |
|
488 | ||
489 | $this->twig |
|
490 | ->expects($this->once()) |
|
491 | ->method('render') |
|
492 | ->with( |
|
493 | $this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/'.$template.'.html.twig')), |
|
494 | $this->identicalTo([ |
|
495 | 'action' => $action, |
|
496 | 'data' => $data, |
|
497 | 'value' => $value, |
|
498 | 'grid' => $view, |
|
499 | ]) |
|
500 | ) |
|
501 | ->will($this->returnValue($result = 'result')); |
|
502 | ||
503 | $this->assertSame($result, $this->renderer->renderColumnAction($view, $action, $data)); |
|
504 | } |
|
505 | ||
506 | /** |
|
507 | * @dataProvider renderProvider |