public function testBlockRendering() { $view = new BlockView(); $blockName = 'test'; $variables = ['foo' => 'bar']; $this->renderer->expects($this->once())->method('renderBlock')->with($this->identicalTo($view), $blockName, $variables); $this->helper->block($view, $blockName, $variables); }
public function testViewWithForms() { $this->parameterResolver->expects($this->once())->method('resolveApi')->will($this->returnValue(false)); $event = $this->createViewEventMock(); $event->expects($this->once())->method('getView')->will($this->returnValue($view = $this->createViewMock())); $view->expects($this->once())->method('getData')->will($this->returnValue([$object = new \stdClass(), $form = $this->createFormMock()])); $form->expects($this->once())->method('createView')->will($this->returnValue($formView = $this->createFormViewMock())); $this->parameterResolver->expects($this->once())->method('resolveThemes')->will($this->returnValue($themes = ['theme'])); $this->formRenderer->expects($this->once())->method('setTheme')->with($this->identicalTo($formView), $this->identicalTo($themes)); $view->expects($this->once())->method('setData')->with($this->identicalTo([$object, $formView])); $this->subscriber->onView($event); }
public function testViewFormThemes() { $this->parameterResolver->expects($this->once())->method('resolveApi')->will($this->returnValue(false)); $this->parameterResolver->expects($this->once())->method('resolveThemes')->will($this->returnValue($themes = ['theme'])); $event = $this->createViewEventMock(); $event->expects($this->once())->method('getView')->will($this->returnValue($view = $this->createViewMock())); $view->expects($this->once())->method('getData')->will($this->returnValue(['grid' => $gridView = $this->createGridViewMock(), 'batch_form' => $batchForm = $this->createFormMock()])); $batchForm->expects($this->once())->method('createView')->will($this->returnValue($batchFormView = $this->createFormViewMock())); $gridView->expects($this->once())->method('setBatchForm')->with($this->identicalTo($batchFormView)); $gridView->expects($this->once())->method('getForm')->will($this->returnValue($formView = $this->createFormViewMock())); $gridView->expects($this->exactly(2))->method('getBatchForm')->willReturnOnConsecutiveCalls(null, $batchFormView); $this->formRenderer->expects($this->exactly(2))->method('setTheme')->withConsecutive([$formView, $themes], [$batchFormView, $themes]); $view->expects($this->once())->method('setTemplateVar')->with($this->identicalTo('grid'))->will($this->returnSelf()); $view->expects($this->once())->method('setData')->with($this->identicalTo($gridView)); $this->subscriber->onView($event); }
public function testApiWithHateoas() { $this->parameterResolver->expects($this->once())->method('resolveApi')->will($this->returnValue(true)); $this->parameterResolver->expects($this->once())->method('resolveHateoas')->will($this->returnValue(true)); $event = $this->createViewEventMock(); $event->expects($this->once())->method('getView')->will($this->returnValue($view = $this->createViewMock())); $view->expects($this->once())->method('getData')->will($this->returnValue($pagerfanta = $this->createPagerfantaMock())); $this->requestStack->expects($this->once())->method('getMasterRequest')->will($this->returnValue($request = $this->createRequestMock())); $request->attributes->expects($this->exactly(2))->method('get')->will($this->returnValueMap([['_route', null, $route = 'route'], ['_route_params', [], $routeParameters = ['foo' => 'bar']]])); $request->query->expects($this->once())->method('all')->will($this->returnValue($queryParameters = ['baz' => 'bat'])); $this->pagerfantaFactory->expects($this->once())->method('createRepresentation')->with($this->identicalTo($pagerfanta), $this->callback(function ($config) use($route, $routeParameters, $queryParameters) { return $config instanceof Route && $config->getName() === $route && $config->getParameters() === array_merge($routeParameters, $queryParameters); }))->will($this->returnValue($representation = 'representation')); $view->expects($this->once())->method('setData')->with($this->identicalTo($representation)); $this->subscriber->onApi($event); }