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 testAssemblingWrongChain()
 {
     $foo = new RouterStaticRule('bar');
     $bar = new RouterHostnameRule('mega.example.com');
     $chain = $foo->chain($bar);
     $this->router->addRoute('foobar', $chain);
     $this->assertEquals(2, $chain->getCount());
     try {
         $s = $this->router->assembly(array(), 'foobar');
     } catch (BaseException $e) {
         $this->assertInstanceOf('RouterException', $e);
         return true;
     }
     $this->fail();
 }