Ejemplo n.º 1
0
 /**
  * @dataProvider routeProvider
  * @param        Regex   $route
  * @param        string  $path
  * @param        integer $offset
  * @param        array   $params
  */
 public function testAssembling(Regex $route, $path, $offset, array $params = null)
 {
     if ($params === null) {
         // Data which will not match are not tested for assembling.
         return;
     }
     $result = $route->assemble($params);
     if ($offset !== null) {
         $this->assertEquals($offset, strpos($path, $result, $offset));
     } else {
         $this->assertEquals($path, $result);
     }
 }
Ejemplo n.º 2
0
 public function testGetAssembledParams()
 {
     $route = new Regex('/(?<foo>.+)', '/%foo%');
     $route->assemble(array('foo' => 'bar', 'baz' => 'bat'));
     $this->assertEquals(array('foo'), $route->getAssembledParams());
 }
Ejemplo n.º 3
0
 /**
  * Create a new regex route.
  *
  * @param  string $regex
  * @param  string $spec
  * @param  array  $defaults
  */
 public function __construct($regex, $spec, array $defaults = array())
 {
     parent::__construct($regex, $spec, $defaults);
 }
Ejemplo n.º 4
0
 public function testEncodedDecode()
 {
     // every character
     $in = '%61%62%63%64%65%66%67%68%69%6a%6b%6c%6d%6e%6f%70%71%72%73%74%75%76%77%78%79%7a%41%42%43%44%45%46%47%48%49%4a%4b%4c%4d%4e%4f%50%51%52%53%54%55%56%57%58%59%5a%30%31%32%33%34%35%36%37%38%39%60%2d%3d%5b%5d%5c%3b%27%2c%2e%2f%7e%21%40%23%24%25%5e%26%2a%28%29%5f%2b%7b%7d%7c%3a%22%3c%3e%3f';
     $out = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`-=[]\\;\',./~!@#$%^&*()_+{}|:"<>?';
     $request = new Request();
     $request->setUri('http://example.com/' . $in);
     $route = new Regex('/(?<foo>[^/]+)', '/%foo%');
     $match = $route->match($request);
     $this->assertSame($out, $match->getParam('foo'));
 }