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); }
/** * @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'); } }
/** * @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'); } }
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()); }
public function getParams() { return parent::getParams(); }