diff options
Diffstat (limited to 'Tests/Http/HttpUtilsTest.php')
-rw-r--r-- | Tests/Http/HttpUtilsTest.php | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Tests/Http/HttpUtilsTest.php b/Tests/Http/HttpUtilsTest.php index a30051f..bf078da 100644 --- a/Tests/Http/HttpUtilsTest.php +++ b/Tests/Http/HttpUtilsTest.php @@ -97,6 +97,11 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase $this->assertTrue($utils->checkRequestPath($this->getRequest(), '/')); $this->assertFalse($utils->checkRequestPath($this->getRequest(), '/foo')); + $this->assertTrue($utils->checkRequestPath($this->getRequest('/foo%20bar'), '/foo bar')); + // Plus must not decoded to space + $this->assertTrue($utils->checkRequestPath($this->getRequest('/foo+bar'), '/foo+bar')); + // Checking unicode + $this->assertTrue($utils->checkRequestPath($this->getRequest(urlencode('/вход')), '/вход')); $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); $urlMatcher @@ -132,13 +137,25 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase $utils->checkRequestPath($this->getRequest(), 'foobar'); } - private function getUrlGenerator() + public function testGenerateUriRemovesQueryString() + { + $method = new \ReflectionMethod('Symfony\Component\Security\Http\HttpUtils', 'generateUri'); + $method->setAccessible(true); + + $utils = new HttpUtils($this->getUrlGenerator()); + $this->assertEquals('/foo/bar', $method->invoke($utils, new Request(), 'route_name')); + + $utils = new HttpUtils($this->getUrlGenerator('/foo/bar?param=value')); + $this->assertEquals('/foo/bar', $method->invoke($utils, new Request(), 'route_name')); + } + + private function getUrlGenerator($generatedUrl = '/foo/bar') { $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); $urlGenerator ->expects($this->any()) ->method('generate') - ->will($this->returnValue('/foo/bar')) + ->will($this->returnValue($generatedUrl)) ; return $urlGenerator; |