Laravel version update
Laravel version update
This commit is contained in:
@@ -11,15 +11,16 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Routing\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Loader\YamlFileLoader;
|
||||
|
||||
class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
class YamlFileLoaderTest extends TestCase
|
||||
{
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new YamlFileLoader($this->getMock('Symfony\Component\Config\FileLocator'));
|
||||
$loader = new YamlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock());
|
||||
|
||||
$this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable');
|
||||
$this->assertTrue($loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable');
|
||||
@@ -107,4 +108,99 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame('context.getMethod() == "POST"', $route->getCondition());
|
||||
}
|
||||
}
|
||||
|
||||
public function testLoadRouteWithControllerAttribute()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
|
||||
$this->assertSame('AppBundle:Homepage:show', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function testLoadRouteWithoutControllerAttribute()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$route = $routeCollection->get('app_logout');
|
||||
|
||||
$this->assertNull($route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function testLoadRouteWithControllerSetInDefaults()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$route = $routeCollection->get('app_blog');
|
||||
|
||||
$this->assertSame('AppBundle:Blog:list', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "app_blog"/
|
||||
*/
|
||||
public function testOverrideControllerInDefaults()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader->load('override_defaults.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFilesImportingRoutesWithControllers
|
||||
*/
|
||||
public function testImportRouteWithController($file)
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load($file);
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
$this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('app_blog');
|
||||
$this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('app_logout');
|
||||
$this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function provideFilesImportingRoutesWithControllers()
|
||||
{
|
||||
yield array('import_controller.yml');
|
||||
yield array('import__controller.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "_static"/
|
||||
*/
|
||||
public function testImportWithOverriddenController()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader->load('import_override_defaults.yml');
|
||||
}
|
||||
|
||||
public function testImportRouteWithGlobMatchingSingleFile()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$routeCollection = $loader->load('import_single.yml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
$this->assertSame('AppBundle:Bar:view', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function testImportRouteWithGlobMatchingMultipleFiles()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$routeCollection = $loader->load('import_multiple.yml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
$this->assertSame('AppBundle:Bar:view', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('baz_route');
|
||||
$this->assertSame('AppBundle:Baz:view', $route->getDefault('_controller'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user