composer update

This commit is contained in:
2019-06-23 10:14:30 +00:00
parent a56db5ea2b
commit ec4506ebf4
790 changed files with 35767 additions and 7663 deletions

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\AbstractClassCon
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\ActionPathController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\DefaultValueController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\ExplicitLocalizedActionPathController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\GlobalDefaultsClass;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\InvokableController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\InvokableLocalizedController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\LocalizedActionPathController;
@@ -35,6 +36,7 @@ use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\PrefixedActionLo
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\PrefixedActionPathController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\RequirementsWithoutPlaceholderNameController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\RouteWithPrefixController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\Utf8ActionControllers;
class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
{
@@ -159,6 +161,32 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
$this->assertEquals('/the/path', $routes->get('post.en')->getPath());
}
public function testGlobalDefaultsRoutesLoadWithAnnotation()
{
$routes = $this->loader->load(GlobalDefaultsClass::class);
$this->assertCount(2, $routes);
$specificLocaleRoute = $routes->get('specific_locale');
$this->assertSame('/defaults/specific-locale', $specificLocaleRoute->getPath());
$this->assertSame('s_locale', $specificLocaleRoute->getDefault('_locale'));
$this->assertSame('g_format', $specificLocaleRoute->getDefault('_format'));
$specificFormatRoute = $routes->get('specific_format');
$this->assertSame('/defaults/specific-format', $specificFormatRoute->getPath());
$this->assertSame('g_locale', $specificFormatRoute->getDefault('_locale'));
$this->assertSame('s_format', $specificFormatRoute->getDefault('_format'));
}
public function testUtf8RoutesLoadWithAnnotation()
{
$routes = $this->loader->load(Utf8ActionControllers::class);
$this->assertCount(2, $routes);
$this->assertTrue($routes->get('one')->getOption('utf8'), 'The route must accept utf8');
$this->assertFalse($routes->get('two')->getOption('utf8'), 'The route must not accept utf8');
}
public function testRouteWithPathWithPrefix()
{
$routes = $this->loader->load(PrefixedActionPathController::class);
@@ -278,6 +306,34 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
$this->assertEquals('/nl/suffix', $routes->get('action.nl')->getPath());
}
/**
* @requires function mb_strtolower
*/
public function testDefaultRouteName()
{
$methodRouteData = [
'name' => null,
];
$reader = $this->getReader();
$reader
->expects($this->once())
->method('getMethodAnnotations')
->will($this->returnValue([new RouteAnnotation($methodRouteData)]))
;
$loader = new class($reader) extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
{
}
};
$routeCollection = $loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass');
$defaultName = array_keys($routeCollection->all())[0];
$this->assertSame($defaultName, 'symfony_component_routing_tests_fixtures_annotatedclasses_encodingclass_routeàction');
}
public function testLoadingRouteWithPrefix()
{
$routes = $this->loader->load(RouteWithPrefixController::class);

View File

@@ -29,7 +29,7 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
public function testLoad()
{
$this->reader->expects($this->exactly(3))->method('getClassAnnotation');
$this->reader->expects($this->exactly(4))->method('getClassAnnotation');
$this->reader
->expects($this->any())
@@ -52,6 +52,7 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass',
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass',
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass',
]);
$this->reader

View File

