Exemplo n.º 1
0
 /**
  * @dataProvider renderProvider
  */
 public function testRenderGlobalAction($gridTemplate = null, $rendererTemplate = null)
 {
     $template = 'global_action';
     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->actionRenderer->expects($this->once())->method('render')->with($this->identicalTo($view), $this->identicalTo($action = $this->createActionMock()), $this->isNull())->will($this->returnValue($value = 'value'));
     $this->twig->expects($this->once())->method('render')->with($this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/' . $template . '.html.twig')), $this->identicalTo(['action' => $action, 'value' => $value, 'grid' => $view]))->will($this->returnValue($result = 'result'));
     $this->assertSame($result, $this->renderer->renderGlobalAction($view, $action));
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function renderGlobalAction(GridViewInterface $grid, ActionInterface $action)
 {
     return $this->doRender($grid, 'global_action', ['action' => $action, 'value' => $this->actionRenderer->render($grid, $action, null)]);
 }