]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
twig implementation
[github/wallabag/wallabag.git] / vendor / symfony / routing / Symfony / Component / Routing / Tests / Loader / PhpFileLoaderTest.php
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\Component\Routing\Tests\Loader;
13
14 use Symfony\Component\Config\FileLocator;
15 use Symfony\Component\Routing\Loader\PhpFileLoader;
16
17 class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
18 {
19 protected function setUp()
20 {
21 if (!class_exists('Symfony\Component\Config\FileLocator')) {
22 $this->markTestSkipped('The "Config" component is not available');
23 }
24 }
25
26 public function testSupports()
27 {
28 $loader = new PhpFileLoader($this->getMock('Symfony\Component\Config\FileLocator'));
29
30 $this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable');
31 $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
32
33 $this->assertTrue($loader->supports('foo.php', 'php'), '->supports() checks the resource type if specified');
34 $this->assertFalse($loader->supports('foo.php', 'foo'), '->supports() checks the resource type if specified');
35 }
36
37 public function testLoadWithRoute()
38 {
39 $loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
40 $routeCollection = $loader->load('validpattern.php');
41 $routes = $routeCollection->all();
42
43 $this->assertCount(2, $routes, 'Two routes are loaded');
44 $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
45
46 foreach ($routes as $route) {
47 $this->assertSame('/blog/{slug}', $route->getPath());
48 $this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
49 $this->assertSame('{locale}.example.com', $route->getHost());
50 $this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
51 $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
52 $this->assertEquals(array('https'), $route->getSchemes());
53 }
54 }
55 }