8000 [Routing] added some more unit tests · symfony/symfony@a270458 · GitHub
[go: up one dir, main page]

Skip to content

Commit a270458

Browse files
fabpotarnaud-lb
authored andcommitted
[Routing] added some more unit tests
1 parent 153fcf2 commit a270458

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Symfony/Component/Routing/Tests/RouteCollectionTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,18 @@ public function testPatternDoesNotChangeWhenDefinitionOrderChanges()
297297

298298
$this->assertEquals($rootCollection_A, $rootCollection_B);
299299
}
300+
301+
public function testSetHostnamePattern()
302+
{
303+
$collection = new RouteCollection();
304+
$routea = new Route('/a');
305+
$routeb = new Route('/b', array(), array(), array(), '{locale}.example.net');
306+
$collection->add('a', $routea);
307+
$collection->add('b', $routeb);
308+
309+
$collection->setHostnamePattern('{locale}.example.com');
310+
311+
$this->assertEquals('{locale}.example.com', $routea->getHostnamePattern());
312+
$this->assertEquals('{locale}.example.net', $routeb->getHostnamePattern());
313+
}
300314
}

src/Symfony/Component/Routing/Tests/RouteTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ class RouteTest extends \PHPUnit_Framework_TestCase
1717
{
1818
public function testConstructor()
1919
{
20-
$route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar'));
20+
$route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar'), '{locale}.example.com');
2121
$this->assertEquals('/{foo}', $route->getPattern(), '__construct() takes a pattern as its first argument');
2222
$this->assertEquals(array('foo' => 'bar'), $route->getDefaults(), '__construct() takes defaults as its second argument');
2323
$this->assertEquals(array('foo' => '\d+'), $route->getRequirements(), '__construct() takes requirements as its third argument');
2424
$this->assertEquals('bar', $route->getOption('foo'), '__construct() takes options as its fourth argument');
25+
$this->assertEquals('{locale}.example.com', $route->getHostnamePattern(), '__construct() takes a hostname pattern as its fifth argument');
2526
}
2627

2728
public function testPattern()
@@ -121,6 +122,13 @@ public function getInvalidRequirements()
121122
);
122123
}
123124

125+
public function testHostnamePattern()
126+
{
127+
$route = new Route('/');
128+
$route->setHostnamePattern('{locale}.example.net');
129+
$this->assertEquals('{locale}.example.net', $route->getHostnamePattern(), '->setHostnamePattern() sets the hostname pattern');
130+
}
131+
124132
public function testCompile()
125133
{
126134
$route = new Route('/{foo}');

0 commit comments

Comments
 (0)
0