2010-06-24 07:46:50 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2010-06-24 07:46:50 +01:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
namespace Symfony\Tests\Component\Routing;
|
2010-06-24 07:46:50 +01:00
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
use Symfony\Component\Routing\CompiledRoute;
|
|
|
|
use Symfony\Component\Routing\Route;
|
2010-06-24 07:46:50 +01:00
|
|
|
|
|
|
|
class CompiledRouteTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function testAccessors()
|
|
|
|
{
|
2011-01-12 06:10:57 +00:00
|
|
|
$route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar'));
|
2010-06-24 07:46:50 +01:00
|
|
|
|
|
|
|
$compiled = new CompiledRoute($route, 'prefix', 'regex', array('tokens'), array('variables'));
|
|
|
|
$this->assertEquals($route, $compiled->getRoute(), '__construct() takes a route as its first argument');
|
|
|
|
$this->assertEquals('prefix', $compiled->getStaticPrefix(), '__construct() takes a static prefix as its second argument');
|
|
|
|
$this->assertEquals('regex', $compiled->getRegex(), '__construct() takes a regexp as its third argument');
|
|
|
|
$this->assertEquals(array('tokens'), $compiled->getTokens(), '__construct() takes an array of tokens as its fourth argument');
|
2011-03-01 17:56:35 +00:00
|
|
|
$this->assertEquals(array('variables'), $compiled->getVariables(), '__construct() takes an array of variables as its fifth argument');
|
2010-06-24 07:46:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testgetPatterngetDefaultsgetOptionsgetRequirements()
|
|
|
|
{
|
2011-01-12 06:10:57 +00:00
|
|
|
$route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar'));
|
2010-06-24 07:46:50 +01:00
|
|
|
|
|
|
|
$compiled = new CompiledRoute($route, 'prefix', 'regex', array('tokens'), array('variables'));
|
2011-01-12 06:10:57 +00:00
|
|
|
$this->assertEquals('/{foo}', $compiled->getPattern(), '->getPattern() returns the route pattern');
|
2010-06-24 07:46:50 +01:00
|
|
|
$this->assertEquals(array('foo' => 'bar'), $compiled->getDefaults(), '->getDefaults() returns the route defaults');
|
|
|
|
$this->assertEquals(array('foo' => '\d+'), $compiled->getRequirements(), '->getRequirements() returns the route requirements');
|
|
|
|
$this->assertEquals(array_merge(array(
|
2010-08-20 22:09:55 +01:00
|
|
|
'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler',
|
2010-06-24 07:46:50 +01:00
|
|
|
), array('foo' => 'bar')), $compiled->getOptions(), '->getOptions() returns the route options');
|
|
|
|
}
|
|
|
|
}
|