Exemplo n.º 1
0
Arquivo: UrlTest.php Projeto: weew/url
 public function test_parse()
 {
     $url = new Url('foo/bar');
     $dict = $url->parse('foo/{name}');
     $this->assertEquals('bar', $dict->get('name'));
     $dict = $url->parse('foo');
     $this->assertNull($dict->get('name'));
     $dict = $url->parse('foo/{name}/{alias?}');
     $this->assertEquals('bar', $dict->get('name'));
     $this->assertNull($dict->get('alias'));
     $dict = $url->parse('foo/{name}/{alias}');
     $this->assertNull($dict->get('name'));
     $this->assertNull($dict->get('alias'));
     $dict = $url->parse('foo/{id}', ['id' => '[a-z]+']);
     $this->assertEquals('bar', $dict->get('id'));
     $dict = $url->parse('foo/{id}', ['id' => '[0-9]+']);
     $this->assertNull($dict->get('id'));
 }