public function testAssembleCanonicalUriWithHostnameRouteAndRequestUriWithoutScheme()
 {
     $uri = new HttpUri();
     $uri->setScheme('http');
     $stack = new TreeRouteStack();
     $stack->setRequestUri($uri);
     $stack->addRoute('foo', new Hostname('example.com'));
     $this->assertEquals('http://example.com', $stack->assemble(array(), array('name' => 'foo')));
 }
 public function testAssembleWithScheme()
 {
     $uri   = new HttpUri();
     $uri->setScheme('http');
     $uri->setHost('example.com');
     $stack = new TreeRouteStack();
     $stack->setRequestUri($uri);
     $stack->addRoute(
         'secure',
         array(
             'type' => 'Scheme',
             'options' => array(
                 'scheme' => 'https'
             ),
             'child_routes' => array(
                 'index' => array(
                     'type'    => 'Literal',
                     'options' => array(
                         'route'    => '/',
                     ),
                 ),
             ),
         )
     );
     $this->assertEquals('https://example.com/', $stack->assemble(array(), array('name' => 'secure/index')));
 }
 public function testAssembleWithQueryRoute()
 {
     $uri = new HttpUri();
     $uri->setScheme('http');
     $stack = new TreeRouteStack();
     $stack->setRequestUri($uri);
     $stack->addRoute('index', array('type' => 'Literal', 'options' => array('route' => '/'), 'child_routes' => array('query' => array('type' => 'Query'))));
     $this->assertEquals('/?bar=baz', $stack->assemble(array('bar' => 'baz'), array('name' => 'index/query')));
 }
Beispiel #4
0
 public function testChainRouteAssemblingWithChildrenAndSecureScheme()
 {
     $stack = new TreeRouteStack();
     $uri = new \Zend\Uri\Http();
     $uri->setHost('localhost');
     $stack->setRequestUri($uri);
     $stack->addRoute('foo', array('type' => 'literal', 'options' => array('route' => '/foo'), 'chain_routes' => array(array('type' => 'scheme', 'options' => array('scheme' => 'https'))), 'child_routes' => array('baz' => array('type' => 'literal', 'options' => array('route' => '/baz')))));
     $this->assertEquals('https://localhost/foo/baz', $stack->assemble(array(), array('name' => 'foo/baz')));
 }