Skip to content

Commit e09b320

Browse files
committed
[Routing] Added PhpFileLoader tests.
1 parent 29922fa commit e09b320

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
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;

tests/Symfony/Tests/Component/Routing/Loader/PhpFileLoaderTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Tests\Component\Routing\Loader;
1313

1414
use Symfony\Component\Config\Loader\LoaderResolver;
15+
use Symfony\Component\Config\FileLocator;
1516
use Symfony\Component\Routing\Loader\PhpFileLoader;
1617
use Symfony\Component\Routing\Route;
1718
use Symfony\Component\Routing\RouteCollection;
@@ -31,4 +32,15 @@ public function testSupports()
3132
$this->assertTrue($loader->supports('foo.php', 'php'), '->supports() checks the resource type if specified');
3233
$this->assertFalse($loader->supports('foo.php', 'foo'), '->supports() checks the resource type if specified');
3334
}
35+
36+
public function testLoadWithRoute()
37+
{
38+
$loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
39+
$routeCollection = $loader->load('validpattern.php');
40+
$routes = $routeCollection->all();
41+
42+
$this->assertEquals(1, count($routes), 'One route is loaded');
43+
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
44+
}
3445
}
46+

0 commit comments

Comments
 (0)