コード例 #1
7
 private function setUpDispatcher()
 {
     $this->dispatcher->setControllerName($this->router->getControllerName());
     $this->dispatcher->setActionName($this->router->getActionName());
     $this->dispatcher->setParams($this->router->getParams());
     $oDispatcherEventManager = new Manager();
     $oDispatcherEventManager->attach('dispatch:beforeDispatch', function (Event $oEvent, Dispatcher $oDispatcher, $data) {
         return false;
     });
     $this->dispatcher->setEventsManager($oDispatcherEventManager);
 }
コード例 #2
0
 /**
  * @dataProvider easyMatchedProvider
  */
 public function testEasyMatched($strUri, $strController, $strAction, $strRouteName, $arParameters = array())
 {
     $this->router->handle($strUri);
     $boolMatched = $this->router->wasMatched();
     $this->assertTrue($boolMatched, 'route ' . $strUri . ' does not match any of ' . print_r($this->routes, true) . ' when it should');
     $this->assertEquals($strRouteName, $this->router->getMatchedRoute()->getName(), 'matches wrong route');
     $this->assertEquals($strController, $this->router->getControllerName(), 'wrong controller name');
     $this->assertEquals($strAction, $this->router->getActionName(), 'wrong action name');
     $arActualParameters = $this->router->getParams();
     foreach ($arParameters as $key => $value) {
         $this->assertArrayHasKey($key, $arParameters, 'key "' . $key . '" not found');
         $this->assertEquals($arParameters[$key], $arActualParameters[$key], 'parameter "' . $key . '" mismatch');
     }
 }
コード例 #3
0
 /**
  * @covers initialize
  *
  *
  * @dataProvider easyMatchRoutesDataProvider
  */
 public function testMatchEasyRoutes($strUri, $strModule, $strController, $strAction, $strRouteName, $arParameters)
 {
     $this->router->handle($strUri);
     $boolMatched = $this->router->wasMatched();
     $this->assertTrue($boolMatched, 'route does not match when it should');
     $this->assertEquals($strRouteName, $this->router->getMatchedRoute()->getName(), 'matched wrong route: ' . $this->router->getMatchedRoute()->getPattern());
     $this->assertEquals($strModule, $this->router->getModuleName(), 'wrong module name');
     $this->assertEquals($strController, $this->router->getControllerName(), 'wrong controller name');
     $this->assertEquals($strAction, $this->router->getActionName(), 'wrong action name');
     $arActualParameters = $this->router->getParams();
     foreach ($arParameters as $key => $value) {
         $this->assertArrayHasKey($key, $arParameters, 'key "' . $key . '" not found');
         $this->assertEquals($arParameters[$key], $arActualParameters[$key], 'parameter "' . $key . '" mismatch');
     }
 }
コード例 #4
0
ファイル: Dispatcher.php プロジェクト: nexik/nest-core
 public function routing(Router $router)
 {
     $this->setModuleName($router->getModuleName());
     $this->setNamespaceName($router->getNamespaceName());
     $this->setControllerName($router->getControllerName());
     $this->setActionName($router->getActionName());
     $this->setParams($router->getParams());
 }
コード例 #5
0
ファイル: Router.php プロジェクト: mattvb91/cphalcon
 public function getParams()
 {
     return parent::getParams();
 }