public function testGetInstance()
 {
     $route = RouterStaticRule::create('users/all')->setDefaults(array('area' => 'ctrl'));
     $this->assertInstanceOf('RouterStaticRule', $route);
     $values = $route->match($this->buildRequest('http://localhost/users/all'));
     $this->assertSame('ctrl', $values['area']);
 }
 public function testChainingAssemblyWithStatic()
 {
     $chain = new RouterChainRule();
     $foo = RouterHostnameRule::create('www.example.com')->setDefaults(array('foo' => 'foo'));
     $bar = RouterStaticRule::create('bar')->setDefaults(array('bar' => 'bar'));
     $chain->chain($foo)->chain($bar);
     $request = $this->buildRequest('http://www.example.com/bar');
     $res = $chain->match($request);
     $this->assertInternalType('array', $res);
     $this->assertRegexp('#[^a-z0-9]?www\\.example\\.com/bar$#i', $chain->assembly());
 }
 public function testRouteWithHostnameChain()
 {
     $request = $this->buildRequest('http://www.example.com/bar');
     $foo = RouterHostnameRule::create('nope.example.com')->setDefaults(array('module' => 'nope-bla', 'bogus' => 'bogus'));
     $bar = RouterHostnameRule::create('www.example.com')->setDefaults(array('module' => 'www-bla'));
     $bla = RouterStaticRule::create('bar')->setDefaults(array('area' => 'foo', 'action' => 'bar'));
     $chainMatch = new RouterChainRule();
     $chainMatch->chain($bar)->chain($bla);
     $chainNoMatch = new RouterChainRule();
     $chainNoMatch->chain($foo)->chain($bla);
     $this->router->addRoute('match', $chainMatch);
     $this->router->addRoute('no-match', $chainNoMatch);
     $token = $this->router->route($request);
     $this->assertEquals('foo', $token->getAttachedVar('area'));
     $this->assertEquals('bar', $token->getAttachedVar('action'));
     $this->assertFalse($token->hasAttachedVar('bogus'));
 }