Exemplo n.º 1
0
 function testRequirements()
 {
     $route = new Route('/path', '');
     $route->setRequirements(['id' => '\\d+']);
     $this->assertEquals(['id' => '\\d+'], $route->getRequirements());
     $this->assertEquals('\\d+', $route->getRequirement('id'));
     $this->assertNull($route->getRequirement('undefined'));
     $route->addRequirements(['name' => '\\w+']);
     $this->assertEquals(['id' => '\\d+', 'name' => '\\w+'], $route->getRequirements());
 }
Exemplo n.º 2
0
 function testRouteNotFoundException()
 {
     $routes = new RouteCollection();
     $route = new Route('/foo/{id}/bar/{name}', '');
     $route->setHost('{main}.foo.com');
     $route->setRequirements(['id' => '\\d+', 'name' => '\\w+', 'main' => 'm']);
     $routes->add($route);
     $matcher = new Matcher();
     $context = RequestContext::create();
     $context->setHost('www.foo.com');
     $matcher->setContext($context);
     $this->setExpectedExceptionRegExp('Slince\\Routing\\Exception\\RouteNotFoundException');
     $matcher->match('/foo/100/bar/steven', $routes);
 }