$this->
assertEquals($route,
$route->
setRequirements([]), '->setRequirements() implements a fluent interface'
);
$route->
setRequirements(['foo' => '\d+'
]);
$route->
addRequirements(['bar' => '\d+'
]);
$this->
assertEquals($route,
$route->
addRequirements([]), '->addRequirements() implements a fluent interface'
);
$this->
assertEquals(['foo' => '\d+', 'bar' => '\d+'
],
$route->
getRequirements(), '->addRequirement() keep previous requirements'
);
} public function testRequirement() { $route =
new Route('/{foo}'
);
$this->
assertFalse($route->
hasRequirement('foo'
), '->hasRequirement() return false if requirement is not set'
);
$route->
setRequirement('foo', '^\d+$'
);
$this->
assertEquals('\d+',
$route->
getRequirement('foo'
), '->setRequirement() removes ^ and $ from the path'
);
$this->
assertTrue($route->
hasRequirement('foo'
), '->hasRequirement() return true if requirement is set'
);
} public function testRequirementAlternativeStartAndEndRegexSyntax() { $route =
new Route('/{foo}'
);
$route->
setRequirement('foo', '\A\d+\z'
);
$this->
assertEquals('\d+',
$route->
getRequirement('foo'
), '->setRequirement() removes \A and \z from the path'
);
$this->
assertTrue($route->
hasRequirement('foo'
));
}