This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Components/Routing/Matcher/UrlMatcherTest.php

41 lines
1.4 KiB
PHP
Raw Normal View History

2010-06-24 07:46:50 +01:00
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Tests\Components\Routing\Matcher;
use Symfony\Components\Routing\Matcher\UrlMatcher;
use Symfony\Components\Routing\RouteCollection;
use Symfony\Components\Routing\Route;
class UrlMatcherTest extends \PHPUnit_Framework_TestCase
{
public function testNormalizeUrl()
{
$collection = new RouteCollection();
$collection->addRoute('foo', new Route('/:foo'));
$matcher = new UrlMatcherForTests($collection, array(), array());
$this->assertEquals('/', $matcher->normalizeUrl(''), '->normalizeUrl() adds a / at the beginning of the URL if needed');
$this->assertEquals('/foo', $matcher->normalizeUrl('foo'), '->normalizeUrl() adds a / at the beginning of the URL if needed');
$this->assertEquals('/foo', $matcher->normalizeUrl('/foo?foo=bar'), '->normalizeUrl() removes the query string');
$this->assertEquals('/foo/bar', $matcher->normalizeUrl('/foo//bar'), '->normalizeUrl() removes duplicated /');
}
}
class UrlMatcherForTests extends UrlMatcher
{
public function normalizeUrl($url)
{
return parent::normalizeUrl($url);
}
}