public function testGetInstance() { require_once 'Zend/Config.php'; $routeConf = array('route' => 'users/all', 'defaults' => array('controller' => 'ctrl')); $config = new Zend_Config($routeConf); $route = Zend_Controller_Router_Route_Static::getInstance($config); $this->assertType('Zend_Controller_Router_Route_Static', $route); $values = $route->match('users/all'); $this->assertSame('ctrl', $values['controller']); }
/** * @group ZF-7368 */ public function testChainingStaticDynamicMatchToParams() { $foo = new Zend_Controller_Router_Route_Static('foo'); $bar = new Zend_Controller_Router_Route(':bar', array('bar' => 1)); $chain = $foo->chain($bar); $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/foo/2'); $res = $chain->match($request); $this->assertTrue(is_array($res), 'Route did not match'); $this->assertEquals(2, $res['bar']); }
public function testChainingSeparatorOverriding() { $foo = new Zend_Controller_Router_Route_Static('foo', array('foo' => 1)); $bar = new Zend_Controller_Router_Route_Static('bar', array('bar' => 2)); $baz = new Zend_Controller_Router_Route_Static('baz', array('baz' => 3)); $chain = $foo->chain($bar, '.'); $res = $chain->match(new Zend_Controller_Router_ChainTest_Request('http://localhost/foo.bar')); $this->assertType('array', $res); $res = $chain->match(new Zend_Controller_Router_ChainTest_Request('http://localhost/foo/bar')); $this->assertEquals(false, $res); $chain->chain($baz, ':'); $res = $chain->match(new Zend_Controller_Router_ChainTest_Request('http://localhost/foo.bar:baz')); $this->assertType('array', $res); }
public function testAssemblingWithNonFirstHostname() { $this->markTestSkipped('Router features not ready'); $foo = new Zend_Controller_Router_Route_Static('bar'); $bar = new Zend_Controller_Router_Route_Hostname('www.zend.com'); $foo->chain($bar); $this->_router->addRoute('foo-bar', $foo); $this->assertEquals('bar/www.zend.com', $this->_router->assemble(array(), 'foo-bar')); }
public function match($path, $partial = false) { $path = $path->getPathInfo(); $match = parent::match($path, $partial); if (is_array($match)) { $this->setMatchedPath($this->_route); } return $match; }
/** * Prepares the route for mapping. * * défaut corrigé : Zend_Controller_Router_Route_Static::match ne décode * pas l'url donc les caractères accentués ne sont pas bien comparés à la route. * La correction consiste à encoder aussi la route (é => %A9%C9) * * @param string $route Map used to match with later submitted URL path * @param array $defaults Defaults for map variables with keys as variable names */ public function __construct($route, $defaults = array()) { // tout est dans le urlencode parent::__construct(urlencode($route), $defaults); }
/** * Matches a user submitted path with a previously defined route. * Assigns and returns an array of defaults on a successful match. * * @param string $path Path used to match against this routing map * @return array|false An array of assigned values or a false on a mismatch */ public function match($path, $partial = false) { return parent::match(trim($path, '/'), true); }
public function testGetDefault() { $route = new Zend_Controller_Router_Route_Static('users/all', array('controller' => 'ctrl', 'action' => 'act')); $this->assertSame('ctrl', $route->getDefault('controller')); $this->assertSame(null, $route->getDefault('bogus')); }