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 PHPUnit\Framework\TestCase;
15 use Symfony\Component\Routing\Loader\ClosureLoader;
16 use Symfony\Component\Routing\Route;
17 use Symfony\Component\Routing\RouteCollection;
19 class ClosureLoaderTest extends TestCase
21 public function testSupports()
23 $loader = new ClosureLoader();
25 $closure = function () {};
27 $this->assertTrue($loader->supports($closure), '->supports() returns true if the resource is loadable');
28 $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
30 $this->assertTrue($loader->supports($closure, 'closure'), '->supports() checks the resource type if specified');
31 $this->assertFalse($loader->supports($closure, 'foo'), '->supports() checks the resource type if specified');
34 public function testLoad()
36 $loader = new ClosureLoader();
38 $route = new Route('/');
39 $routes = $loader->load(function () use ($route) {
40 $routes = new RouteCollection();
42 $routes->add('foo', $route);
47 $this->assertEquals($route, $routes->get('foo'), '->load() loads a \Closure resource');