public function RouteTest::testRequirements in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/routing/Tests/RouteTest.php \Symfony\Component\Routing\Tests\RouteTest::testRequirements()
File
- vendor/
symfony/ routing/ Tests/ RouteTest.php, line 98
Class
Namespace
Symfony\Component\Routing\TestsCode
public function testRequirements() {
$route = new Route('/{foo}');
$route
->setRequirements(array(
'foo' => '\\d+',
));
$this
->assertEquals(array(
'foo' => '\\d+',
), $route
->getRequirements(), '->setRequirements() sets the requirements');
$this
->assertEquals('\\d+', $route
->getRequirement('foo'), '->getRequirement() returns a requirement');
$this
->assertNull($route
->getRequirement('bar'), '->getRequirement() returns null if a requirement is not defined');
$route
->setRequirements(array(
'foo' => '^\\d+$',
));
$this
->assertEquals('\\d+', $route
->getRequirement('foo'), '->getRequirement() removes ^ and $ from the path');
$this
->assertEquals($route, $route
->setRequirements(array()), '->setRequirements() implements a fluent interface');
$route
->setRequirements(array(
'foo' => '\\d+',
));
$route
->addRequirements(array(
'bar' => '\\d+',
));
$this
->assertEquals($route, $route
->addRequirements(array()), '->addRequirements() implements a fluent interface');
$this
->assertEquals(array(
'foo' => '\\d+',
'bar' => '\\d+',
), $route
->getRequirements(), '->addRequirement() keep previous requirements');
}