<?php/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/namespaceSymfony\Component\Routing\Tests\Loader;
useSymfony\Component\Routing\Loader\ClosureLoader;
useSymfony\Component\Routing\Route;
useSymfony\Component\Routing\RouteCollection;
class ClosureLoaderTestextends \PHPUnit_Framework_TestCase {
protected functionsetUp() {
if (!class_exists('Symfony\\Component\\Config\\FileLocator')) {
$this
->markTestSkipped('The "Config" component is not available');
}
}
public functiontestSupports() {
$loader = newClosureLoader();
$closure = function () {
};
$this
->assertTrue($loader
->supports($closure), '->supports() returns true if the resource is loadable');
$this
->assertFalse($loader
->supports('foo.foo'), '->supports() returns true if the resource is loadable');
$this
->assertTrue($loader
->supports($closure, 'closure'), '->supports() checks the resource type if specified');
$this
->assertFalse($loader
->supports($closure, 'foo'), '->supports() checks the resource type if specified');
}
public functiontestLoad() {
$loader = newClosureLoader();
$route = newRoute('/');
$routes = $loader
->load(function () use ($route) {
$routes = newRouteCollection();
$routes
->add('foo', $route);
return$routes;
});
$this
->assertEquals($route, $routes
->get('foo'), '->load() loads a \\Closure resource');
}
}