matchPath() public method

Adds a check for the URL path info.
public matchPath ( string $regexp )
$regexp string A Regexp
コード例 #1
0
 public function testPath()
 {
     $matcher = new RequestMatcher();
     $request = Request::create('/admin/foo');
     $matcher->matchPath('/admin/.*');
     $this->assertTrue($matcher->matches($request));
     $matcher->matchPath('/admin');
     $this->assertTrue($matcher->matches($request));
     $matcher->matchPath('^/admin/.*$');
     $this->assertTrue($matcher->matches($request));
     $matcher->matchMethod('/blog/.*');
     $this->assertFalse($matcher->matches($request));
 }
コード例 #2
0
ファイル: RequestMatcherTest.php プロジェクト: mawaha/tracker
 public function testPathWithEncodedCharacters()
 {
     $matcher = new RequestMatcher();
     $request = Request::create('/admin/fo%20o');
     $matcher->matchPath('^/admin/fo o*$');
     $this->assertTrue($matcher->matches($request));
 }
コード例 #3
0
 public function testPathWithLocale()
 {
     $matcher = new RequestMatcher();
     $request = Request::create('/en/login');
     $session = new Session(new ArraySessionStorage());
     $session->setLocale('en');
     $request->setSession($session);
     $matcher->matchPath('^/{_locale}/login$');
     $this->assertTrue($matcher->matches($request));
     $session->setLocale('de');
     $this->assertFalse($matcher->matches($request));
 }
コード例 #4
0
    public function testPathWithLocaleIsNotSupported()
    {
        $matcher = new RequestMatcher();
        $request = Request::create('/en/login');
        $request->setLocale('en');

        $matcher->matchPath('^/{_locale}/login$');
        $this->assertFalse($matcher->matches($request));
    }