/** * @expectedException Symfony\Component\Routing\Exception\MethodNotAllowedException */ public function testNotAllowed() { // do not set a content here, or we need a valid request and so on... $route = new Route(); $route->setName('not_allowed'); $route->setController('testController'); $route->setRequirement('_method', 'GET'); $route->setPath('/notallowed'); self::$em->persist($route); self::$em->flush(); self::$router->getContext()->setMethod('POST'); self::$router->match('/notallowed'); }
/** * If any of the routers throws a not allowed exception and no other matches, we need to see this * * @expectedException \Symfony\Component\Routing\Exception\MethodNotAllowedException */ public function testMatchMethodNotAllowed() { $url = '/test'; list($low, $high) = $this->createRouterMocks(); $high->expects($this->once())->method('match')->with($url)->will($this->throwException(new MethodNotAllowedException(array()))); $low->expects($this->once())->method('match')->with($url)->will($this->throwException(new ResourceNotFoundException())); $this->router->add($low, 10); $this->router->add($high, 100); $this->router->match('/test'); }
public function testMatchLocale() { $route = new Route(); $route->setPosition($this->getDm()->find(null, self::ROUTE_ROOT), 'de'); $route->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testController'); $this->getDm()->persist($route); $childroute = new Route(); $childroute->setPosition($route, 'testroute'); $childroute->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testController'); $this->getDm()->persist($childroute); $nolocale = new Route(); $nolocale->setPosition($this->getDm()->find(null, self::ROUTE_ROOT), 'es'); $nolocale->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testController'); $this->getDm()->persist($nolocale); $this->getDm()->flush(); $expected = array('_controller' => 'testController', '_locale' => 'de', '_route' => self::ROUTE_ROOT . '/de'); $this->assertEquals($expected, $this->router->match('/de')); $expected = array('_controller' => 'testController', '_locale' => 'de', '_route' => self::ROUTE_ROOT . '/de/testroute'); $this->assertEquals($expected, $this->router->match('/de/testroute')); // es is not a configured locale $expected = array('_controller' => 'testController', '_route' => self::ROUTE_ROOT . '/es'); $this->assertEquals($expected, $this->router->match('/es')); }