From 94571fcdd7ae79b4da179e1ccb7efe4a8e6ac4ee Mon Sep 17 00:00:00 2001 From: Wouter J Date: Sun, 29 Jan 2017 16:41:15 +0000 Subject: [PATCH] Apply fixes from StyleCI [ci skip] [skip ci] --- src/CmfRoutingBundle.php | 8 +- src/Controller/RedirectController.php | 6 +- .../CmfRoutingExtension.php | 8 +- .../Compiler/SetRouterPass.php | 2 +- .../Compiler/ValidationPass.php | 2 +- src/DependencyInjection/Configuration.php | 4 +- src/Doctrine/Orm/ContentRepository.php | 2 +- src/Doctrine/Orm/RouteProvider.php | 8 +- src/Doctrine/Phpcr/ContentRepository.php | 2 +- src/Doctrine/Phpcr/LocaleListener.php | 2 +- src/Doctrine/Phpcr/PrefixCandidates.php | 2 +- src/Doctrine/Phpcr/Route.php | 2 +- src/Doctrine/Phpcr/RouteProvider.php | 14 +- .../RouteConditionMetadataListener.php | 2 +- src/Model/RedirectRoute.php | 2 +- src/Model/Route.php | 2 +- src/Routing/DynamicRouter.php | 4 +- tests/Functional/BaseTestCase.php | 2 +- .../Controller/RedirectControllerTest.php | 10 +- tests/Functional/Doctrine/Orm/OrmTestCase.php | 6 +- .../Doctrine/Phpcr/RedirectRouteTest.php | 4 +- .../Doctrine/Phpcr/RouteProviderTest.php | 8 +- tests/Functional/Doctrine/Phpcr/RouteTest.php | 4 +- .../Functional/Routing/DynamicRouterTest.php | 80 ++--- .../DataFixtures/Phpcr/LoadRouteData.php | 4 +- tests/Resources/Fixtures/config/config.php | 51 +-- tests/Resources/app/AppKernel.php | 23 +- tests/Resources/app/config/config_orm.php | 9 + tests/Resources/app/config/config_phpcr.php | 9 + tests/Resources/app/config/routing.php | 9 + .../CmfRoutingExtensionTest.php | 296 +++++++++--------- .../Compiler/SetRouterPassTest.php | 2 +- .../DependencyInjection/ConfigurationTest.php | 54 ++-- .../DependencyInjection/XmlSchemaTest.php | 4 +- .../Doctrine/Orm/ContentRepositoryTest.php | 10 +- tests/Unit/Doctrine/Orm/RouteProviderTest.php | 24 +- .../Doctrine/Phpcr/ContentRepositoryTest.php | 4 +- .../Doctrine/Phpcr/IdPrefixListenerTest.php | 4 +- .../Doctrine/Phpcr/LocaleListenerTest.php | 16 +- .../Doctrine/Phpcr/PrefixCandidatesTest.php | 38 +-- .../Unit/Doctrine/Phpcr/RouteProviderTest.php | 30 +- tests/Unit/Doctrine/Phpcr/RouteTest.php | 4 +- tests/Unit/Form/Type/RouteTypeTypeTest.php | 8 +- tests/Unit/Routing/DynamicRouterTest.php | 14 +- .../RouteDefaultsValidatorTest.php | 12 +- 45 files changed, 428 insertions(+), 383 deletions(-) diff --git a/src/CmfRoutingBundle.php b/src/CmfRoutingBundle.php index be197c95..c9245ac1 100644 --- a/src/CmfRoutingBundle.php +++ b/src/CmfRoutingBundle.php @@ -18,14 +18,14 @@ use Doctrine\ODM\PHPCR\Version as PHPCRVersion; use Doctrine\ORM\Mapping\Driver\XmlDriver as ORMXmlDriver; use Doctrine\ORM\Version as ORMVersion; +use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler\SetRouterPass; use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler\ValidationPass; +use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRouteEnhancersPass; +use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRoutersPass; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\HttpKernel\Bundle\Bundle; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRoutersPass; -use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRouteEnhancersPass; -use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler\SetRouterPass; /** * Bundle class. diff --git a/src/Controller/RedirectController.php b/src/Controller/RedirectController.php index b3cd261b..2dce14d0 100644 --- a/src/Controller/RedirectController.php +++ b/src/Controller/RedirectController.php @@ -11,10 +11,10 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Controller; -use Symfony\Component\Routing\RouterInterface; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Cmf\Component\Routing\RedirectRouteInterface; +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Routing\RouterInterface; /** * Default router that handles redirection route objects. diff --git a/src/DependencyInjection/CmfRoutingExtension.php b/src/DependencyInjection/CmfRoutingExtension.php index cfeabe9e..76d8d721 100644 --- a/src/DependencyInjection/CmfRoutingExtension.php +++ b/src/DependencyInjection/CmfRoutingExtension.php @@ -12,13 +12,13 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** * @author Philippo de Santis diff --git a/src/DependencyInjection/Compiler/SetRouterPass.php b/src/DependencyInjection/Compiler/SetRouterPass.php index 60fb2145..1eb2cd99 100644 --- a/src/DependencyInjection/Compiler/SetRouterPass.php +++ b/src/DependencyInjection/Compiler/SetRouterPass.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Changes the Router implementation. diff --git a/src/DependencyInjection/Compiler/ValidationPass.php b/src/DependencyInjection/Compiler/ValidationPass.php index 93ab337e..18430066 100644 --- a/src/DependencyInjection/Compiler/ValidationPass.php +++ b/src/DependencyInjection/Compiler/ValidationPass.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Register validation files if their storage is activated. diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index d3a26847..1a6e0da9 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -11,10 +11,10 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; -use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route; +use Symfony\Component\Config\Definition\ConfigurationInterface; /** * This class contains the configuration information for the bundle. diff --git a/src/Doctrine/Orm/ContentRepository.php b/src/Doctrine/Orm/ContentRepository.php index 5a7f6490..0a1b5c6b 100644 --- a/src/Doctrine/Orm/ContentRepository.php +++ b/src/Doctrine/Orm/ContentRepository.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm; -use Symfony\Cmf\Component\Routing\ContentRepositoryInterface; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\DoctrineProvider; +use Symfony\Cmf\Component\Routing\ContentRepositoryInterface; /** * Abstract content repository for ORM. diff --git a/src/Doctrine/Orm/RouteProvider.php b/src/Doctrine/Orm/RouteProvider.php index 5d5371c6..830ca87f 100644 --- a/src/Doctrine/Orm/RouteProvider.php +++ b/src/Doctrine/Orm/RouteProvider.php @@ -14,12 +14,12 @@ use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\ObjectRepository; use Doctrine\DBAL\Exception\TableNotFoundException; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\DoctrineProvider; use Symfony\Cmf\Component\Routing\Candidates\CandidatesInterface; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\RouteProviderInterface; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\DoctrineProvider; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Exception\RouteNotFoundException; +use Symfony\Component\Routing\RouteCollection; /** * Provider loading routes from Doctrine. diff --git a/src/Doctrine/Phpcr/ContentRepository.php b/src/Doctrine/Phpcr/ContentRepository.php index b187e6e0..95c4917c 100644 --- a/src/Doctrine/Phpcr/ContentRepository.php +++ b/src/Doctrine/Phpcr/ContentRepository.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr; -use Symfony\Cmf\Component\Routing\ContentRepositoryInterface; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\DoctrineProvider; +use Symfony\Cmf\Component\Routing\ContentRepositoryInterface; /** * Implement ContentRepositoryInterface for PHPCR-ODM. diff --git a/src/Doctrine/Phpcr/LocaleListener.php b/src/Doctrine/Phpcr/LocaleListener.php index 99b90b1f..cf2035fa 100644 --- a/src/Doctrine/Phpcr/LocaleListener.php +++ b/src/Doctrine/Phpcr/LocaleListener.php @@ -11,9 +11,9 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr; +use Doctrine\Common\Persistence\Event\LifecycleEventArgs; use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\Event\MoveEventArgs; -use Doctrine\Common\Persistence\Event\LifecycleEventArgs; use Symfony\Cmf\Bundle\RoutingBundle\Model\Route as ModelRoute; /** diff --git a/src/Doctrine/Phpcr/PrefixCandidates.php b/src/Doctrine/Phpcr/PrefixCandidates.php index 2271e43d..bf103517 100644 --- a/src/Doctrine/Phpcr/PrefixCandidates.php +++ b/src/Doctrine/Phpcr/PrefixCandidates.php @@ -11,10 +11,10 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr; -use PHPCR\Util\PathHelper; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; +use PHPCR\Util\PathHelper; use Symfony\Cmf\Component\Routing\Candidates\Candidates; use Symfony\Component\HttpFoundation\Request; diff --git a/src/Doctrine/Phpcr/Route.php b/src/Doctrine/Phpcr/Route.php index 5d108886..d4ec82cb 100644 --- a/src/Doctrine/Phpcr/Route.php +++ b/src/Doctrine/Phpcr/Route.php @@ -15,8 +15,8 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\PHPCR\Exception\InvalidArgumentException; use Doctrine\ODM\PHPCR\HierarchyInterface; -use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Cmf\Bundle\RoutingBundle\Model\Route as RouteModel; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; /** * PHPCR-ODM routes use their path for the url. They need to have set the diff --git a/src/Doctrine/Phpcr/RouteProvider.php b/src/Doctrine/Phpcr/RouteProvider.php index 90bdf728..cd6d59aa 100644 --- a/src/Doctrine/Phpcr/RouteProvider.php +++ b/src/Doctrine/Phpcr/RouteProvider.php @@ -11,19 +11,19 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr; +use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\DBAL\Exception\TableNotFoundException; +use Doctrine\ODM\PHPCR\DocumentManager; use PHPCR\RepositoryException; use PHPCR\Util\UUIDHelper; -use Doctrine\Common\Persistence\ManagerRegistry; -use Doctrine\ODM\PHPCR\DocumentManager; use Psr\Log\LoggerInterface; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\DoctrineProvider; +use Symfony\Cmf\Component\Routing\Candidates\CandidatesInterface; +use Symfony\Cmf\Component\Routing\RouteProviderInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Route as SymfonyRoute; use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Cmf\Component\Routing\RouteProviderInterface; -use Symfony\Cmf\Component\Routing\Candidates\CandidatesInterface; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\DoctrineProvider; /** * Loads routes from Doctrine PHPCR-ODM. diff --git a/src/Doctrine/RouteConditionMetadataListener.php b/src/Doctrine/RouteConditionMetadataListener.php index 1e106f31..0af94d53 100644 --- a/src/Doctrine/RouteConditionMetadataListener.php +++ b/src/Doctrine/RouteConditionMetadataListener.php @@ -13,8 +13,8 @@ use Doctrine\Common\EventSubscriber; use Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs; -use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata; use Doctrine\ODM\PHPCR\Mapping\ClassMetadata as PhpcrClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata; use Symfony\Component\Routing\Route; /** diff --git a/src/Model/RedirectRoute.php b/src/Model/RedirectRoute.php index 8a367c0f..ce86c0b6 100644 --- a/src/Model/RedirectRoute.php +++ b/src/Model/RedirectRoute.php @@ -12,8 +12,8 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Model; use LogicException; -use Symfony\Component\Routing\Route as SymfonyRoute; use Symfony\Cmf\Component\Routing\RedirectRouteInterface; +use Symfony\Component\Routing\Route as SymfonyRoute; /** * {@inheritdoc} diff --git a/src/Model/Route.php b/src/Model/Route.php index a956628a..9a2e1c3e 100644 --- a/src/Model/Route.php +++ b/src/Model/Route.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Model; -use Symfony\Component\Routing\Route as SymfonyRoute; use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\Routing\Route as SymfonyRoute; use Symfony\Component\Routing\RouteCompiler; /** diff --git a/src/Routing/DynamicRouter.php b/src/Routing/DynamicRouter.php index bd6cbd89..7cfe4a1b 100644 --- a/src/Routing/DynamicRouter.php +++ b/src/Routing/DynamicRouter.php @@ -11,10 +11,10 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Routing; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Cmf\Component\Routing\DynamicRouter as BaseDynamicRouter; use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; /** * Symfony framework integration of the CMF routing component DynamicRouter class. diff --git a/tests/Functional/BaseTestCase.php b/tests/Functional/BaseTestCase.php index 6d622788..1fca3b59 100644 --- a/tests/Functional/BaseTestCase.php +++ b/tests/Functional/BaseTestCase.php @@ -14,8 +14,8 @@ use Doctrine\ODM\PHPCR\DocumentManager; use PHPCR\Util\PathHelper; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; -use Symfony\Cmf\Component\Testing\Functional\BaseTestCase as ComponentBaseTestCase; use Symfony\Cmf\Bundle\RoutingBundle\Tests\Resources\Document\Content; +use Symfony\Cmf\Component\Testing\Functional\BaseTestCase as ComponentBaseTestCase; class BaseTestCase extends ComponentBaseTestCase { diff --git a/tests/Functional/Controller/RedirectControllerTest.php b/tests/Functional/Controller/RedirectControllerTest.php index 40d0205f..153570bd 100644 --- a/tests/Functional/Controller/RedirectControllerTest.php +++ b/tests/Functional/Controller/RedirectControllerTest.php @@ -11,9 +11,9 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\Controller; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute; use Symfony\Cmf\Bundle\RoutingBundle\Controller\RedirectController; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -43,7 +43,7 @@ public function testRedirectUri() $redirect = new RedirectRoute(); $redirect->setPosition($root, 'redirectUri'); $redirect->setUri('http://example.com/test-url'); - $redirect->setParameters(array('test' => 7)); // parameters should be ignored in this case + $redirect->setParameters(['test' => 7]); // parameters should be ignored in this case $redirect->setPermanent(true); $this->getDm()->persist($redirect); @@ -73,7 +73,7 @@ public function testRedirectContent() $redirect = new RedirectRoute(); $redirect->setPosition($root, 'redirectContent'); $redirect->setRouteTarget($route); - $redirect->setParameters(array('test' => 'content')); + $redirect->setParameters(['test' => 'content']); $this->getDm()->persist($redirect); $this->getDm()->flush(); @@ -95,7 +95,7 @@ public function testRedirectName() $redirect = new RedirectRoute(); $redirect->setPosition($root, 'redirectName'); $redirect->setRouteName('symfony_route'); - $redirect->setParameters(array('param' => 7)); // parameters should be ignored in this case + $redirect->setParameters(['param' => 7]); // parameters should be ignored in this case $this->getDm()->persist($redirect); $this->getDm()->flush(); diff --git a/tests/Functional/Doctrine/Orm/OrmTestCase.php b/tests/Functional/Doctrine/Orm/OrmTestCase.php index 975f53a0..339323f4 100644 --- a/tests/Functional/Doctrine/Orm/OrmTestCase.php +++ b/tests/Functional/Doctrine/Orm/OrmTestCase.php @@ -11,16 +11,16 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\Doctrine\Orm; -use Symfony\Cmf\Component\Testing\Functional\BaseTestCase as ComponentBaseTestCase; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route; +use Symfony\Cmf\Component\Testing\Functional\BaseTestCase as ComponentBaseTestCase; class OrmTestCase extends ComponentBaseTestCase { protected function getKernelConfiguration() { - return array( + return [ 'environment' => 'orm', - ); + ]; } protected function clearDb($model) diff --git a/tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php b/tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php index a121590a..3785a0fb 100644 --- a/tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php +++ b/tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\Doctrine\Phpcr; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase; use Symfony\Cmf\Component\Routing\RedirectRouteInterface; use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface; @@ -56,7 +56,7 @@ public function testRedirectDoctrine() $params = $redirect->getParameters(); $this->assertSame($route, $redirect->getRouteTarget()); $defaults = $redirect->getDefaults(); - $this->assertEquals(array('test' => 'toast'), $defaults); + $this->assertEquals(['test' => 'toast'], $defaults); } /** diff --git a/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php b/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php index 4227ebc8..63e1fa2f 100644 --- a/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php +++ b/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php @@ -12,11 +12,11 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\Doctrine\Phpcr; use Doctrine\ODM\PHPCR\Document\Generic; -use Symfony\Cmf\Component\Routing\RouteObjectInterface; -use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RouteProvider; use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RouteCollection; class RouteProviderTest extends BaseTestCase @@ -125,12 +125,12 @@ public function testGetRoutesByNames() { $this->buildRoutes(); - $routeNames = array( + $routeNames = [ self::ROUTE_ROOT.'/testroute/noroute/child', self::ROUTE_ROOT.'/testroute/noroute', self::ROUTE_ROOT.'/testroute/', // trailing slash is invalid for phpcr self::ROUTE_ROOT.'/testroute', - ); + ]; $routes = $this->repository->getRoutesByNames($routeNames); $this->assertCount(2, $routes); diff --git a/tests/Functional/Doctrine/Phpcr/RouteTest.php b/tests/Functional/Doctrine/Phpcr/RouteTest.php index e2e54066..c275f007 100644 --- a/tests/Functional/Doctrine/Phpcr/RouteTest.php +++ b/tests/Functional/Doctrine/Phpcr/RouteTest.php @@ -34,7 +34,7 @@ public function testPersist() $route->setPosition($root, 'testroute'); $route->setDefault('x', 'y'); $route->setRequirement('testreq', 'testregex'); - $route->setOptions(array('test' => 'value')); + $route->setOptions(['test' => 'value']); $route->setOption('another', 'value2'); $this->getDm()->persist($route); @@ -159,7 +159,7 @@ public function testPrefixNonpersisted() public function testDefaultFormat() { - $route = new Route(array('add_format_pattern' => true)); + $route = new Route(['add_format_pattern' => true]); $root = $this->getDm()->find(null, self::ROUTE_ROOT); diff --git a/tests/Functional/Routing/DynamicRouterTest.php b/tests/Functional/Routing/DynamicRouterTest.php index a9426992..a8f78004 100644 --- a/tests/Functional/Routing/DynamicRouterTest.php +++ b/tests/Functional/Routing/DynamicRouterTest.php @@ -12,15 +12,15 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\Routing; use PHPCR\Util\NodeHelper; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Cmf\Component\Routing\ChainRouter; -use Symfony\Cmf\Component\Routing\RouteObjectInterface; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\RoutingBundle\Routing\DynamicRouter; use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase; use Symfony\Cmf\Bundle\RoutingBundle\Tests\Resources\Document\Content; +use Symfony\Cmf\Component\Routing\ChainRouter; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * The goal of these tests is to test the interoperation with DI and everything. @@ -65,21 +65,21 @@ public function setUp() $childroute->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testController'); $this->getDm()->persist($childroute); - $formatroute = new Route(array('add_format_pattern' => true)); + $formatroute = new Route(['add_format_pattern' => true]); $formatroute->setPosition($root, 'format'); $formatroute->setVariablePattern('/{id}'); $formatroute->setRequirement('_format', 'html|json'); $formatroute->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testController'); $this->getDm()->persist($formatroute); - $format2jsonroute = new Route(array('add_format_pattern' => true)); + $format2jsonroute = new Route(['add_format_pattern' => true]); $format2jsonroute->setPosition($root, 'format2.json'); $format2jsonroute->setDefault('_format', 'json'); $format2jsonroute->setRequirement('_format', 'json'); $format2jsonroute->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testJsonController'); $this->getDm()->persist($format2jsonroute); - $format2route = new Route(array('add_format_pattern' => true)); + $format2route = new Route(['add_format_pattern' => true]); $format2route->setPosition($root, 'format2'); $format2route->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testController'); $this->getDm()->persist($format2route); @@ -89,10 +89,10 @@ public function setUp() public function testMatch() { - $expected = array( + $expected = [ RouteObjectInterface::CONTROLLER_NAME, RouteObjectInterface::ROUTE_NAME, - ); + ]; $request = Request::create('/testroute/child'); $matches = $this->router->matchRequest($request); @@ -105,12 +105,12 @@ public function testMatch() public function testMatchParameters() { - $expected = array( + $expected = [ RouteObjectInterface::CONTROLLER_NAME => 'testController', RouteObjectInterface::ROUTE_NAME => '/test/routing/testroute', 'id' => '123', 'slug' => 'child', - ); + ]; $request = Request::create('/testroute/child/123'); @@ -139,7 +139,7 @@ public function testNotAllowed() // do not set a content here, or we need a valid request and so on... $route = new Route(); $route->setPosition($root, 'notallowed'); - $route->setMethods(array('GET')); + $route->setMethods(['GET']); $route->setDefault(RouteObjectInterface::CONTROLLER_NAME, 'testController'); $this->getDm()->persist($route); $this->getDm()->flush(); @@ -149,12 +149,12 @@ public function testNotAllowed() public function testMatchDefaultFormat() { - $expected = array( + $expected = [ '_controller' => 'testController', '_format' => 'html', RouteObjectInterface::ROUTE_NAME => '/test/routing/format', 'id' => '48', - ); + ]; $request = Request::create('/format/48'); $matches = $this->router->matchRequest($request); ksort($matches); @@ -165,12 +165,12 @@ public function testMatchDefaultFormat() public function testMatchFormat() { - $expected = array( + $expected = [ '_controller' => 'testController', '_format' => 'json', RouteObjectInterface::ROUTE_NAME => '/test/routing/format', 'id' => '48', - ); + ]; $request = Request::create('/format/48.json'); $matches = $this->router->matchRequest($request); ksort($matches); @@ -178,11 +178,11 @@ public function testMatchFormat() $this->assertTrue($request->attributes->has(DynamicRouter::ROUTE_KEY)); $this->assertEquals($expected, $matches); - $expected = array( + $expected = [ '_controller' => 'testController', '_format' => 'html', RouteObjectInterface::ROUTE_NAME => '/test/routing/format2', - ); + ]; $request = Request::create('/format2.html'); $matches = $this->router->matchRequest($request); ksort($matches); @@ -190,11 +190,11 @@ public function testMatchFormat() $this->assertTrue($request->attributes->has(DynamicRouter::ROUTE_KEY)); $this->assertEquals($expected, $matches); - $expected = array( + $expected = [ '_controller' => 'testJsonController', '_format' => 'json', RouteObjectInterface::ROUTE_NAME => '/test/routing/format2.json', - ); + ]; $request = Request::create('/format2.json'); $matches = $this->router->matchRequest($request); ksort($matches); @@ -227,29 +227,29 @@ public function testMatchLocale() $this->getDm()->persist($nolocale); $this->getDm()->flush(); - $expected = array( + $expected = [ '_controller' => 'testController', '_locale' => 'de', '_route' => self::ROUTE_ROOT.'/de', - ); + ]; $this->assertEquals( $expected, $this->router->match('/de') ); - $expected = array( + $expected = [ '_controller' => 'testController', '_locale' => 'de', '_route' => self::ROUTE_ROOT.'/de/testroute', - ); + ]; $this->assertEquals( $expected, $this->router->match('/de/testroute') ); // es is not a configured locale - $expected = array( + $expected = [ '_controller' => 'testController', '_route' => self::ROUTE_ROOT.'/es', - ); + ]; $this->assertEquals( $expected, $this->router->match('/es') @@ -267,11 +267,11 @@ public function testEnhanceControllerByAlias() $this->getDm()->persist($route); $this->getDm()->flush(); - $expected = array( + $expected = [ '_controller' => 'test.controller:aliasAction', RouteObjectInterface::ROUTE_NAME => '/test/routing/controlleralias', 'type' => 'demo_alias', - ); + ]; $request = Request::create('/controlleralias'); $matches = $this->router->matchRequest($request); ksort($matches); @@ -291,10 +291,10 @@ public function testEnhanceControllerByClass() $this->getDm()->persist($route); $this->getDm()->flush(); - $expected = array( + $expected = [ '_controller' => 'cmf_routing.redirect_controller:redirectAction', RouteObjectInterface::ROUTE_NAME => '/test/routing/redirect', - ); + ]; $request = Request::create('/redirect'); $matches = $this->router->matchRequest($request); ksort($matches); @@ -323,10 +323,10 @@ public function testEnhanceTemplateByClass() $this->getDm()->persist($route); $this->getDm()->flush(); - $expected = array( + $expected = [ '_controller' => 'cmf_content.controller:indexAction', RouteObjectInterface::ROUTE_NAME => self::ROUTE_ROOT.'/templatebyclass', - ); + ]; $request = Request::create('/templatebyclass'); $matches = $this->router->matchRequest($request); ksort($matches); @@ -341,14 +341,14 @@ public function testGenerate() { $route = $this->getDm()->find(null, self::ROUTE_ROOT.'/testroute/child'); - $url = $this->router->generate($route, array('test' => 'value')); + $url = $this->router->generate($route, ['test' => 'value']); $this->assertEquals('/testroute/child?test=value', $url); } public function testGenerateAbsolute() { $route = $this->getDm()->find(null, self::ROUTE_ROOT.'/testroute/child'); - $url = $this->router->generate($route, array('test' => 'value'), UrlGeneratorInterface::ABSOLUTE_URL); + $url = $this->router->generate($route, ['test' => 'value'], UrlGeneratorInterface::ABSOLUTE_URL); $this->assertEquals('http://localhost/testroute/child?test=value', $url); } @@ -356,7 +356,7 @@ public function testGenerateParameters() { $route = $this->getDm()->find(null, self::ROUTE_ROOT.'/testroute'); - $url = $this->router->generate($route, array('slug' => 'gen-slug', 'test' => 'value')); + $url = $this->router->generate($route, ['slug' => 'gen-slug', 'test' => 'value']); $this->assertEquals('/testroute/gen-slug?test=value', $url); } @@ -367,14 +367,14 @@ public function testGenerateParametersInvalid() { $route = $this->getDm()->find(null, self::ROUTE_ROOT.'/testroute'); - $this->router->generate($route, array('slug' => 'gen-slug', 'id' => 'nonumber')); + $this->router->generate($route, ['slug' => 'gen-slug', 'id' => 'nonumber']); } public function testGenerateDefaultFormat() { $route = $this->getDm()->find(null, self::ROUTE_ROOT.'/format'); - $url = $this->router->generate($route, array('id' => 37)); + $url = $this->router->generate($route, ['id' => 37]); $this->assertEquals('/format/37', $url); } @@ -382,7 +382,7 @@ public function testGenerateFormat() { $route = $this->getDm()->find(null, self::ROUTE_ROOT.'/format'); - $url = $this->router->generate($route, array('id' => 37, '_format' => 'json')); + $url = $this->router->generate($route, ['id' => 37, '_format' => 'json']); $this->assertEquals('/format/37.json', $url); } @@ -393,6 +393,6 @@ public function testGenerateNoMatchingFormat() { $route = $this->getDm()->find(null, self::ROUTE_ROOT.'/format'); - $this->router->generate($route, array('id' => 37, '_format' => 'xyz')); + $this->router->generate($route, ['id' => 37, '_format' => 'xyz']); } } diff --git a/tests/Resources/DataFixtures/Phpcr/LoadRouteData.php b/tests/Resources/DataFixtures/Phpcr/LoadRouteData.php index e0166bc3..17f76097 100644 --- a/tests/Resources/DataFixtures/Phpcr/LoadRouteData.php +++ b/tests/Resources/DataFixtures/Phpcr/LoadRouteData.php @@ -13,10 +13,10 @@ use Doctrine\Common\DataFixtures\FixtureInterface; use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ODM\PHPCR\Document\Generic; use PHPCR\Util\NodeHelper; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute; -use Doctrine\ODM\PHPCR\Document\Generic; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; class LoadRouteData implements FixtureInterface { diff --git a/tests/Resources/Fixtures/config/config.php b/tests/Resources/Fixtures/config/config.php index 1a0c020c..920616de 100644 --- a/tests/Resources/Fixtures/config/config.php +++ b/tests/Resources/Fixtures/config/config.php @@ -1,36 +1,45 @@ loadFromExtension('cmf_routing', array( - 'chain' => array( - 'routers_by_id' => array( +/* + * This file is part of the Symfony CMF package. + * + * (c) 2011-2017 Symfony CMF + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$container->loadFromExtension('cmf_routing', [ + 'chain' => [ + 'routers_by_id' => [ 'cmf_routing.router' => 300, 'router.default' => 100, - ), + ], 'replace_symfony_router' => true, - ), - 'dynamic' => array( + ], + 'dynamic' => [ 'generic_controller' => 'acme_main.controller:mainAction', - 'controllers_by_type' => array( + 'controllers_by_type' => [ 'editable' => 'acme_main.some_controller:editableAction', - ), - 'controllers_by_class' => array( + ], + 'controllers_by_class' => [ 'Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent' => 'cmf_content.controller:indexAction', - ), - 'templates_by_class' => array( + ], + 'templates_by_class' => [ 'Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent' => 'CmfContentBundle:StaticContent:index.html.twig', - ), - 'persistence' => array( - 'phpcr' => array( - 'route_basepaths' => array( + ], + 'persistence' => [ + 'phpcr' => [ + 'route_basepaths' => [ '/cms/routes', '/simple', - ), + ], 'content_basepath' => '/cms/content', 'enable_initializer' => true, - ), - ), - 'locales' => array('en', 'fr'), + ], + ], + 'locales' => ['en', 'fr'], 'auto_locale_pattern' => true, 'match_implicit_locale' => true, - ), -)); + ], +]); diff --git a/tests/Resources/app/AppKernel.php b/tests/Resources/app/AppKernel.php index 747e93ba..6a448bb1 100644 --- a/tests/Resources/app/AppKernel.php +++ b/tests/Resources/app/AppKernel.php @@ -1,7 +1,16 @@ requireBundleSet('default'); if ('phpcr' === $this->environment) { - $this->requireBundleSets(array( + $this->requireBundleSets([ 'phpcr_odm', - )); + ]); } elseif ('orm' === $this->environment) { $this->requireBundleSet('doctrine_orm'); } - $this->addBundles(array( + $this->addBundles([ new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(), - )); + ]); if (class_exists(CmfResourceRestBundle::class)) { - $this->addBundles(array( + $this->addBundles([ new \Symfony\Cmf\Bundle\ResourceBundle\CmfResourceBundle(), new \Symfony\Cmf\Bundle\ResourceRestBundle\CmfResourceRestBundle(), - )); + ]); } } diff --git a/tests/Resources/app/config/config_orm.php b/tests/Resources/app/config/config_orm.php index 3b940b4c..829f0d05 100644 --- a/tests/Resources/app/config/config_orm.php +++ b/tests/Resources/app/config/config_orm.php @@ -1,5 +1,14 @@ setParameter('cmf_testing.bundle_fqn', 'Symfony\Cmf\Bundle\RoutingBundle'); $loader->import(CMF_TEST_CONFIG_DIR.'/default.php'); $loader->import(CMF_TEST_CONFIG_DIR.'/doctrine_orm.php'); diff --git a/tests/Resources/app/config/config_phpcr.php b/tests/Resources/app/config/config_phpcr.php index bea412f5..094e7a4e 100644 --- a/tests/Resources/app/config/config_phpcr.php +++ b/tests/Resources/app/config/config_phpcr.php @@ -1,5 +1,14 @@ setParameter('cmf_testing.bundle_fqn', 'Symfony\Cmf\Bundle\RoutingBundle'); $loader->import(CMF_TEST_CONFIG_DIR.'/default.php'); $loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php'); diff --git a/tests/Resources/app/config/routing.php b/tests/Resources/app/config/routing.php index 1d0e3413..2f33e571 100644 --- a/tests/Resources/app/config/routing.php +++ b/tests/Resources/app/config/routing.php @@ -1,5 +1,14 @@ load(array( - 'dynamic' => array( + $this->load([ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array( - 'phpcr' => array( + 'persistence' => [ + 'phpcr' => [ 'enabled' => true, - ), - ), - ), - )); + ], + ], + ], + ]); $this->assertContainerBuilderHasAlias('cmf_routing.route_provider', 'cmf_routing.phpcr_route_provider'); $this->assertContainerBuilderHasAlias('cmf_routing.content_repository', 'cmf_routing.phpcr_content_repository'); @@ -45,88 +45,88 @@ public function testLoadDefault() $this->assertContainerBuilderHasParameter('cmf_routing.replace_symfony_router', true); $this->assertContainerBuilderHasService('cmf_routing.router', ChainRouter::class); - $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('cmf_routing.router', 'add', array( + $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('cmf_routing.router', 'add', [ new Reference('router.default'), 100, - )); + ]); $this->assertContainerBuilderHasServiceDefinitionWithTag( 'cmf_routing.enhancer.route_content', 'dynamic_router_route_enhancer', - array('priority' => 100) + ['priority' => 100] ); } public function testLoadConfigured() { - $this->load(array( - 'dynamic' => array( + $this->load([ + 'dynamic' => [ 'enabled' => true, 'route_provider_service_id' => 'test_route_provider_service', 'content_repository_service_id' => 'test_content_repository_service', - 'persistence' => array( + 'persistence' => [ 'phpcr' => true, - ), - ), - 'chain' => array( - 'routers_by_id' => array( + ], + ], + 'chain' => [ + 'routers_by_id' => [ 'router.custom' => 200, 'router.default' => 300, - ), - ), - )); + ], + ], + ]); $this->assertContainerBuilderHasAlias('cmf_routing.route_provider', 'test_route_provider_service'); $this->assertContainerBuilderHasAlias('cmf_routing.content_repository', 'test_content_repository_service'); - $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('cmf_routing.router', 'add', array( + $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('cmf_routing.router', 'add', [ new Reference('router.custom'), 200, - )); - $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('cmf_routing.router', 'add', array( + ]); + $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('cmf_routing.router', 'add', [ new Reference('router.default'), 300, - )); + ]); $this->assertContainerBuilderHasServiceDefinitionWithTag( 'cmf_routing.enhancer.content_repository', 'dynamic_router_route_enhancer', - array('priority' => 100) + ['priority' => 100] ); } public function testWhitespaceInPriorities() { - $this->load(array( - 'dynamic' => array( + $this->load([ + 'dynamic' => [ 'route_provider_service_id' => 'test_route_provider_service', 'enabled' => true, - 'controllers_by_type' => array( + 'controllers_by_type' => [ 'Acme\Foo' => ' acme_main.controller:indexAction ', - ), - ), - 'chain' => array( - 'routers_by_id' => array( + ], + ], + 'chain' => [ + 'routers_by_id' => [ 'acme_test.router' => ' 100 ', - ), - ), - )); + ], + ], + ]); - $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('cmf_routing.router', 'add', array( + $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('cmf_routing.router', 'add', [ new Reference('acme_test.router'), 100, - )); + ]); - $this->assertContainerBuilderHasParameter('cmf_routing.controllers_by_type', array( + $this->assertContainerBuilderHasParameter('cmf_routing.controllers_by_type', [ 'Acme\Foo' => 'acme_main.controller:indexAction', - )); + ]); $this->assertContainerBuilderHasServiceDefinitionWithTag( 'cmf_routing.enhancer.controllers_by_type', 'dynamic_router_route_enhancer', - array('priority' => 60) + ['priority' => 60] ); } @@ -137,55 +137,55 @@ public function testLoadBasePaths($phpcrConfig, $routeBasepathsParameter) { $this->container->setParameter( 'kernel.bundles', - array( + [ 'CmfRoutingBundle' => true, - ) + ] ); if (!isset($phpcrConfig['enabled'])) { $phpcrConfig['enabled'] = true; } - $this->load(array( - 'dynamic' => array( + $this->load([ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array( + 'persistence' => [ 'phpcr' => $phpcrConfig, - ), - ), - )); + ], + ], + ]); $this->assertContainerBuilderHasParameter('cmf_routing.dynamic.persistence.phpcr.route_basepaths', $routeBasepathsParameter); $this->assertContainerBuilderHasServiceDefinitionWithTag( 'cmf_routing.enhancer.content_repository', 'dynamic_router_route_enhancer', - array('priority' => 100) + ['priority' => 100] ); } public function getBasePathsTests() { - return array( - array( + return [ + [ [], - array('/cms/routes'), - ), - - array( - array('route_basepaths' => '/cms/test'), - array('/cms/test'), - ), - - array( - array('route_basepaths' => array('/cms/routes', '/cms/test')), - array('/cms/routes', '/cms/test'), - ), - - array( - array('route_basepaths' => array('/cms/test', '/cms/routes')), - array('/cms/test', '/cms/routes'), - ), - ); + ['/cms/routes'], + ], + + [ + ['route_basepaths' => '/cms/test'], + ['/cms/test'], + ], + + [ + ['route_basepaths' => ['/cms/routes', '/cms/test']], + ['/cms/routes', '/cms/test'], + ], + + [ + ['route_basepaths' => ['/cms/test', '/cms/routes']], + ['/cms/test', '/cms/routes'], + ], + ]; } /** @@ -195,7 +195,7 @@ public function testRouteBasepathsMerging($phpcrConfig1, $phpcrConfig2, $routeBa { $this->container->setParameter( 'kernel.bundles', - array('CmfRoutingBundle' => true) + ['CmfRoutingBundle' => true] ); if (!isset($phpcrConfig1['enabled'])) { @@ -205,20 +205,20 @@ public function testRouteBasepathsMerging($phpcrConfig1, $phpcrConfig2, $routeBa $phpcrConfig2['enabled'] = true; } - $configs = array( - array( - 'dynamic' => array( + $configs = [ + [ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array('phpcr' => $phpcrConfig1), - ), - ), - array( - 'dynamic' => array( + 'persistence' => ['phpcr' => $phpcrConfig1], + ], + ], + [ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array('phpcr' => $phpcrConfig2), - ), - ), - ); + 'persistence' => ['phpcr' => $phpcrConfig2], + ], + ], + ]; foreach ($this->container->getExtensions() as $extension) { $extension->load($configs, $this->container); @@ -228,77 +228,77 @@ public function testRouteBasepathsMerging($phpcrConfig1, $phpcrConfig2, $routeBa $this->assertContainerBuilderHasServiceDefinitionWithTag( 'cmf_routing.enhancer.content_repository', 'dynamic_router_route_enhancer', - array('priority' => 100) + ['priority' => 100] ); } public function getBasePathsMergingTests() { - return array( - array( - array('route_basepaths' => array('/cms/test')), - array('route_basepaths' => array('/cms/test2')), - array('/cms/test', '/cms/test2'), + return [ + [ + ['route_basepaths' => ['/cms/test']], + ['route_basepaths' => ['/cms/test2']], + ['/cms/test', '/cms/test2'], '/cms/test', - ), + ], - array( - array('route_basepaths' => array('/cms/test')), - array('route_basepaths' => array('/cms/test2', '/cms/test3')), - array('/cms/test', '/cms/test2', '/cms/test3'), + [ + ['route_basepaths' => ['/cms/test']], + ['route_basepaths' => ['/cms/test2', '/cms/test3']], + ['/cms/test', '/cms/test2', '/cms/test3'], '/cms/test', - ), + ], - array( + [ [], - array('route_basepaths' => array('/cms/test')), - array('/cms/test'), + ['route_basepaths' => ['/cms/test']], + ['/cms/test'], '/cms/test', - ), - ); + ], + ]; } public function testLegacyRouteBasepath() { $this->container->setParameter( 'kernel.bundles', - array('CmfRoutingBundle' => true) + ['CmfRoutingBundle' => true] ); - $this->load(array( - 'dynamic' => array( + $this->load([ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array( - 'phpcr' => array( + 'persistence' => [ + 'phpcr' => [ 'route_basepath' => '/cms/test', - ), - ), - ), - )); + ], + ], + ], + ]); - $this->assertContainerBuilderHasParameter('cmf_routing.dynamic.persistence.phpcr.route_basepaths', array('/cms/test')); + $this->assertContainerBuilderHasParameter('cmf_routing.dynamic.persistence.phpcr.route_basepaths', ['/cms/test']); } public function testInitializerEnabled() { $this->container->setParameter( 'kernel.bundles', - array( + [ 'CmfRoutingBundle' => true, - ) + ] ); - $this->load(array( - 'dynamic' => array( + $this->load([ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array( - 'phpcr' => array( + 'persistence' => [ + 'phpcr' => [ 'enabled' => true, 'enable_initializer' => true, - ), - ), - ), - )); + ], + ], + ], + ]); $this->assertContainerBuilderHasService('cmf_routing.initializer', GenericInitializer::class); } @@ -307,52 +307,52 @@ public function testInitializerDisabled() { $this->container->setParameter( 'kernel.bundles', - array( + [ 'CmfRoutingBundle' => true, - ) + ] ); - $this->load(array( - 'dynamic' => array( + $this->load([ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array( - 'phpcr' => array( + 'persistence' => [ + 'phpcr' => [ 'enabled' => true, 'enable_initializer' => false, - ), - ), - ), - )); + ], + ], + ], + ]); $this->assertFalse($this->container->has('cmf_routing.initializer')); } public function testSettingCustomRouteClassForOrm() { - $this->load(array( - 'dynamic' => array( + $this->load([ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array( - 'orm' => array( + 'persistence' => [ + 'orm' => [ 'enabled' => true, - ), - ), - ), - )); + ], + ], + ], + ]); $this->assertContainerBuilderHasParameter('cmf_routing.backend_type_orm_default', true); - $this->load(array( - 'dynamic' => array( + $this->load([ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array( - 'orm' => array( + 'persistence' => [ + 'orm' => [ 'enabled' => true, 'route_class' => 'Some\Bundle\CustomBundle\Doctrine\ORM\Route', - ), - ), - ), - )); + ], + ], + ], + ]); $this->assertContainerBuilderHasParameter('cmf_routing.backend_type_orm_custom', true); } diff --git a/tests/Unit/DependencyInjection/Compiler/SetRouterPassTest.php b/tests/Unit/DependencyInjection/Compiler/SetRouterPassTest.php index d36edd2c..7bb852f0 100644 --- a/tests/Unit/DependencyInjection/Compiler/SetRouterPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/SetRouterPassTest.php @@ -11,9 +11,9 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Unit\DependencyInjection\Compiler; +use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler\SetRouterPass; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; class SetRouterPassTest extends AbstractCompilerPassTestCase { diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index a14887f8..3c538ed3 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -11,9 +11,9 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Unit\DependencyInjection; +use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionConfigurationTestCase; use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\CmfRoutingExtension; use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Configuration; -use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionConfigurationTestCase; class ConfigurationTest extends AbstractExtensionConfigurationTestCase { @@ -29,65 +29,65 @@ protected function getConfiguration() public function testSupportsAllConfigFormats() { - $expectedConfiguration = array( - 'chain' => array( - 'routers_by_id' => array( + $expectedConfiguration = [ + 'chain' => [ + 'routers_by_id' => [ 'cmf_routing.router' => 300, 'router.default' => 100, - ), + ], 'replace_symfony_router' => true, - ), - 'dynamic' => array( + ], + 'dynamic' => [ 'route_collection_limit' => 0, 'generic_controller' => 'acme_main.controller:mainAction', - 'controllers_by_type' => array( + 'controllers_by_type' => [ 'editable' => 'acme_main.some_controller:editableAction', - ), - 'controllers_by_class' => array( + ], + 'controllers_by_class' => [ 'Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent' => 'cmf_content.controller:indexAction', - ), - 'templates_by_class' => array( + ], + 'templates_by_class' => [ 'Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent' => 'CmfContentBundle:StaticContent:index.html.twig', - ), - 'persistence' => array( - 'phpcr' => array( + ], + 'persistence' => [ + 'phpcr' => [ 'enabled' => true, - 'route_basepaths' => array( + 'route_basepaths' => [ '/cms/routes', '/simple', - ), + ], 'content_basepath' => '/cms/content', 'manager_name' => null, 'enable_initializer' => true, - ), - 'orm' => array( + ], + 'orm' => [ 'enabled' => false, 'manager_name' => null, 'route_class' => 'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route', - ), - ), + ], + ], 'enabled' => true, 'default_controller' => null, 'uri_filter_regexp' => '', 'route_filters_by_id' => [], - 'locales' => array('en', 'fr'), + 'locales' => ['en', 'fr'], 'limit_candidates' => 20, 'auto_locale_pattern' => true, 'match_implicit_locale' => true, 'url_generator' => 'cmf_routing.generator', - ), - ); + ], + ]; $formats = array_map(function ($path) { return __DIR__.'/../../Resources/Fixtures/'.$path; - }, array( + }, [ 'config/config.yml', 'config/config.xml', 'config/config.php', - )); + ]); foreach ($formats as $format) { - $this->assertProcessedConfigurationEquals($expectedConfiguration, array($format)); + $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } } } diff --git a/tests/Unit/DependencyInjection/XmlSchemaTest.php b/tests/Unit/DependencyInjection/XmlSchemaTest.php index a34b9da1..128d05c6 100644 --- a/tests/Unit/DependencyInjection/XmlSchemaTest.php +++ b/tests/Unit/DependencyInjection/XmlSchemaTest.php @@ -29,13 +29,13 @@ public function testSchema() $fixturesPath = $this->fixturesPath; $xmlFiles = array_map(function ($file) use ($fixturesPath) { return $fixturesPath.$file; - }, array( + }, [ 'config.xml', 'config1.xml', 'config2.xml', 'config3.xml', 'config4.xml', - )); + ]); $this->assertSchemaAcceptsXml($xmlFiles, $this->schemaPath); } diff --git a/tests/Unit/Doctrine/Orm/ContentRepositoryTest.php b/tests/Unit/Doctrine/Orm/ContentRepositoryTest.php index 26da9937..e2fe8b63 100644 --- a/tests/Unit/Doctrine/Orm/ContentRepositoryTest.php +++ b/tests/Unit/Doctrine/Orm/ContentRepositoryTest.php @@ -93,10 +93,10 @@ public function testFindCorrectModelAndId($input, $model, $id) public function getFindCorrectModelAndIdData() { - return array( - array('Acme\ContentBundle\Entity\Content:12', 'Acme\ContentBundle\Entity\Content', 12), - array('Id\Contains\Colon:12:1', 'Id\Contains\Colon', '12:1'), - array('Class\EndsWith\Number12:20', 'Class\EndsWith\Number12', 20), - ); + return [ + ['Acme\ContentBundle\Entity\Content:12', 'Acme\ContentBundle\Entity\Content', 12], + ['Id\Contains\Colon:12:1', 'Id\Contains\Colon', '12:1'], + ['Class\EndsWith\Number12:20', 'Class\EndsWith\Number12', 20], + ]; } } diff --git a/tests/Unit/Doctrine/Orm/RouteProviderTest.php b/tests/Unit/Doctrine/Orm/RouteProviderTest.php index abe66cfb..ca63a031 100644 --- a/tests/Unit/Doctrine/Orm/RouteProviderTest.php +++ b/tests/Unit/Doctrine/Orm/RouteProviderTest.php @@ -61,7 +61,7 @@ public function setUp() $this->managerRegistryMock = $this->createMock(ManagerRegistry::class); $this->objectRepositoryMock = $this->getMockBuilder(EntityRepository::class) ->disableOriginalConstructor() - ->setMethods(array('findByStaticPrefix', 'findOneBy', 'findBy')) + ->setMethods(['findByStaticPrefix', 'findOneBy', 'findBy']) ->getMock(); $this->candidatesMock = $this->createMock(CandidatesInterface::class); $this->candidatesMock @@ -86,7 +86,7 @@ public function setUp() public function testGetRouteCollectionForRequest() { $request = Request::create('/my/path'); - $candidates = array('/my/path', '/my', '/'); + $candidates = ['/my/path', '/my', '/']; $this->candidatesMock ->expects($this->once()) @@ -105,15 +105,15 @@ public function testGetRouteCollectionForRequest() ->method('getName') ->will($this->returnValue('/my')) ; - $objects = array( + $objects = [ $this->routeMock, $this->route2Mock, - ); + ]; $this->objectRepositoryMock ->expects($this->once()) ->method('findByStaticPrefix') - ->with($candidates, array('position' => 'ASC')) + ->with($candidates, ['position' => 'ASC']) ->will($this->returnValue($objects)) ; @@ -150,7 +150,7 @@ public function testGetRouteByName() $this->objectRepositoryMock ->expects($this->any()) ->method('findOneBy') - ->with(array('name' => '/test-route')) + ->with(['name' => '/test-route']) ->will($this->returnValue($this->routeMock)) ; @@ -170,7 +170,7 @@ public function testGetRouteByNameNotFound() $this->objectRepositoryMock ->expects($this->any()) ->method('findOneBy') - ->with(array('name' => '/test-route')) + ->with(['name' => '/test-route']) ->will($this->returnValue(null)) ; @@ -205,21 +205,21 @@ public function testGetRouteByNameNotCandidate() public function testGetRoutesByNames() { - $paths = array( + $paths = [ '/test-route', '/other-route', - ); + ]; $this->objectRepositoryMock ->expects($this->at(0)) ->method('findOneBy') - ->with(array('name' => $paths[0])) + ->with(['name' => $paths[0]]) ->will($this->returnValue($this->routeMock)) ; $this->objectRepositoryMock ->expects($this->at(1)) ->method('findOneBy') - ->with(array('name' => $paths[1])) + ->with(['name' => $paths[1]]) ->will($this->returnValue($this->routeMock)) ; @@ -273,7 +273,7 @@ public function testGetAllRoutes() ->expects($this->once()) ->method('findBy') ->with([], null, 42) - ->will($this->returnValue(array($this->routeMock))) + ->will($this->returnValue([$this->routeMock])) ; $routeProvider = new RouteProvider($this->managerRegistryMock, $this->candidatesMock, 'Route'); diff --git a/tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php b/tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php index 621194f3..6c28621e 100644 --- a/tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php +++ b/tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php @@ -122,10 +122,10 @@ public function testChangingDocumentManager() ->will($this->returnValue($this->document2)) ; - $objectManagers = array( + $objectManagers = [ 'default' => $this->objectManager, 'new_manager' => $this->objectManager2, - ); + ]; $this->managerRegistry ->expects($this->any()) ->method('getManager') diff --git a/tests/Unit/Doctrine/Phpcr/IdPrefixListenerTest.php b/tests/Unit/Doctrine/Phpcr/IdPrefixListenerTest.php index dc75cc7c..95c3e6ff 100644 --- a/tests/Unit/Doctrine/Phpcr/IdPrefixListenerTest.php +++ b/tests/Unit/Doctrine/Phpcr/IdPrefixListenerTest.php @@ -14,8 +14,8 @@ use Doctrine\Common\Persistence\Event\LifecycleEventArgs; use Doctrine\ODM\PHPCR\DocumentManager; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\IdPrefixListener; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\PrefixCandidates; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase; class IdPrefixListenerTest extends CmfUnitTestCase @@ -46,7 +46,7 @@ public function setUp() $this->candidatesMock ->expects($this->any()) ->method('getPrefixes') - ->will($this->returnValue(array('/cms/routes', '/cms/simple'))) + ->will($this->returnValue(['/cms/routes', '/cms/simple'])) ; $this->dmMock = $this->createMock(DocumentManager::class); $this->routeMock = $this->createMock(Route::class); diff --git a/tests/Unit/Doctrine/Phpcr/LocaleListenerTest.php b/tests/Unit/Doctrine/Phpcr/LocaleListenerTest.php index 2a579cda..b02e0368 100644 --- a/tests/Unit/Doctrine/Phpcr/LocaleListenerTest.php +++ b/tests/Unit/Doctrine/Phpcr/LocaleListenerTest.php @@ -11,12 +11,12 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Unit\Doctrine\Phpcr; +use Doctrine\Common\Persistence\Event\LifecycleEventArgs; use Doctrine\ODM\PHPCR\DocumentManager; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\LocaleListener; use Doctrine\ODM\PHPCR\Event\MoveEventArgs; -use Doctrine\Common\Persistence\Event\LifecycleEventArgs; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\LocaleListener; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\PrefixCandidates; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase; class LocaleListenerTest extends CmfUnitTestCase @@ -45,9 +45,9 @@ public function setUp() $this->candidatesMock->expects($this->any()) ->method('getPrefixes') - ->will($this->returnValue(array('/cms/routes', '/cms/simple'))) + ->will($this->returnValue(['/cms/routes', '/cms/simple'])) ; - $this->listener = new LocaleListener($this->candidatesMock, array('en', 'de')); + $this->listener = new LocaleListener($this->candidatesMock, ['en', 'de']); $this->routeMock = $this->createMock(Route::class); $this->dmMock = $this->createMock(DocumentManager::class); } @@ -162,8 +162,8 @@ public function testMoved() public function testSetLocales() { - $this->listener->setLocales(array('xx')); - $this->assertAttributeEquals(array('xx'), 'locales', $this->listener); + $this->listener->setLocales(['xx']); + $this->assertAttributeEquals(['xx'], 'locales', $this->listener); } public function testHaslocale() @@ -257,7 +257,7 @@ public function testAvailableTranslations() $this->dmMock->expects($this->once()) ->method('getLocalesFor') ->with($this->routeMock, true) - ->will($this->returnValue(array('en', 'de', 'fr'))) + ->will($this->returnValue(['en', 'de', 'fr'])) ; $this->routeMock->expects($this->once()) ->method('setRequirement') diff --git a/tests/Unit/Doctrine/Phpcr/PrefixCandidatesTest.php b/tests/Unit/Doctrine/Phpcr/PrefixCandidatesTest.php index 1c5eb272..02b5ded6 100644 --- a/tests/Unit/Doctrine/Phpcr/PrefixCandidatesTest.php +++ b/tests/Unit/Doctrine/Phpcr/PrefixCandidatesTest.php @@ -24,23 +24,23 @@ class PrefixCandidatesTest extends CmfUnitTestCase { public function testAddPrefix() { - $candidates = new PrefixCandidates(array('/routes')); - $this->assertEquals(array('/routes'), $candidates->getPrefixes()); + $candidates = new PrefixCandidates(['/routes']); + $this->assertEquals(['/routes'], $candidates->getPrefixes()); $candidates->addPrefix('/simple'); - $this->assertEquals(array('/routes', '/simple'), $candidates->getPrefixes()); - $candidates->setPrefixes(array('/other')); - $this->assertEquals(array('/other'), $candidates->getPrefixes()); + $this->assertEquals(['/routes', '/simple'], $candidates->getPrefixes()); + $candidates->setPrefixes(['/other']); + $this->assertEquals(['/other'], $candidates->getPrefixes()); } public function testGetCandidates() { $request = Request::create('/my/path.html'); - $candidates = new PrefixCandidates(array('/routes', '/simple')); + $candidates = new PrefixCandidates(['/routes', '/simple']); $paths = $candidates->getCandidates($request); $this->assertEquals( - array( + [ '/routes/my/path.html', '/routes/my/path', '/routes/my', @@ -49,7 +49,7 @@ public function testGetCandidates() '/simple/my/path', '/simple/my', '/simple', - ), + ], $paths ); } @@ -58,11 +58,11 @@ public function testGetCandidatesPercentEncoded() { $request = Request::create('/my/path%20percent%20encoded.html'); - $candidates = new PrefixCandidates(array('/routes', '/simple')); + $candidates = new PrefixCandidates(['/routes', '/simple']); $paths = $candidates->getCandidates($request); $this->assertEquals( - array( + [ '/routes/my/path percent encoded.html', '/routes/my/path percent encoded', '/routes/my', @@ -71,7 +71,7 @@ public function testGetCandidatesPercentEncoded() '/simple/my/path percent encoded', '/simple/my', '/simple', - ), + ], $paths ); } @@ -80,11 +80,11 @@ public function testGetCandidatesLocales() { $request = Request::create('/de/path.html'); - $candidates = new PrefixCandidates(array('/routes', '/simple'), array('de', 'fr')); + $candidates = new PrefixCandidates(['/routes', '/simple'], ['de', 'fr']); $paths = $candidates->getCandidates($request); $this->assertEquals( - array( + [ '/routes/de/path.html', '/routes/de/path', '/routes/de', @@ -97,7 +97,7 @@ public function testGetCandidatesLocales() '/routes/path', '/simple/path.html', '/simple/path', - ), + ], $paths ); } @@ -125,7 +125,7 @@ public function testGetCandidatesLocalesDm() ->will($this->returnValue($localeMock)) ; - $candidates = new PrefixCandidates(array('/simple'), array('de', 'fr'), $managerRegistryMock); + $candidates = new PrefixCandidates(['/simple'], ['de', 'fr'], $managerRegistryMock); $candidates->getCandidates($request); } @@ -138,13 +138,13 @@ public function testGetCandidatesLocalesDmNoLocale() ->method('getManager') ; - $candidates = new PrefixCandidates(array('/simple'), array('de', 'fr'), $managerRegistryMock); + $candidates = new PrefixCandidates(['/simple'], ['de', 'fr'], $managerRegistryMock); $candidates->getCandidates($request); } public function testIsCandidate() { - $candidates = new PrefixCandidates(array('/routes')); + $candidates = new PrefixCandidates(['/routes']); $this->assertTrue($candidates->isCandidate('/routes')); $this->assertTrue($candidates->isCandidate('/routes/my/path')); $this->assertFalse($candidates->isCandidate('/other/my/path')); @@ -174,7 +174,7 @@ public function testRestrictQuery() ->will($this->returnValue('d')) ; - $candidates = new PrefixCandidates(array('/routes')); + $candidates = new PrefixCandidates(['/routes']); $candidates->restrictQuery($qb); } @@ -185,7 +185,7 @@ public function testRestrictQueryGlobal() ->method('andWhere') ; - $candidates = new PrefixCandidates(array('/routes', '', '/other')); + $candidates = new PrefixCandidates(['/routes', '', '/other']); $candidates->restrictQuery($qb); } } diff --git a/tests/Unit/Doctrine/Phpcr/RouteProviderTest.php b/tests/Unit/Doctrine/Phpcr/RouteProviderTest.php index 4f9bdb7e..63654717 100644 --- a/tests/Unit/Doctrine/Phpcr/RouteProviderTest.php +++ b/tests/Unit/Doctrine/Phpcr/RouteProviderTest.php @@ -11,16 +11,16 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Unit\Doctrine\Phpcr; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Persistence\ManagerRegistry; +use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; use Doctrine\ODM\PHPCR\Query\Builder\SourceFactory; use Doctrine\ODM\PHPCR\Query\Query; use Doctrine\ODM\PHPCR\UnitOfWork; use PHPCR\Util\UUIDHelper; -use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Persistence\ManagerRegistry; -use Doctrine\ODM\PHPCR\DocumentManager; -use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RouteProvider; use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\PrefixCandidates; +use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RouteProvider; use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Route; @@ -76,7 +76,7 @@ public function setUp() public function testGetRouteCollectionForRequest() { $request = Request::create('/my/path'); - $candidates = array('/prefix/my/path', '/prefix/my'); + $candidates = ['/prefix/my/path', '/prefix/my']; $this->candidatesMock ->expects($this->once()) @@ -85,10 +85,10 @@ public function testGetRouteCollectionForRequest() ->will($this->returnValue($candidates)) ; - $objects = array( + $objects = [ new Route('/my'), $this, - ); + ]; $this->dmMock ->expects($this->once()) @@ -329,11 +329,11 @@ public function testGetRouteByNameNoRoute() public function testGetRoutesByNames() { - $paths = array( + $paths = [ '/cms/routes/test-route', '/cms/simple/other-route', '/cms/routes/not-a-route', - ); + ]; $routes = new ArrayCollection(); $routes->set('/cms/routes/test-route', new Route('/test-route')); @@ -383,11 +383,11 @@ public function testGetRoutesByNames() public function testGetRoutesByNamesNotCandidates() { - $paths = array( + $paths = [ '/cms/routes/test-route', '/cms/simple/other-route', '/cms/routes/not-a-route', - ); + ]; $this->dmMock ->expects($this->never()) @@ -424,10 +424,10 @@ public function testGetRoutesByNamesUuid() { $uuid1 = UUIDHelper::generateUUID(); $uuid2 = UUIDHelper::generateUUID(); - $paths = array( + $paths = [ $uuid1, $uuid2, - ); + ]; $route1 = new Route('/test-route'); $route2 = new Route('/other-route'); @@ -593,10 +593,10 @@ public function testChangingDocumentManager() ->will($this->returnValue($this->route2Mock)) ; - $objectManagers = array( + $objectManagers = [ 'default' => $this->dmMock, 'new_manager' => $this->dm2Mock, - ); + ]; $this->managerRegistryMock = $this->createMock(ManagerRegistry::class); $this->managerRegistryMock ->expects($this->any()) diff --git a/tests/Unit/Doctrine/Phpcr/RouteTest.php b/tests/Unit/Doctrine/Phpcr/RouteTest.php index e938b9a2..60295462 100644 --- a/tests/Unit/Doctrine/Phpcr/RouteTest.php +++ b/tests/Unit/Doctrine/Phpcr/RouteTest.php @@ -32,10 +32,10 @@ public function testGetRouteChildren() $refl = new \ReflectionClass($this->route); $prop = $refl->getProperty('children'); $prop->setAccessible(true); - $prop->setValue($this->route, array( + $prop->setValue($this->route, [ new \stdClass(), $this->childRoute1, - )); + ]); $res = $this->route->getRouteChildren(); $this->assertCount(1, $res); diff --git a/tests/Unit/Form/Type/RouteTypeTypeTest.php b/tests/Unit/Form/Type/RouteTypeTypeTest.php index 15da90c6..c970bb33 100644 --- a/tests/Unit/Form/Type/RouteTypeTypeTest.php +++ b/tests/Unit/Form/Type/RouteTypeTypeTest.php @@ -46,13 +46,13 @@ public function testDefaultsSet() $optionsResolver = $this->createMock(OptionsResolver::class); $optionsResolver->expects($this->once()) ->method('setDefaults') - ->with(array( - 'choices' => array( + ->with([ + 'choices' => [ 'foobar' => 'route_type.foobar', 'barfoo' => 'route_type.barfoo', - ), + ], 'translation_domain' => 'CmfRoutingBundle', - )); + ]); $this->type->configureOptions($optionsResolver); } diff --git a/tests/Unit/Routing/DynamicRouterTest.php b/tests/Unit/Routing/DynamicRouterTest.php index b630c234..74846fa8 100644 --- a/tests/Unit/Routing/DynamicRouterTest.php +++ b/tests/Unit/Routing/DynamicRouterTest.php @@ -11,13 +11,13 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Unit\Routing; +use Symfony\Cmf\Bundle\RoutingBundle\Routing\DynamicRouter; use Symfony\Cmf\Component\Routing\Event\Events; use Symfony\Cmf\Component\Routing\Event\RouterMatchEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\RouteObjectInterface; -use Symfony\Cmf\Bundle\RoutingBundle\Routing\DynamicRouter; use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; use Symfony\Component\Routing\RequestContext; @@ -41,7 +41,7 @@ public function setUp() $this->matcher->expects($this->once()) ->method('match') ->with('/foo') - ->will($this->returnValue(array('foo' => 'bar', RouteObjectInterface::CONTENT_OBJECT => 'bla', RouteObjectInterface::TEMPLATE_NAME => 'template'))) + ->will($this->returnValue(['foo' => 'bar', RouteObjectInterface::CONTENT_OBJECT => 'bla', RouteObjectInterface::TEMPLATE_NAME => 'template'])) ; $this->generator = $this->createMock(UrlGeneratorInterface::class); @@ -72,7 +72,7 @@ public function testMatch() ; $parameters = $this->router->match('/foo'); - $this->assertEquals(array('foo' => 'bar'), $parameters); + $this->assertEquals(['foo' => 'bar'], $parameters); $this->assertRequestAttributes($this->request); } @@ -85,7 +85,7 @@ public function testMatchRequest() ; $parameters = $this->router->matchRequest($this->request); - $this->assertEquals(array('foo' => 'bar'), $parameters); + $this->assertEquals(['foo' => 'bar'], $parameters); $this->assertRequestAttributes($this->request); } @@ -112,7 +112,7 @@ public function testEventOptional() $router = new DynamicRouter($this->context, $this->matcher, $this->generator); $parameters = $router->matchRequest($this->request); - $this->assertEquals(array('foo' => 'bar'), $parameters); + $this->assertEquals(['foo' => 'bar'], $parameters); $this->assertRequestAttributes($this->request); } diff --git a/tests/Unit/Validator/Constraints/RouteDefaultsValidatorTest.php b/tests/Unit/Validator/Constraints/RouteDefaultsValidatorTest.php index 5d9246c2..44c03d34 100644 --- a/tests/Unit/Validator/Constraints/RouteDefaultsValidatorTest.php +++ b/tests/Unit/Validator/Constraints/RouteDefaultsValidatorTest.php @@ -11,11 +11,11 @@ namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\Admin; +use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Cmf\Bundle\RoutingBundle\Validator\Constraints\RouteDefaults; use Symfony\Cmf\Bundle\RoutingBundle\Validator\Constraints\RouteDefaultsValidator; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; class RouteDefaultsValidatorTest extends AbstractConstraintValidatorTest { @@ -37,7 +37,7 @@ protected function createValidator() public function testCorrectControllerPath() { - $this->validator->validate(array('_controller' => 'FrameworkBundle:Redirect:redirect'), new RouteDefaults()); + $this->validator->validate(['_controller' => 'FrameworkBundle:Redirect:redirect'], new RouteDefaults()); $this->assertNoViolation(); } @@ -49,7 +49,7 @@ public function testControllerPathViolation() ->will($this->throwException(new \LogicException('Invalid controller'))) ; - $this->validator->validate(array('_controller' => 'NotExistingBundle:Foo:bar'), new RouteDefaults()); + $this->validator->validate(['_controller' => 'NotExistingBundle:Foo:bar'], new RouteDefaults()); $this->buildViolation('Invalid controller')->assertRaised(); } @@ -61,7 +61,7 @@ public function testCorrectTemplate() ->will($this->returnValue(true)) ; - $this->validator->validate(array('_template' => 'TwigBundle::layout.html.twig'), $this->constraint); + $this->validator->validate(['_template' => 'TwigBundle::layout.html.twig'], $this->constraint); $this->assertNoViolation(); } @@ -76,8 +76,8 @@ public function testTemplateViolation() ; $this->validator->validate( - array('_template' => 'NotExistingBundle:Foo:bar.html.twig'), - new RouteDefaults(array('message' => 'my message')) + ['_template' => 'NotExistingBundle:Foo:bar.html.twig'], + new RouteDefaults(['message' => 'my message']) ); $this->buildViolation('my message')