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

Skip to content

Commit b219ab6

Browse files
committed
[Routing] added some more unit tests
1 parent 09eb0d0 commit b219ab6

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
@@ -276,4 +276,18 @@ public function testPatternDoesNotChangeWhenDefinitionOrderChanges()
276276

277277
$this->assertEquals($rootCollection_A, $rootCollection_B);
278278
}
279+
280+
public function testSetHostnamePattern()
281+
{
282+
$collection = new RouteCollection();
283+
$routea = new Route('/a');
284+
$routeb = new Route('/b', array(), array(), array(), '{locale}.example.net');
285+
$collection->add('a', $routea);
286+
$collection->add('b', $routeb);
287+
288+
$collection->setHostnamePattern('{locale}.example.com');
289+
290+
$this->assertEquals('{locale}.example.com', $routea->getHostnamePattern());
291+
$this->assertEquals('{locale}.example.net', $routeb->getHostnamePattern());
292+
}
279293
}

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()
@@ -116,6 +117,13 @@ public function getInvalidRequirements()
116117
);
117118
}
118119

120+
public function testHostnamePattern()
121+
{
122+
$route = new Route('/');
123+
$route->setHostnamePattern('{locale}.example.net');
124+
$this->assertEquals('{locale}.example.net', $route->getHostnamePattern(), '->setHostnamePattern() sets the hostname pattern');
125+
}
126+
119127
public function testCompile()
120128
{
121129
$route = new Route('/{foo}');

0 commit comments

Comments
 (0)
0