示例#1
0
 public function testAssembleWithMappedVariableWithoutMatch()
 {
     $route = new Zend_Controller_Router_Route_Regex('users/(.+)', null, array(1 => 'username'), 'users/%s');
     $url = $route->assemble(array('username' => 'vicki'));
     $this->assertSame('users/vicki', $url);
 }
示例#2
0
    public function testAssembleZF2301() 
    {
        $route = new Zend_Controller_Router_Route_Regex(
            "itemlist(?:/(\d+))?",
            array('page' => 1), // Defaults
            array(1 => 'page'), // Parameter map
            'itemlist/%d'
        );
        
        $values = $route->match('/itemlist/2');
        
        $this->assertEquals(array('page' => 2), $values);

        $url = $route->assemble();
        $this->assertEquals('itemlist/2', $url);
        
        $url = $route->assemble(array('page' => 2));
        $this->assertEquals('itemlist/2', $url);
    }
示例#3
0
文件: RegexTest.php 项目: lortnus/zf1
 /**
  * @issue ZF-2301
  */
 public function testAssemblyOfRouteWithMergedMatchedParts()
 {
     $route = new Zend_Controller_Router_Route_Regex('itemlist(?:/(\\d+))?', array('page' => 1), array(1 => 'page'), 'itemlist/%d');
     // make sure defaults work
     $this->assertEquals(array('page' => 1), $route->match('/itemlist/'));
     // make sure default assembly work
     $this->assertEquals('itemlist/1', $route->assemble());
     // make sure the route is parsed correctly
     $this->assertEquals(array('page' => 2), $route->match('/itemlist/2'));
     // check to make sure that the default assembly will return with default 1 (previously defined)
     $this->assertEquals('itemlist/2', $route->assemble());
     // check to make sure that the assembly will return with provided page=3 in the correct place
     $this->assertEquals('itemlist/3', $route->assemble(array('page' => 3)));
     // check to make sure that the assembly can reset a single parameter
     $this->assertEquals('itemlist/1', $route->assemble(array('page' => null)));
 }
示例#4
0
文件: RegexTest.php 项目: travisj/zf
 /**
  * Allow using <lang>1</lang> instead of invalid <1>lang</1> for xml router
  * config.
  *
  * <zend-config>
  *     <routes>
  *         <page>
  *             <type>Zend_Controller_Router_Route_Regex</type>
  *             <route>([a-z]{2})/page/(.*)</route>
  *             <defaults>
  *                 <controller>index</controller>
  *                 <action>showpage</action>
  *             </defaults>
  *             <map>
  *                 <lang>1</lang>
  *                 <title>2</title>
  *             </map>
  *             <reverse>%s/page/%s</reverse>
  *         </page>
  *     </routes>
  * </zend-config>
  *
  *
  * @group ZF-7658
  */
 public function testAssembleWithFlippedMappedVariables()
 {
     $route = new Zend_Controller_Router_Route_Regex('([a-z]{2})/page/(.*)', array('controller' => 'index', 'action' => 'showpage'), array('lang' => 1, 'title' => 2), '%s/page/%s');
     $url = $route->assemble(array('lang' => 'fi', 'title' => 'Suomi'), true, true);
     $this->assertEquals($url, 'fi/page/Suomi');
 }
示例#5
0
 public function testAssembleZF1332()
 {
     $route = new Zend_Controller_Router_Route_Regex('(.+)\\.([0-9]+)-([0-9]+)\\.html', array('module' => 'default', 'controller' => 'content.item', 'action' => 'forward'), array(1 => 'name', 2 => 'id', 3 => 'class'), '%s.%s-%s.html');
     $route->match('uml-explained-composition.72-3.html');
     $url = $route->assemble();
     $this->assertSame('uml-explained-composition.72-3.html', $url);
     $url = $route->assemble(array('name' => 'post_name', 'id' => '12', 'class' => 5));
     $this->assertSame('post_name.12-5.html', $url);
 }