| 3 |
liveuser |
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\Routing\Loader\ClosureLoader;
|
|
|
15 |
use Symfony\Component\Routing\Route;
|
|
|
16 |
use Symfony\Component\Routing\RouteCollection;
|
|
|
17 |
|
|
|
18 |
class ClosureLoaderTest extends \PHPUnit_Framework_TestCase
|
|
|
19 |
{
|
|
|
20 |
public function testSupports()
|
|
|
21 |
{
|
|
|
22 |
$loader = new ClosureLoader();
|
|
|
23 |
|
|
|
24 |
$closure = function () {};
|
|
|
25 |
|
|
|
26 |
$this->assertTrue($loader->supports($closure), '->supports() returns true if the resource is loadable');
|
|
|
27 |
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
|
|
28 |
|
|
|
29 |
$this->assertTrue($loader->supports($closure, 'closure'), '->supports() checks the resource type if specified');
|
|
|
30 |
$this->assertFalse($loader->supports($closure, 'foo'), '->supports() checks the resource type if specified');
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
public function testLoad()
|
|
|
34 |
{
|
|
|
35 |
$loader = new ClosureLoader();
|
|
|
36 |
|
|
|
37 |
$route = new Route('/');
|
|
|
38 |
$routes = $loader->load(function () use ($route) {
|
|
|
39 |
$routes = new RouteCollection();
|
|
|
40 |
|
|
|
41 |
$routes->add('foo', $route);
|
|
|
42 |
|
|
|
43 |
return $routes;
|
|
|
44 |
});
|
|
|
45 |
|
|
|
46 |
$this->assertEquals($route, $routes->get('foo'), '->load() loads a \Closure resource');
|
|
|
47 |
}
|
|
|
48 |
}
|