[HttpFoundation] changed RequestMatcher pattern syntax
This commit is contained in:
parent
18caddec7a
commit
fafcd02684
@ -85,16 +85,16 @@ class RequestMatcher implements RequestMatcherInterface
|
||||
}
|
||||
|
||||
foreach ($this->attributes as $key => $pattern) {
|
||||
if (!preg_match($pattern, $request->attributes->get($key))) {
|
||||
if (!preg_match('#^'.$pattern.'$#', $request->attributes->get($key))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $this->path && !preg_match($this->path, $request->getPathInfo())) {
|
||||
if (null !== $this->path && !preg_match('#^'.$this->path.'$#', $request->getPathInfo())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $this->host && !preg_match($this->host, $request->getHost())) {
|
||||
if (null !== $this->host && !preg_match('#^'.$this->host.'$#', $request->getHost())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,11 @@ class RequestMatcherTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$matcher = new RequestMatcher();
|
||||
|
||||
$matcher->matchHost('#.*\.example\.com#i');
|
||||
$matcher->matchHost('.*\.example\.com');
|
||||
$request = Request::create('', 'get', array(), array(), array(), array('HTTP_HOST' => 'foo.example.com'));
|
||||
$this->assertTrue($matcher->matches($request));
|
||||
|
||||
$matcher->matchMethod('#sensio\.com#i');
|
||||
$matcher->matchMethod('.*\.sensio\.com');
|
||||
$this->assertFalse($matcher->matches($request));
|
||||
}
|
||||
|
||||
@ -62,11 +62,11 @@ class RequestMatcherTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$matcher = new RequestMatcher();
|
||||
|
||||
$matcher->matchPath('#^/admin#');
|
||||
$matcher->matchPath('/admin/.*');
|
||||
$request = Request::create('/admin/foo');
|
||||
$this->assertTrue($matcher->matches($request));
|
||||
|
||||
$matcher->matchMethod('#^/blog#i');
|
||||
$matcher->matchMethod('/blog/.*');
|
||||
$this->assertFalse($matcher->matches($request));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user