@@ -70,7 +70,7 @@ class ObjectRouteLoaderTest extends TestCase
* @expectedException \InvalidArgumentException
* @dataProvider getBadResourceStrings
*/
public function testExceptionWithoutSyntax($resourceString)
public function testExceptionWithoutSyntax(string $resourceString): void
{
$loader = new ObjectRouteLoaderForTest();
$loader->load($resourceString);
@@ -79,8 +79,12 @@ class ObjectRouteLoaderTest extends TestCase
public function getBadResourceStrings()
{
return [
['Foo'],
['Foo:Bar:baz'],
['Foo::Bar::baz'],
['Foo:'],
['Foo::'],
[':Foo'],
['::Foo'],
];
}

View File

@@ -84,6 +84,80 @@ class PhpFileLoaderTest extends TestCase
);
}
public function testLoadingRouteWithDefaults()
{
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('defaults.php');
$this->assertCount(1, $routes);
$defaultsRoute = $routes->get('defaults');
$this->assertSame('/defaults', $defaultsRoute->getPath());
$this->assertSame('en', $defaultsRoute->getDefault('_locale'));
$this->assertSame('html', $defaultsRoute->getDefault('_format'));
}
public function testLoadingImportedRoutesWithDefaults()
{
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('importer-with-defaults.php');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('one', $localeRoute = new Route('/defaults/one'));
$localeRoute->setDefault('_locale', 'g_locale');
$localeRoute->setDefault('_format', 'g_format');
$expectedRoutes->add('two', $formatRoute = new Route('/defaults/two'));
$formatRoute->setDefault('_locale', 'g_locale');
$formatRoute->setDefault('_format', 'g_format');
$formatRoute->setDefault('specific', 'imported');
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/imported-with-defaults.php'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/importer-with-defaults.php'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8Route()
{
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('utf8.php');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('some_route', new Route('/'));
$expectedRoutes->add('some_utf8_route', $route = new Route('/utf8'));
$route->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/utf8.php'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8ImportedRoutes()
{
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('importer-with-utf8.php');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('utf8_one', $one = new Route('/one'));
$one->setOption('utf8', true);
$expectedRoutes->add('utf8_two', $two = new Route('/two'));
$two->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/imported-with-utf8.php'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/importer-with-utf8.php'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testRoutingConfigurator()
{
$locator = new FileLocator([__DIR__.'/../Fixtures']);

View File

@@ -13,7 +13,10 @@ namespace Symfony\Component\Routing\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Routing\Loader\XmlFileLoader;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Tests\Fixtures\CustomXmlFileLoader;
class XmlFileLoaderTest extends TestCase
@@ -83,24 +86,79 @@ class XmlFileLoaderTest extends TestCase
}
}
public function testUtf8Route()
public function testLoadingRouteWithDefaults()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('defaults.xml');
$this->assertCount(1, $routes);
$defaultsRoute = $routes->get('defaults');
$this->assertSame('/defaults', $defaultsRoute->getPath());
$this->assertSame('en', $defaultsRoute->getDefault('_locale'));
$this->assertSame('html', $defaultsRoute->getDefault('_format'));
}
public function testLoadingImportedRoutesWithDefaults()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('importer-with-defaults.xml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('one', $localeRoute = new Route('/defaults/one'));
$localeRoute->setDefault('_locale', 'g_locale');
$localeRoute->setDefault('_format', 'g_format');
$expectedRoutes->add('two', $formatRoute = new Route('/defaults/two'));
$formatRoute->setDefault('_locale', 'g_locale');
$formatRoute->setDefault('_format', 'g_format');
$formatRoute->setDefault('specific', 'imported');
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/imported-with-defaults.xml'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/importer-with-defaults.xml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8Route()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routeCollection = $loader->load('utf8.xml');
$routes = $routeCollection->all();
$routes = $loader->load('utf8.xml');
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
$this->assertCount(2, $routes);
$utf8Route = $routeCollection->get('app_utf8');
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('app_utf8', $route = new Route('/utf8'));
$route->setOption('utf8', true);
$this->assertSame('/utf8', $utf8Route->getPath());
$this->assertTrue($utf8Route->getOption('utf8'), 'Must be utf8');
$expectedRoutes->add('app_no_utf8', $route = new Route('/no-utf8'));
$route->setOption('utf8', false);
$noUtf8Route = $routeCollection->get('app_no_utf8');
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/utf8.xml'));
$this->assertSame('/no-utf8', $noUtf8Route->getPath());
$this->assertFalse($noUtf8Route->getOption('utf8'), 'Must not be utf8');
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8ImportedRoutes()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('importer-with-utf8.xml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('utf8_one', $one = new Route('/one'));
$one->setOption('utf8', true);
$expectedRoutes->add('utf8_two', $two = new Route('/two'));
$two->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/imported-with-utf8.xml'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/importer-with-utf8.xml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadLocalized()

View File

@@ -15,6 +15,8 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
class YamlFileLoaderTest extends TestCase
{
@@ -222,6 +224,80 @@ class YamlFileLoaderTest extends TestCase
$loader->load('http://remote.com/here.yml');
}
public function testLoadingRouteWithDefaults()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('defaults.yml');
$this->assertCount(1, $routes);
$defaultsRoute = $routes->get('defaults');
$this->assertSame('/defaults', $defaultsRoute->getPath());
$this->assertSame('en', $defaultsRoute->getDefault('_locale'));
$this->assertSame('html', $defaultsRoute->getDefault('_format'));
}
public function testLoadingImportedRoutesWithDefaults()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('importer-with-defaults.yml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('one', $localeRoute = new Route('/defaults/one'));
$localeRoute->setDefault('_locale', 'g_locale');
$localeRoute->setDefault('_format', 'g_format');
$expectedRoutes->add('two', $formatRoute = new Route('/defaults/two'));
$formatRoute->setDefault('_locale', 'g_locale');
$formatRoute->setDefault('_format', 'g_format');
$formatRoute->setDefault('specific', 'imported');
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/imported-with-defaults.yml'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/importer-with-defaults.yml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8Route()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('utf8.yml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('some_route', new Route('/'));
$expectedRoutes->add('some_utf8_route', $route = new Route('/utf8'));
$route->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/utf8.yml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8ImportedRoutes()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('importer-with-utf8.yml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('utf8_one', $one = new Route('/one'));
$one->setOption('utf8', true);
$expectedRoutes->add('utf8_two', $two = new Route('/two'));
$two->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/imported-with-utf8.yml'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/importer-with-utf8.yml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingLocalizedRoute()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));