updated packages
This commit is contained in:
@@ -26,7 +26,7 @@ abstract class AbstractAnnotationLoaderTest extends TestCase
|
||||
public function getClassLoader($reader)
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Routing\Loader\AnnotationClassLoader')
|
||||
->setConstructorArgs(array($reader))
|
||||
->setConstructorArgs([$reader])
|
||||
->getMockForAbstractClass()
|
||||
;
|
||||
}
|
||||
|
||||
@@ -64,15 +64,15 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||
|
||||
public function provideTestSupportsChecksResource()
|
||||
{
|
||||
return array(
|
||||
array('class', true),
|
||||
array('\fully\qualified\class\name', true),
|
||||
array('namespaced\class\without\leading\slash', true),
|
||||
array('ÿClassWithLegalSpecialCharacters', true),
|
||||
array('5', false),
|
||||
array('foo.foo', false),
|
||||
array(null, false),
|
||||
);
|
||||
return [
|
||||
['class', true],
|
||||
['\fully\qualified\class\name', true],
|
||||
['namespaced\class\without\leading\slash', true],
|
||||
['ÿClassWithLegalSpecialCharacters', true],
|
||||
['5', false],
|
||||
['foo.foo', false],
|
||||
[null, false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testSupportsChecksTypeIfSpecified()
|
||||
@@ -105,8 +105,8 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$routes = $this->loader->load(InvokableController::class);
|
||||
$this->assertCount(1, $routes);
|
||||
$this->assertEquals('/here', $routes->get('lol')->getPath());
|
||||
$this->assertEquals(array('GET', 'POST'), $routes->get('lol')->getMethods());
|
||||
$this->assertEquals(array('https'), $routes->get('lol')->getSchemes());
|
||||
$this->assertEquals(['GET', 'POST'], $routes->get('lol')->getMethods());
|
||||
$this->assertEquals(['https'], $routes->get('lol')->getSchemes());
|
||||
}
|
||||
|
||||
public function testInvokableLocalizedControllerLoading()
|
||||
@@ -136,9 +136,11 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||
public function testDefaultValuesForMethods()
|
||||
{
|
||||
$routes = $this->loader->load(DefaultValueController::class);
|
||||
$this->assertCount(1, $routes);
|
||||
$this->assertCount(3, $routes);
|
||||
$this->assertEquals('/{default}/path', $routes->get('action')->getPath());
|
||||
$this->assertEquals('value', $routes->get('action')->getDefault('default'));
|
||||
$this->assertEquals('Symfony', $routes->get('hello_with_default')->getDefault('name'));
|
||||
$this->assertEquals('World', $routes->get('hello_without_default')->getDefault('name'));
|
||||
}
|
||||
|
||||
public function testMethodActionControllers()
|
||||
@@ -185,30 +187,30 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||
|
||||
public function testInvokableClassMultipleRouteLoad()
|
||||
{
|
||||
$classRouteData1 = array(
|
||||
$classRouteData1 = [
|
||||
'name' => 'route1',
|
||||
'path' => '/1',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
);
|
||||
'schemes' => ['https'],
|
||||
'methods' => ['GET'],
|
||||
];
|
||||
|
||||
$classRouteData2 = array(
|
||||
$classRouteData2 = [
|
||||
'name' => 'route2',
|
||||
'path' => '/2',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
);
|
||||
'schemes' => ['https'],
|
||||
'methods' => ['GET'],
|
||||
];
|
||||
|
||||
$reader = $this->getReader();
|
||||
$reader
|
||||
->expects($this->exactly(1))
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array(new RouteAnnotation($classRouteData1), new RouteAnnotation($classRouteData2))))
|
||||
->will($this->returnValue([new RouteAnnotation($classRouteData1), new RouteAnnotation($classRouteData2)]))
|
||||
;
|
||||
$reader
|
||||
->expects($this->once())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
$loader = new class($reader) extends AnnotationClassLoader {
|
||||
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
|
||||
|
||||
@@ -34,13 +34,13 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
|
||||
@@ -48,22 +48,22 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
|
||||
public function testLoadIgnoresHiddenDirectories()
|
||||
{
|
||||
$this->expectAnnotationsToBeReadFrom(array(
|
||||
$this->expectAnnotationsToBeReadFrom([
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass',
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass',
|
||||
));
|
||||
]);
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
|
||||
@@ -92,7 +92,7 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
|
||||
|
||||
@@ -53,10 +53,10 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
|
||||
|
||||
public function testLoadVariadic()
|
||||
{
|
||||
$route = new Route(array('path' => '/path/to/{id}'));
|
||||
$route = new Route(['path' => '/path/to/{id}']);
|
||||
$this->reader->expects($this->once())->method('getClassAnnotation');
|
||||
$this->reader->expects($this->once())->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array($route)));
|
||||
->will($this->returnValue([$route]));
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
|
||||
}
|
||||
@@ -72,6 +72,14 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php');
|
||||
}
|
||||
|
||||
public function testLoadAbstractClass()
|
||||
{
|
||||
$this->reader->expects($this->never())->method('getClassAnnotation');
|
||||
$this->reader->expects($this->never())->method('getMethodAnnotations');
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/AbstractClass.php');
|
||||
}
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$fixture = __DIR__.'/../Fixtures/annotated.php';
|
||||
|
||||
@@ -30,11 +30,11 @@ class DirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
$locator = new FileLocator();
|
||||
$this->reader = $this->getReader();
|
||||
$this->loader = new DirectoryLoader($locator);
|
||||
$resolver = new LoaderResolver(array(
|
||||
$resolver = new LoaderResolver([
|
||||
new YamlFileLoader($locator),
|
||||
new AnnotationFileLoader($locator, $this->getClassLoader($this->reader)),
|
||||
$this->loader,
|
||||
));
|
||||
]);
|
||||
$this->loader->setResolver($resolver);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ class ObjectRouteLoaderTest extends TestCase
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/foo'));
|
||||
|
||||
$loader->loaderMap = array(
|
||||
$loader->loaderMap = [
|
||||
'my_route_provider_service' => new RouteService($collection),
|
||||
);
|
||||
];
|
||||
|
||||
$actualRoutes = $loader->load(
|
||||
'my_route_provider_service:loadRoutes',
|
||||
@@ -52,9 +52,9 @@ class ObjectRouteLoaderTest extends TestCase
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/foo'));
|
||||
|
||||
$loader->loaderMap = array(
|
||||
$loader->loaderMap = [
|
||||
'my_route_provider_service' => new RouteService($collection),
|
||||
);
|
||||
];
|
||||
|
||||
$actualRoutes = $loader->load(
|
||||
'my_route_provider_service::loadRoutes',
|
||||
@@ -78,10 +78,10 @@ class ObjectRouteLoaderTest extends TestCase
|
||||
|
||||
public function getBadResourceStrings()
|
||||
{
|
||||
return array(
|
||||
array('Foo'),
|
||||
array('Foo:Bar:baz'),
|
||||
);
|
||||
return [
|
||||
['Foo'],
|
||||
['Foo:Bar:baz'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ class ObjectRouteLoaderTest extends TestCase
|
||||
public function testExceptionOnNoObjectReturned()
|
||||
{
|
||||
$loader = new ObjectRouteLoaderForTest();
|
||||
$loader->loaderMap = array('my_service' => 'NOT_AN_OBJECT');
|
||||
$loader->loaderMap = ['my_service' => 'NOT_AN_OBJECT'];
|
||||
$loader->load('my_service::method');
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class ObjectRouteLoaderTest extends TestCase
|
||||
public function testExceptionOnBadMethod()
|
||||
{
|
||||
$loader = new ObjectRouteLoaderForTest();
|
||||
$loader->loaderMap = array('my_service' => new \stdClass());
|
||||
$loader->loaderMap = ['my_service' => new \stdClass()];
|
||||
$loader->load('my_service::method');
|
||||
}
|
||||
|
||||
@@ -110,21 +110,21 @@ class ObjectRouteLoaderTest extends TestCase
|
||||
public function testExceptionOnMethodNotReturningCollection()
|
||||
{
|
||||
$service = $this->getMockBuilder('stdClass')
|
||||
->setMethods(array('loadRoutes'))
|
||||
->setMethods(['loadRoutes'])
|
||||
->getMock();
|
||||
$service->expects($this->once())
|
||||
->method('loadRoutes')
|
||||
->will($this->returnValue('NOT_A_COLLECTION'));
|
||||
|
||||
$loader = new ObjectRouteLoaderForTest();
|
||||
$loader->loaderMap = array('my_service' => $service);
|
||||
$loader->loaderMap = ['my_service' => $service];
|
||||
$loader->load('my_service::loadRoutes');
|
||||
}
|
||||
}
|
||||
|
||||
class ObjectRouteLoaderForTest extends ObjectRouteLoader
|
||||
{
|
||||
public $loaderMap = array();
|
||||
public $loaderMap = [];
|
||||
|
||||
protected function getServiceObject($id)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ class PhpFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadWithRoute()
|
||||
{
|
||||
$loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('validpattern.php');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
@@ -45,14 +45,14 @@ class PhpFileLoaderTest extends TestCase
|
||||
$this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertSame('{locale}.example.com', $route->getHost());
|
||||
$this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
|
||||
$this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
|
||||
$this->assertEquals(array('https'), $route->getSchemes());
|
||||
$this->assertEquals(['GET', 'POST', 'PUT', 'OPTIONS'], $route->getMethods());
|
||||
$this->assertEquals(['https'], $route->getSchemes());
|
||||
}
|
||||
}
|
||||
|
||||
public function testLoadWithImport()
|
||||
{
|
||||
$loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('validresource.php');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
@@ -64,14 +64,14 @@ class PhpFileLoaderTest extends TestCase
|
||||
$this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertSame('{locale}.example.com', $route->getHost());
|
||||
$this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
|
||||
$this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
|
||||
$this->assertEquals(array('https'), $route->getSchemes());
|
||||
$this->assertEquals(['GET', 'POST', 'PUT', 'OPTIONS'], $route->getMethods());
|
||||
$this->assertEquals(['https'], $route->getSchemes());
|
||||
}
|
||||
}
|
||||
|
||||
public function testThatDefiningVariableInConfigFileHasNoSideEffects()
|
||||
{
|
||||
$locator = new FileLocator(array(__DIR__.'/../Fixtures'));
|
||||
$locator = new FileLocator([__DIR__.'/../Fixtures']);
|
||||
$loader = new PhpFileLoader($locator);
|
||||
$routeCollection = $loader->load('with_define_path_variable.php');
|
||||
$resources = $routeCollection->getResources();
|
||||
@@ -86,7 +86,7 @@ class PhpFileLoaderTest extends TestCase
|
||||
|
||||
public function testRoutingConfigurator()
|
||||
{
|
||||
$locator = new FileLocator(array(__DIR__.'/../Fixtures'));
|
||||
$locator = new FileLocator([__DIR__.'/../Fixtures']);
|
||||
$loader = new PhpFileLoader($locator);
|
||||
$routeCollectionClosure = $loader->load('php_dsl.php');
|
||||
$routeCollectionObject = $loader->load('php_object_dsl.php');
|
||||
@@ -94,21 +94,21 @@ class PhpFileLoaderTest extends TestCase
|
||||
$expectedCollection = new RouteCollection();
|
||||
|
||||
$expectedCollection->add('foo', (new Route('/foo'))
|
||||
->setOptions(array('utf8' => true))
|
||||
->setOptions(['utf8' => true])
|
||||
->setCondition('abc')
|
||||
);
|
||||
$expectedCollection->add('buz', (new Route('/zub'))
|
||||
->setDefaults(array('_controller' => 'foo:act'))
|
||||
->setDefaults(['_controller' => 'foo:act'])
|
||||
);
|
||||
$expectedCollection->add('c_root', (new Route('/sub/pub/'))
|
||||
->setRequirements(array('id' => '\d+'))
|
||||
->setRequirements(['id' => '\d+'])
|
||||
);
|
||||
$expectedCollection->add('c_bar', (new Route('/sub/pub/bar'))
|
||||
->setRequirements(array('id' => '\d+'))
|
||||
->setRequirements(['id' => '\d+'])
|
||||
);
|
||||
$expectedCollection->add('c_pub_buz', (new Route('/sub/pub/buz'))
|
||||
->setHost('host')
|
||||
->setRequirements(array('id' => '\d+'))
|
||||
->setRequirements(['id' => '\d+'])
|
||||
);
|
||||
$expectedCollection->add('z_c_root', new Route('/zub/pub/'));
|
||||
$expectedCollection->add('z_c_bar', new Route('/zub/pub/bar'));
|
||||
@@ -116,9 +116,9 @@ class PhpFileLoaderTest extends TestCase
|
||||
$expectedCollection->add('r_root', new Route('/bus'));
|
||||
$expectedCollection->add('r_bar', new Route('/bus/bar/'));
|
||||
$expectedCollection->add('ouf', (new Route('/ouf'))
|
||||
->setSchemes(array('https'))
|
||||
->setMethods(array('GET'))
|
||||
->setDefaults(array('id' => 0))
|
||||
->setSchemes(['https'])
|
||||
->setMethods(['GET'])
|
||||
->setDefaults(['id' => 0])
|
||||
);
|
||||
|
||||
$expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_sub.php')));
|
||||
@@ -136,7 +136,7 @@ class PhpFileLoaderTest extends TestCase
|
||||
|
||||
public function testRoutingConfiguratorCanImportGlobPatterns()
|
||||
{
|
||||
$locator = new FileLocator(array(__DIR__.'/../Fixtures/glob'));
|
||||
$locator = new FileLocator([__DIR__.'/../Fixtures/glob']);
|
||||
$loader = new PhpFileLoader($locator);
|
||||
$routeCollection = $loader->load('php_dsl.php');
|
||||
|
||||
@@ -149,17 +149,17 @@ class PhpFileLoaderTest extends TestCase
|
||||
|
||||
public function testRoutingI18nConfigurator()
|
||||
{
|
||||
$locator = new FileLocator(array(__DIR__.'/../Fixtures'));
|
||||
$locator = new FileLocator([__DIR__.'/../Fixtures']);
|
||||
$loader = new PhpFileLoader($locator);
|
||||
$routeCollection = $loader->load('php_dsl_i18n.php');
|
||||
|
||||
$expectedCollection = new RouteCollection();
|
||||
|
||||
$expectedCollection->add('foo.en', (new Route('/glish/foo'))->setDefaults(array('_locale' => 'en', '_canonical_route' => 'foo')));
|
||||
$expectedCollection->add('bar.en', (new Route('/glish/bar'))->setDefaults(array('_locale' => 'en', '_canonical_route' => 'bar')));
|
||||
$expectedCollection->add('baz.en', (new Route('/baz'))->setDefaults(array('_locale' => 'en', '_canonical_route' => 'baz')));
|
||||
$expectedCollection->add('c_foo.fr', (new Route('/ench/pub/foo'))->setDefaults(array('_locale' => 'fr', '_canonical_route' => 'c_foo')));
|
||||
$expectedCollection->add('c_bar.fr', (new Route('/ench/pub/bar'))->setDefaults(array('_locale' => 'fr', '_canonical_route' => 'c_bar')));
|
||||
$expectedCollection->add('foo.en', (new Route('/glish/foo'))->setDefaults(['_locale' => 'en', '_canonical_route' => 'foo']));
|
||||
$expectedCollection->add('bar.en', (new Route('/glish/bar'))->setDefaults(['_locale' => 'en', '_canonical_route' => 'bar']));
|
||||
$expectedCollection->add('baz.en', (new Route('/baz'))->setDefaults(['_locale' => 'en', '_canonical_route' => 'baz']));
|
||||
$expectedCollection->add('c_foo.fr', (new Route('/ench/pub/foo'))->setDefaults(['_locale' => 'fr', '_canonical_route' => 'c_foo']));
|
||||
$expectedCollection->add('c_bar.fr', (new Route('/ench/pub/bar'))->setDefaults(['_locale' => 'fr', '_canonical_route' => 'c_bar']));
|
||||
|
||||
$expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_sub_i18n.php')));
|
||||
$expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_i18n.php')));
|
||||
|
||||
@@ -31,7 +31,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadWithRoute()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('validpattern.xml');
|
||||
$route = $routeCollection->get('blog_show');
|
||||
|
||||
@@ -41,14 +41,14 @@ class XmlFileLoaderTest extends TestCase
|
||||
$this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertSame('\w+', $route->getRequirement('locale'));
|
||||
$this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
|
||||
$this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
|
||||
$this->assertEquals(array('https'), $route->getSchemes());
|
||||
$this->assertEquals(['GET', 'POST', 'PUT', 'OPTIONS'], $route->getMethods());
|
||||
$this->assertEquals(['https'], $route->getSchemes());
|
||||
$this->assertEquals('context.getMethod() == "GET"', $route->getCondition());
|
||||
}
|
||||
|
||||
public function testLoadWithNamespacePrefix()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('namespaceprefix.xml');
|
||||
|
||||
$this->assertCount(1, $routeCollection->all(), 'One route is loaded');
|
||||
@@ -66,7 +66,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadWithImport()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('validresource.xml');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
@@ -83,9 +83,29 @@ class XmlFileLoaderTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testUtf8Route()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$routeCollection = $loader->load('utf8.xml');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
$this->assertCount(2, $routes, 'Two routes are loaded');
|
||||
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
|
||||
|
||||
$utf8Route = $routeCollection->get('app_utf8');
|
||||
|
||||
$this->assertSame('/utf8', $utf8Route->getPath());
|
||||
$this->assertTrue($utf8Route->getOption('utf8'), 'Must be utf8');
|
||||
|
||||
$noUtf8Route = $routeCollection->get('app_no_utf8');
|
||||
|
||||
$this->assertSame('/no-utf8', $noUtf8Route->getPath());
|
||||
$this->assertFalse($noUtf8Route->getOption('utf8'), 'Must not be utf8');
|
||||
}
|
||||
|
||||
public function testLoadLocalized()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('localized.xml');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
@@ -98,7 +118,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLocalizedImports()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$routeCollection = $loader->load('importer-with-locale.xml');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
@@ -111,7 +131,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLocalizedImportsOfNotLocalizedRoutes()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$routeCollection = $loader->load('importer-with-locale-imports-non-localized-route.xml');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
@@ -128,7 +148,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testLoadThrowsExceptionWithInvalidFile($filePath)
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$loader->load($filePath);
|
||||
}
|
||||
|
||||
@@ -138,13 +158,13 @@ class XmlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testLoadThrowsExceptionWithInvalidFileEvenWithoutSchemaValidation($filePath)
|
||||
{
|
||||
$loader = new CustomXmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new CustomXmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$loader->load($filePath);
|
||||
}
|
||||
|
||||
public function getPathsToInvalidFiles()
|
||||
{
|
||||
return array(array('nonvalidnode.xml'), array('nonvalidroute.xml'), array('nonvalid.xml'), array('missing_id.xml'), array('missing_path.xml'));
|
||||
return [['nonvalidnode.xml'], ['nonvalidroute.xml'], ['nonvalid.xml'], ['missing_id.xml'], ['missing_path.xml']];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,13 +173,13 @@ class XmlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testDocTypeIsNotAllowed()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$loader->load('withdoctype.xml');
|
||||
}
|
||||
|
||||
public function testNullValues()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('null_values.xml');
|
||||
$route = $routeCollection->get('blog_show');
|
||||
|
||||
@@ -173,12 +193,12 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testScalarDataTypeDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('scalar_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'slug' => null,
|
||||
'published' => true,
|
||||
@@ -189,147 +209,147 @@ class XmlFileLoaderTest extends TestCase
|
||||
'locked' => false,
|
||||
'foo' => null,
|
||||
'bar' => null,
|
||||
),
|
||||
],
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testListDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('list_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array(true, 1, 3.5, 'foo'),
|
||||
),
|
||||
'values' => [true, 1, 3.5, 'foo'],
|
||||
],
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testListInListDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('list_in_list_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array(array(true, 1, 3.5, 'foo')),
|
||||
),
|
||||
'values' => [[true, 1, 3.5, 'foo']],
|
||||
],
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testListInMapDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('list_in_map_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array('list' => array(true, 1, 3.5, 'foo')),
|
||||
),
|
||||
'values' => ['list' => [true, 1, 3.5, 'foo']],
|
||||
],
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMapDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('map_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array(
|
||||
'values' => [
|
||||
'public' => true,
|
||||
'page' => 1,
|
||||
'price' => 3.5,
|
||||
'title' => 'foo',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMapInListDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('map_in_list_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array(array(
|
||||
'values' => [[
|
||||
'public' => true,
|
||||
'page' => 1,
|
||||
'price' => 3.5,
|
||||
'title' => 'foo',
|
||||
)),
|
||||
),
|
||||
]],
|
||||
],
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMapInMapDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('map_in_map_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array('map' => array(
|
||||
'values' => ['map' => [
|
||||
'public' => true,
|
||||
'page' => 1,
|
||||
'price' => 3.5,
|
||||
'title' => 'foo',
|
||||
)),
|
||||
),
|
||||
]],
|
||||
],
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testNullValuesInList()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('list_null_values.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(array(null, null, null, null, null, null), $route->getDefault('list'));
|
||||
$this->assertSame([null, null, null, null, null, null], $route->getDefault('list'));
|
||||
}
|
||||
|
||||
public function testNullValuesInMap()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('map_null_values.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'boolean' => null,
|
||||
'integer' => null,
|
||||
'float' => null,
|
||||
'string' => null,
|
||||
'list' => null,
|
||||
'map' => null,
|
||||
),
|
||||
],
|
||||
$route->getDefault('map')
|
||||
);
|
||||
}
|
||||
|
||||
public function testLoadRouteWithControllerAttribute()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$routeCollection = $loader->load('routing.xml');
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
@@ -339,7 +359,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadRouteWithoutControllerAttribute()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$routeCollection = $loader->load('routing.xml');
|
||||
|
||||
$route = $routeCollection->get('app_logout');
|
||||
@@ -349,7 +369,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadRouteWithControllerSetInDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$routeCollection = $loader->load('routing.xml');
|
||||
|
||||
$route = $routeCollection->get('app_blog');
|
||||
@@ -363,7 +383,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testOverrideControllerInDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$loader->load('override_defaults.xml');
|
||||
}
|
||||
|
||||
@@ -372,7 +392,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testImportRouteWithController($file)
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$routeCollection = $loader->load($file);
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
@@ -387,8 +407,8 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function provideFilesImportingRoutesWithControllers()
|
||||
{
|
||||
yield array('import_controller.xml');
|
||||
yield array('import__controller.xml');
|
||||
yield ['import_controller.xml'];
|
||||
yield ['import__controller.xml'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,13 +417,13 @@ class XmlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testImportWithOverriddenController()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$loader->load('import_override_defaults.xml');
|
||||
}
|
||||
|
||||
public function testImportRouteWithGlobMatchingSingleFile()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/glob']));
|
||||
$routeCollection = $loader->load('import_single.xml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
@@ -412,7 +432,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportRouteWithGlobMatchingMultipleFiles()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/glob']));
|
||||
$routeCollection = $loader->load('import_multiple.xml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
@@ -424,7 +444,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportRouteWithNamePrefix()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/import_with_name_prefix')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/import_with_name_prefix']));
|
||||
$routeCollection = $loader->load('routing.xml');
|
||||
|
||||
$this->assertNotNull($routeCollection->get('app_blog'));
|
||||
@@ -435,7 +455,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportRouteWithNoTrailingSlash()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/import_with_no_trailing_slash')));
|
||||
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/import_with_no_trailing_slash']));
|
||||
$routeCollection = $loader->load('routing.xml');
|
||||
|
||||
$this->assertEquals('/slash/', $routeCollection->get('a_app_homepage')->getPath());
|
||||
|
||||
@@ -33,11 +33,11 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadDoesNothingIfEmpty()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$collection = $loader->load('empty.yml');
|
||||
|
||||
$this->assertEquals(array(), $collection->all());
|
||||
$this->assertEquals(array(new FileResource(realpath(__DIR__.'/../Fixtures/empty.yml'))), $collection->getResources());
|
||||
$this->assertEquals([], $collection->all());
|
||||
$this->assertEquals([new FileResource(realpath(__DIR__.'/../Fixtures/empty.yml'))], $collection->getResources());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,26 +46,26 @@ class YamlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testLoadThrowsExceptionWithInvalidFile($filePath)
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$loader->load($filePath);
|
||||
}
|
||||
|
||||
public function getPathsToInvalidFiles()
|
||||
{
|
||||
return array(
|
||||
array('nonvalid.yml'),
|
||||
array('nonvalid2.yml'),
|
||||
array('incomplete.yml'),
|
||||
array('nonvalidkeys.yml'),
|
||||
array('nonesense_resource_plus_path.yml'),
|
||||
array('nonesense_type_without_resource.yml'),
|
||||
array('bad_format.yml'),
|
||||
);
|
||||
return [
|
||||
['nonvalid.yml'],
|
||||
['nonvalid2.yml'],
|
||||
['incomplete.yml'],
|
||||
['nonvalidkeys.yml'],
|
||||
['nonesense_resource_plus_path.yml'],
|
||||
['nonesense_type_without_resource.yml'],
|
||||
['bad_format.yml'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testLoadSpecialRouteName()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('special_route_name.yml');
|
||||
$route = $routeCollection->get('#$péß^a|');
|
||||
|
||||
@@ -75,7 +75,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadWithRoute()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('validpattern.yml');
|
||||
$route = $routeCollection->get('blog_show');
|
||||
|
||||
@@ -85,14 +85,14 @@ class YamlFileLoaderTest extends TestCase
|
||||
$this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertSame('\w+', $route->getRequirement('locale'));
|
||||
$this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
|
||||
$this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
|
||||
$this->assertEquals(array('https'), $route->getSchemes());
|
||||
$this->assertEquals(['GET', 'POST', 'PUT', 'OPTIONS'], $route->getMethods());
|
||||
$this->assertEquals(['https'], $route->getSchemes());
|
||||
$this->assertEquals('context.getMethod() == "GET"', $route->getCondition());
|
||||
}
|
||||
|
||||
public function testLoadWithResource()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$routeCollection = $loader->load('validresource.yml');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
@@ -111,7 +111,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadRouteWithControllerAttribute()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
@@ -121,7 +121,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadRouteWithoutControllerAttribute()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$route = $routeCollection->get('app_logout');
|
||||
@@ -131,7 +131,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadRouteWithControllerSetInDefaults()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$route = $routeCollection->get('app_blog');
|
||||
@@ -145,7 +145,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testOverrideControllerInDefaults()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$loader->load('override_defaults.yml');
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testImportRouteWithController($file)
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$routeCollection = $loader->load($file);
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
@@ -169,8 +169,8 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function provideFilesImportingRoutesWithControllers()
|
||||
{
|
||||
yield array('import_controller.yml');
|
||||
yield array('import__controller.yml');
|
||||
yield ['import_controller.yml'];
|
||||
yield ['import__controller.yml'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,13 +179,13 @@ class YamlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testImportWithOverriddenController()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
|
||||
$loader->load('import_override_defaults.yml');
|
||||
}
|
||||
|
||||
public function testImportRouteWithGlobMatchingSingleFile()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/glob']));
|
||||
$routeCollection = $loader->load('import_single.yml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
@@ -194,7 +194,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportRouteWithGlobMatchingMultipleFiles()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/glob']));
|
||||
$routeCollection = $loader->load('import_multiple.yml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
@@ -206,7 +206,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportRouteWithNamePrefix()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/import_with_name_prefix')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/import_with_name_prefix']));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$this->assertNotNull($routeCollection->get('app_blog'));
|
||||
@@ -224,7 +224,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testLoadingLocalizedRoute()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$routes = $loader->load('localized-route.yml');
|
||||
|
||||
$this->assertCount(3, $routes);
|
||||
@@ -232,7 +232,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportingRoutesFromDefinition()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$routes = $loader->load('importing-localized-route.yml');
|
||||
|
||||
$this->assertCount(3, $routes);
|
||||
@@ -243,7 +243,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportingRoutesWithLocales()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$routes = $loader->load('importer-with-locale.yml');
|
||||
|
||||
$this->assertCount(2, $routes);
|
||||
@@ -253,7 +253,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportingNonLocalizedRoutesWithLocales()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$routes = $loader->load('importer-with-locale-imports-non-localized-route.yml');
|
||||
|
||||
$this->assertCount(2, $routes);
|
||||
@@ -263,7 +263,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportingRoutesWithOfficialLocales()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$routes = $loader->load('officially_formatted_locales.yml');
|
||||
|
||||
$this->assertCount(3, $routes);
|
||||
@@ -274,21 +274,21 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportingRoutesFromDefinitionMissingLocalePrefix()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$loader->load('missing-locale-in-importer.yml');
|
||||
}
|
||||
|
||||
public function testImportingRouteWithoutPathOrLocales()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$loader->load('route-without-path-or-locales.yml');
|
||||
}
|
||||
|
||||
public function testImportingWithControllerDefault()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/localized')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
|
||||
$routes = $loader->load('importer-with-controller-default.yml');
|
||||
$this->assertCount(3, $routes);
|
||||
$this->assertEquals('DefaultController::defaultAction', $routes->get('home.en')->getDefault('_controller'));
|
||||
@@ -298,7 +298,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
public function testImportRouteWithNoTrailingSlash()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/import_with_no_trailing_slash')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/import_with_no_trailing_slash']));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$this->assertEquals('/slash/', $routeCollection->get('a_app_homepage')->getPath());
|
||||
@@ -311,7 +311,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
*/
|
||||
public function testRequirementsWithoutPlaceholderName()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
|
||||
$loader->load('requirements_without_placeholder_name.yml');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user