[Routing] added some more unit tests
This commit is contained in:
parent
153fcf2596
commit
a270458d40
@ -297,4 +297,18 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals($rootCollection_A, $rootCollection_B);
|
||||
}
|
||||
|
||||
public function testSetHostnamePattern()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
$routea = new Route('/a');
|
||||
$routeb = new Route('/b', array(), array(), array(), '{locale}.example.net');
|
||||
$collection->add('a', $routea);
|
||||
$collection->add('b', $routeb);
|
||||
|
||||
$collection->setHostnamePattern('{locale}.example.com');
|
||||
|
||||
$this->assertEquals('{locale}.example.com', $routea->getHostnamePattern());
|
||||
$this->assertEquals('{locale}.example.net', $routeb->getHostnamePattern());
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,12 @@ class RouteTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstructor()
|
||||
{
|
||||
$route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar'));
|
||||
$route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar'), '{locale}.example.com');
|
||||
$this->assertEquals('/{foo}', $route->getPattern(), '__construct() takes a pattern as its first argument');
|
||||
$this->assertEquals(array('foo' => 'bar'), $route->getDefaults(), '__construct() takes defaults as its second argument');
|
||||
$this->assertEquals(array('foo' => '\d+'), $route->getRequirements(), '__construct() takes requirements as its third argument');
|
||||
$this->assertEquals('bar', $route->getOption('foo'), '__construct() takes options as its fourth argument');
|
||||
$this->assertEquals('{locale}.example.com', $route->getHostnamePattern(), '__construct() takes a hostname pattern as its fifth argument');
|
||||
}
|
||||
|
||||
public function testPattern()
|
||||
@ -121,6 +122,13 @@ class RouteTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testHostnamePattern()
|
||||
{
|
||||
$route = new Route('/');
|
||||
$route->setHostnamePattern('{locale}.example.net');
|
||||
$this->assertEquals('{locale}.example.net', $route->getHostnamePattern(), '->setHostnamePattern() sets the hostname pattern');
|
||||
}
|
||||
|
||||
public function testCompile()
|
||||
{
|
||||
$route = new Route('/{foo}');
|
||||
|
Reference in New Issue
Block a user