Пример #1
0
 protected function createMvcEvent()
 {
     $this->mvcEvent = new MvcEvent();
     $request = new Request();
     $response = new Response();
     $routeMatch = new RouteMatch([]);
     $routeMatch->setMatchedRouteName('test/route');
     $routeMatch->setParam('controller', 'Application\\Controller\\Index');
     $routeMatch->setParam('action', 'index');
     $this->mvcEvent->setRouteMatch($routeMatch);
     $this->mvcEvent->setRequest($request);
     $this->mvcEvent->setResponse($response);
 }
 /**
  * @dataProvider tetShowBackButtonDefaultProvider
  */
 public function testShowBackButtonDefault($id, $backLinkValue, $expectedBackLink)
 {
     $this->docs->expects($this->once())->method('getOne')->with($id);
     $this->routeMatch->setParam('action', 'show');
     $this->routeMatch->setParam('id', $id);
     if (null !== $backLinkValue) {
         $this->routeMatch->setParam('show_back_link', $backLinkValue);
     }
     $result = $this->object->dispatch($this->request, $this->response);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('data', $result);
     $this->assertArrayHasKey('showBackLink', $result);
     $this->assertEquals($expectedBackLink, $result['showBackLink']);
 }
Пример #3
0
 protected function dispatch($controller, $action, $renderView = FALSE)
 {
     $this->event = $this->application->getMvcEvent();
     $this->request = new Request();
     //		$this->routeMatch = $this->eventManager->trigger(MvcEvent::EVENT_ROUTE, $this->event)->first();
     $this->routeMatch = new RouteMatch(array('controller' => $controller));
     $this->routeMatch->setParam('action', $action);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     return $this->controller->dispatch($this->request, $this->response);
     //		$this->request->setUri($url);
     //		$this->viewModel = $this->eventManager->trigger(MvcEvent::EVENT_DISPATCH, $this->event)->first();
     //		$responseEvent = ($renderView ? MvcEvent::EVENT_RENDER : MvcEvent::EVENT_FINISH);
     //		$this->response = $this->eventManager->trigger($responseEvent, $this->event)->first();
 }