/** * @return RouterChainRule **/ public function chain(RouterRule $route, $separator = '/') { $chain = new RouterChainRule(); $chain->chain($this)->chain($route, $separator); return $chain; }
public function testAssemblyWithHostnameAndTransparent() { $chain = new RouterChainRule(); $host = RouterHostnameRule::create(':subdomain.example.com')->setDefaults(array('subdomain' => 'www')); $transparent = RouterTransparentRule::create(':bar/:area/:action')->setDefaults(array('bar' => 'barvalue', 'area' => 'controller', 'action' => 'create')); $chain->chain($host)->chain($transparent); $this->assertEquals('http://www.example.com/', $chain->assembly()); $this->assertEquals('http://www.example.com/barvalue/controller/misc', $chain->assembly(array('action' => 'misc'))); $this->assertEquals('http://www.example.com/barvalue/misc', $chain->assembly(array('area' => 'misc'))); $this->assertEquals('http://www.example.com/misc', $chain->assembly(array('bar' => 'misc'))); }
public function testAssemblingWithHostnameAndTransparentWithBaseUrl() { $base = 'http://www.example.com/~users/public/www/'; $hostname = RouterHostnameRule::create(':subdomain.example.com')->setDefaults(array('subdomain' => 'www')); $transparent = RouterTransparentRule::create('/company/:id')->setRequirements(array('id' => '\\d+')); $chain = RouterChainRule::create()->chain($hostname)->chain($transparent); $this->router->setBaseUrl(HttpUrl::create()->parse($base)); $this->router->addRoute('chain', $chain); $this->assertEquals('http://test.example.com/~users/public/www/company/123', $this->router->assembly(array('subdomain' => 'test', 'id' => 123), 'chain')); }