4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Routing\Tests\Loader
;
14 use Symfony\Component\Routing\Loader\ClosureLoader
;
15 use Symfony\Component\Routing\Route
;
16 use Symfony\Component\Routing\RouteCollection
;
18 class ClosureLoaderTest
extends \PHPUnit_Framework_TestCase
20 protected function setUp()
22 if (!class_exists('Symfony\Component\Config\FileLocator')) {
23 $this->markTestSkipped('The "Config" component is not available');
27 public function testSupports()
29 $loader = new ClosureLoader();
31 $closure = function () {};
33 $this->assertTrue($loader->supports($closure), '->supports() returns true if the resource is loadable');
34 $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
36 $this->assertTrue($loader->supports($closure, 'closure'), '->supports() checks the resource type if specified');
37 $this->assertFalse($loader->supports($closure, 'foo'), '->supports() checks the resource type if specified');
40 public function testLoad()
42 $loader = new ClosureLoader();
44 $route = new Route('/');
45 $routes = $loader->load(function () use ($route) {
46 $routes = new RouteCollection();
48 $routes->add('foo', $route);
53 $this->assertEquals($route, $routes->get('foo'), '->load() loads a \Closure resource');