Пример #1
0
 public function testViewWithTemplateVar()
 {
     $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($data = new \stdClass()));
     $this->parameterResolver->expects($this->once())->method('resolveTemplate')->will($this->returnValue($template = 'template'));
     $view->expects($this->once())->method('setTemplate')->with($this->identicalTo($template))->will($this->returnSelf());
     $event->expects($this->once())->method('getResource')->will($this->returnValue($resource = $this->createResourceMock()));
     $view->expects($this->once())->method('getTemplateVar')->will($this->returnValue($templateVar = 'template_var'));
     $view->expects($this->once())->method('setData')->with($this->identicalTo([$templateVar => $data, 'resource' => $resource]));
     $this->subscriber->onView($event);
 }