Beispiel #1
0
 /**
  * @dataProvider renderProvider
  */
 public function testRenderColumn($gridTemplate = null, $rendererTemplate = null)
 {
     $template = 'column';
     if ($rendererTemplate !== null) {
         $this->renderer = new Renderer($this->twig, $this->actionRenderer, $this->columnRenderer, $this->sorterRenderer, [$template => $rendererTemplate]);
     }
     $view = $this->createGridViewMock();
     $view->expects($this->once())->method('getDefinition')->will($this->returnValue($grid = $this->createGridMock()));
     $grid->expects($this->once())->method('hasOption')->with($this->identicalTo($option = $template . '_template'))->will($this->returnValue($gridTemplate !== null));
     $grid->expects($gridTemplate !== null ? $this->once() : $this->never())->method('getOption')->with($this->identicalTo($option))->will($this->returnValue($gridTemplate));
     $this->columnRenderer->expects($this->once())->method('render')->with($this->identicalTo($view), $this->identicalTo($column = $this->createColumnMock()), $this->identicalTo($data = new \stdClass()))->will($this->returnValue($value = 'value'));
     $this->twig->expects($this->once())->method('render')->with($this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/' . $template . '.html.twig')), $this->identicalTo(['column' => $column, 'data' => $data, 'value' => $value, 'grid' => $view]))->will($this->returnValue($result = 'result'));
     $this->assertSame($result, $this->renderer->renderColumn($view, $column, $data));
 }
Beispiel #2
0
 public function testRenderWithNull()
 {
     $this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($path = 'path_value'))->will($this->returnValue(null));
     $this->renderer->expects($this->never())->method('render');
     $this->assertNull($this->type->render($data, ['path' => $path]));
 }