Skip to content

Commit a44f8d8

Browse files
Fabien PotencierFabien Potencier
authored andcommitted
Merge remote branch 'jakzal/routing-tests'
2 parents 3f7564b + e09b320 commit a44f8d8

14 files changed

+252
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Tests\Component\Routing\Annotation;
13+
14+
use Symfony\Component\Routing\Annotation\Route;
15+
16+
class RouteTest extends \PHPUnit_Framework_TestCase
17+
{
18+
/**
19+
* @expectedException \BadMethodCallException
20+
*/
21+
public function testInvalidRouteParameter()
22+
{
23+
$route = new Route(array('foo' => 'bar'));
24+
}
25+
26+
/**
27+
* @dataProvider getValidParameters
28+
*/
29+
public function testRouteParameters($parameter, $value, $getter)
30+
{
31+
$route = new Route(array($parameter => $value));
32+
$this->assertEquals($route->$getter(), $value);
33+
}
34+
35+
public function getValidParameters()
36+
{
37+
return array(
38+
array('value', '/Blog', 'getPattern'),
39+
array('requirements', array('_method' => 'GET'), 'getRequirements'),
40+
array('options', array('segment_separators' => array('/')), 'getOptions'),
41+
array('name', 'blog_index', 'getName'),
42+
array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults')
43+
);
44+
}
45+
}
46+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
blog_show:
2+
defaults: { _controller: MyBlogBundle:Blog:show }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<routes xmlns="http://symfony.com/schema/routing"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<route id="blog_show" pattern="/blog/{slug}">
8+
<default key="_controller">MyBundle:Blog:show</default>
9+
<requirement key="_method">GET</requirement>
10+
<option key="segment_separators">/</option>
11+
<!-- </route> -->
12+
</routes>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<routes xmlns="http://symfony.com/schema/routing"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<foo>bar</foo>
8+
</routes>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<routes xmlns="http://symfony.com/schema/routing"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<route id="blog_show" pattern="/blog/{slug}">
8+
<default key="_controller">MyBundle:Blog:show</default>
9+
<requirement key="_method">GET</requirement>
10+
<option key="segment_separators">/</option>
11+
<foo key="bar">baz</foo>
12+
</route>
13+
</routes>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
use Symfony\Component\Routing\RouteCollection;
3+
use Symfony\Component\Routing\Route;
4+
5+
$collection = new RouteCollection();
6+
$collection->add('blog_show', new Route('/blog/{slug}', array(
7+
'_controller' => 'MyBlogBundle:Blog:show',
8+
)));
9+
10+
return $collection;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<routes xmlns="http://symfony.com/schema/routing"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<route id="blog_show" pattern="/blog/{slug}">
8+
<default key="_controller">MyBundle:Blog:show</default>
9+
<requirement key="_method">GET</requirement>
10+
<option key="segment_separators">/</option>
11+
</route>
12+
</routes>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
blog_show:
2+
pattern: /blog/{slug}
3+
defaults: { _controller: MyBlogBundle:Blog:show }
4+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<routes xmlns="http://symfony.com/schema/routing"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<import resource="validpattern.xml" />
8+
</routes>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
blog_show:
2+
resource: validpattern.yml

0 commit comments

Comments
 (0)