From 305d72d8182b0810f260fb473f1e8bd188578bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Sat, 8 Dec 2018 18:21:12 +0100 Subject: [PATCH 01/15] Allow EAB 2.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2721a092..7df82acc 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "doctrine/common": "^2.4", "doctrine/doctrine-bundle": "~1.2", "doctrine/orm": "~2.3", - "easycorp/easyadmin-bundle": "^1.17", + "easycorp/easyadmin-bundle": "^2.0", "symfony/config": "~3.0|^4.0", "symfony/dependency-injection": "~3.0|^4.0", "symfony/event-dispatcher": "~3.0|^4.0", From 3200feede57c0b07360d59cdaf70b609ec7139de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Sun, 9 Dec 2018 16:09:17 +0100 Subject: [PATCH 02/15] Use FormTypeHelper insteadof LegacyFormHelper --- src/Configuration/ShortFormTypeConfigPass.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Configuration/ShortFormTypeConfigPass.php b/src/Configuration/ShortFormTypeConfigPass.php index 11df2df0..459dea91 100644 --- a/src/Configuration/ShortFormTypeConfigPass.php +++ b/src/Configuration/ShortFormTypeConfigPass.php @@ -5,7 +5,7 @@ use AlterPHP\EasyAdminExtensionBundle\Form\Type\EasyAdminEmbeddedListType; use AlterPHP\EasyAdminExtensionBundle\Form\Type\Security\AdminRolesType; use EasyCorp\Bundle\EasyAdminBundle\Configuration\ConfigPassInterface; -use EasyCorp\Bundle\EasyAdminBundle\Form\Util\LegacyFormHelper; +use EasyCorp\Bundle\EasyAdminBundle\Form\Util\FormTypeHelper; use Symfony\Component\PropertyAccess\PropertyAccess; /** @@ -70,7 +70,7 @@ private function replaceShortFormTypesInObjectConfig(array $objectConfig) if (\array_key_exists($field['type'], $shortFormTypes)) { $configPathItem[$name]['type'] = $shortFormTypes[$field['type']]; } elseif (self::isLegacyEasyAdminFormShortType($field['type'])) { - $configPathItem[$name]['type'] = LegacyFormHelper::getType($field['type']); + $configPathItem[$name]['type'] = FormTypeHelper::getTypeClass($field['type']); } } @@ -85,7 +85,7 @@ private function replaceShortFormTypesInObjectConfig(array $objectConfig) private static function isLegacyEasyAdminFormShortType(string $shortType) { - $legacyEasyAdminMatchingType = LegacyFormHelper::getType($shortType); + $legacyEasyAdminMatchingType = FormTypeHelper::getTypeClass($shortType); return \class_exists($legacyEasyAdminMatchingType); } From 4698a74af29c37f8b4ac424e63617197e9d2fa02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Sun, 9 Dec 2018 16:12:29 +0100 Subject: [PATCH 03/15] form template is bootstrap_4 --- src/Resources/views/default/list.html.twig | 2 +- src/Resources/views/form/bootstrap_3_layout.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/views/default/list.html.twig b/src/Resources/views/default/list.html.twig index 79adc383..378a16c8 100644 --- a/src/Resources/views/default/list.html.twig +++ b/src/Resources/views/default/list.html.twig @@ -78,7 +78,7 @@
- {% form_theme list_form_filters '@EasyAdmin/form/bootstrap_3_layout.html.twig' %} + {% form_theme list_form_filters '@EasyAdmin/form/bootstrap_4.html.twig' %} {{ block('request_parameters_as_hidden') }} diff --git a/src/Resources/views/form/bootstrap_3_layout.html.twig b/src/Resources/views/form/bootstrap_3_layout.html.twig index 051f14c5..c9a770c7 100644 --- a/src/Resources/views/form/bootstrap_3_layout.html.twig +++ b/src/Resources/views/form/bootstrap_3_layout.html.twig @@ -1,4 +1,4 @@ -{% use '@BaseEasyAdmin/form/bootstrap_3_layout.html.twig' %} +{% use '@BaseEasyAdmin/form/bootstrap_4.html.twig' %} {% block easyadmin_embedded_list_row %} {% set default_filters = entity_fqcn is defined From 307c23cd46022064626c476b012c673bc62fb66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Mon, 10 Dec 2018 12:32:39 +0100 Subject: [PATCH 04/15] Resolve aliased service subscription --- src/Controller/AdminController.php | 18 +++++++++++++----- src/Resources/config/services.xml | 8 +++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 5d080f1d..9ca87f65 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -2,12 +2,22 @@ namespace AlterPHP\EasyAdminExtensionBundle\Controller; -use EasyCorp\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController; +use AlterPHP\EasyAdminExtensionBundle\Security\AdminAuthorizationChecker; +use EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController; use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; use Symfony\Component\HttpFoundation\JsonResponse; -class AdminController extends BaseAdminController +class AdminController extends EasyAdminController { + + public static function getSubscribedServices(): array + { + return array_merge( + parent::getSubscribedServices(), + ['admin_authorization_checker' => AdminAuthorizationChecker::class] + ); + } + protected function embeddedListAction() { $this->dispatch(EasyAdminEvents::PRE_LIST); @@ -49,9 +59,7 @@ protected function isActionAllowed($actionName) // Get item for edit/show or custom actions => security voters may apply $easyadmin = $this->request->attributes->get('easyadmin'); $subject = $easyadmin['item'] ?? null; - $this->get('alterphp.easyadmin_extension.admin_authorization_checker')->checksUserAccess( - $this->entity, $actionName, $subject - ); + $this->get('admin_authorization_checker')->checksUserAccess($this->entity, $actionName, $subject); return parent::isActionAllowed($actionName); } diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index b666f2e8..48f82073 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -4,6 +4,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> + + + @@ -62,10 +67,11 @@ - + %easy_admin_extension.minimum_role% + From 628de17fdd59a7cf4fc5001aeb6fa2d6480feeca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Mon, 10 Dec 2018 12:33:33 +0100 Subject: [PATCH 05/15] TODO lists --- TODO-UPGRADE-EAB2.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 TODO-UPGRADE-EAB2.md diff --git a/TODO-UPGRADE-EAB2.md b/TODO-UPGRADE-EAB2.md new file mode 100644 index 00000000..e69de29b From dcdfc44c8515213423616567ae165f0c39c50107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Mon, 10 Dec 2018 12:48:15 +0100 Subject: [PATCH 06/15] Fix Travis CI --- .travis.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 261d4afd..3bc988d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,19 +30,6 @@ matrix: env: - SYMFONY_VERSION="4.1.*" - TWIG_VERSION="^2.4" - # Symfony 4 - - php: 7.1 - env: - - SYMFONY_VERSION="4.0.*" - - STABILITY=beta - # Deprecations breaks CI (sensio frameworkextrabundle + sf 4.1) - # - SYMFONY_DEPRECATIONS_HELPER="strict" - # Symfony 3 LTS - - php: 7.0 - env: - - SYMFONY_VERSION="3.4.*" - - TWIG_VERSION="1.x-dev" - # Only 7.0 php images on Travis have xdebug enabled - ENABLE_CODE_COVERAGE="true" allow_failures: # code coverage is very slow; allow a failure to get the Travis result early From c56d2f40a332180ec0a3dfb7fa43fb05ad911cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Mon, 10 Dec 2018 12:52:42 +0100 Subject: [PATCH 07/15] remove old config case --- tests/Fixtures/App/AppKernel.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/tests/Fixtures/App/AppKernel.php b/tests/Fixtures/App/AppKernel.php index 3f1bfeb6..230752b7 100644 --- a/tests/Fixtures/App/AppKernel.php +++ b/tests/Fixtures/App/AppKernel.php @@ -40,18 +40,6 @@ public function registerContainerConfiguration(LoaderInterface $loader) 'assets' => null, )); }); - - if ($this->requiresLogoutOnUserChange()) { - $loader->load(function (ContainerBuilder $container) { - $container->loadFromExtension('security', array( - 'firewalls' => array( - 'secured_area' => array( - 'logout_on_user_change' => true, - ), - ), - )); - }); - } } /** @@ -69,9 +57,4 @@ public function getLogDir() { return __DIR__.'/../../../build/kernel_logs/'.$this->getEnvironment(); } - - protected function requiresLogoutOnUserChange() - { - return Kernel::VERSION_ID >= 30400 && Kernel::VERSION_ID < 40100; - } } From ab3b3d22b10c20edb28d5ce0ffc99720014ebf52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Mon, 10 Dec 2018 13:54:18 +0100 Subject: [PATCH 08/15] sort array syntax --- .php_cs | 9 +- debug.txt | 1548 +++++++++++++++++ .../EmbeddedListViewConfigPass.php | 4 +- src/Configuration/ExcludeFieldsConfigPass.php | 2 +- .../ListFormFiltersConfigPass.php | 34 +- src/Configuration/ShortFormTypeConfigPass.php | 10 +- src/Configuration/ShowViewConfigPass.php | 4 +- src/Controller/AdminController.php | 11 +- .../Compiler/TwigPathPass.php | 4 +- src/EasyAdminExtensionBundle.php | 4 +- .../PostQueryBuilderSubscriber.php | 18 +- .../Transformer/RestoreRolesTransformer.php | 2 +- src/Form/Type/EasyAdminEmbeddedListType.php | 2 +- .../EasyAdminAutocompleteTypeExtension.php | 4 +- src/Form/Type/Security/AdminRolesType.php | 6 +- src/Helper/EditableRolesHelper.php | 4 +- src/Helper/ListFormFiltersHelper.php | 4 +- src/Model/AdminGroup.php | 2 +- src/Model/AdminUser.php | 2 +- src/Resources/config/services.xml | 4 +- src/Twig/AdminAuthorizationExtension.php | 14 +- src/Twig/CheckboxTreeExtension.php | 12 +- src/Twig/EmbeddedListExtension.php | 12 +- src/Twig/ListFormFiltersExtension.php | 6 +- .../CustomFormTypeConfigPassTest.php | 120 +- .../EmbeddedListViewConfigPassTest.php | 56 +- .../ExcludeFieldsConfigPassTest.php | 58 +- .../Configuration/ShowViewConfigPassTest.php | 130 +- tests/Controller/AutocompleteAddTest.php | 6 +- tests/Controller/EmbeddedListTest.php | 36 +- tests/Controller/ListFormFiltersTest.php | 6 +- tests/Controller/RequestParametersTest.php | 22 +- tests/Controller/UserRolesTest.php | 22 +- tests/Fixtures/AbstractTestCase.php | 43 +- tests/Fixtures/App/AppKernel.php | 10 +- .../App/DynamicConfigLoadingKernel.php | 2 +- .../App/config/{config.yml => config.yaml} | 5 +- ...e_add.yml => config_autocomplete_add.yaml} | 2 +- ...tom_types.yml => config_custom_types.yaml} | 2 +- ...ackend.yml => config_default_backend.yaml} | 2 +- ...ded_list.yml => config_embedded_list.yaml} | 2 +- ...ters.yml => config_list_form_filters.yaml} | 2 +- tests/Fixtures/App/config/config_test.yaml | 2 + tests/Fixtures/App/config/config_test.yml | 2 - ..._user_roles.yml => config_user_roles.yaml} | 2 +- .../{routing_base.yml => routing_base.yaml} | 0 tests/Fixtures/App/config/services.yaml | 4 + .../DataFixtures/ORM/LoadAdminGroups.php | 4 +- .../DataFixtures/ORM/LoadAdminUsers.php | 6 +- .../DataFixtures/ORM/LoadCategories.php | 4 +- .../DataFixtures/ORM/LoadProducts.php | 54 +- .../DataFixtures/ORM/LoadPurchases.php | 28 +- .../DataFixtures/ORM/LoadUsers.php | 2 +- .../Entity/FunctionalTests/Dummy.php | 4 +- .../Entity/FunctionalTests/Product.php | 10 +- .../Entity/FunctionalTests/Purchase.php | 4 +- .../RestoreRolesTransformerTest.php | 44 +- tests/Helper/EditableRolesHelperTest.php | 48 +- tests/Helper/MenuHelperTest.php | 135 +- tests/Model/AdminUserTest.php | 8 +- tests/bootstrap.php | 16 +- 61 files changed, 2093 insertions(+), 532 deletions(-) create mode 100644 debug.txt rename tests/Fixtures/App/config/{config.yml => config.yaml} (96%) rename tests/Fixtures/App/config/{config_autocomplete_add.yml => config_autocomplete_add.yaml} (93%) rename tests/Fixtures/App/config/{config_custom_types.yml => config_custom_types.yaml} (93%) rename tests/Fixtures/App/config/{config_default_backend.yml => config_default_backend.yaml} (92%) rename tests/Fixtures/App/config/{config_embedded_list.yml => config_embedded_list.yaml} (97%) rename tests/Fixtures/App/config/{config_list_form_filters.yml => config_list_form_filters.yaml} (94%) create mode 100644 tests/Fixtures/App/config/config_test.yaml delete mode 100644 tests/Fixtures/App/config/config_test.yml rename tests/Fixtures/App/config/{config_user_roles.yml => config_user_roles.yaml} (98%) rename tests/Fixtures/App/config/{routing_base.yml => routing_base.yaml} (100%) create mode 100644 tests/Fixtures/App/config/services.yaml diff --git a/.php_cs b/.php_cs index c56d289a..949d2acb 100644 --- a/.php_cs +++ b/.php_cs @@ -12,11 +12,12 @@ return PhpCsFixer\Config::create() ->setUsingCache(true) ->setRiskyAllowed(true) ->setFinder($finder) - ->setRules(array( + ->setRules([ '@Symfony' => true, - 'binary_operator_spaces' => array( + 'array_syntax' => ['syntax' => 'short'], + 'binary_operator_spaces' => [ 'align_double_arrow' => false, - ), + ], 'combine_consecutive_unsets' => true, 'no_useless_else' => true, 'no_useless_return' => true, @@ -25,5 +26,5 @@ return PhpCsFixer\Config::create() 'phpdoc_summary' => false, 'strict_comparison' => false, 'native_function_invocation'=> true - )) + ]) ; diff --git a/debug.txt b/debug.txt new file mode 100644 index 00000000..b7ed310c --- /dev/null +++ b/debug.txt @@ -0,0 +1,1548 @@ +Created database /app/tests/Fixtures/App/../../../build/test.db for connection named default + + !  + ! [CAUTION] This operation should not be executed in a production environment!  + !  + + Creating database schema... + +  + [OK] Database schema created successfully!  +  + + > purging database + > loading [10] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadAdminGroups + > loading [10] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadUsers + > loading [11] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadAdminUsers + > loading [20] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\ORM\LoadCategories + > loading [100] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadProducts + > loading [200] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadPurchases +PHPUnit 5.7.27 by Sebastian Bergmann and contributors. + +.......F + + + + + + You have requested a non-existent service "admin_authorization_checker". Did you mean this: "security.authorization_checker"? (500 Internal Server Error) + + + + + + +
+
+

+ Symfony Exception

+ + + + +
+
+ +
+ + +
+
+

You have requested a non-existent service "admin_authorization_checker". Did you mean this: "security.authorization_checker"?

+ +
+ + +
+
+
+
+ +
+
+
+

+ Exception +

+ +
+
+
+
+ +

+ + + + + + + Symfony\Component\DependencyInjection\Exception\ + + ServiceNotFoundException +

+ +
+
+ +
+
+
+ + + + + + + + + in + vendor/symfony/dependency-injection/Container.php (line 277) + +
+
+
  1.                 if ($lev <= \strlen($id) / || false !== strpos($knownId$id)) {
  2. +
  3.                     $alternatives[] = $knownId;
  4. +
  5.                 }
  6. +
  7.             }
  8. +
  9. +
  10.             throw new ServiceNotFoundException($idnullnull$alternatives);
  11. +
  12.         }
  13. +
  14.     }
  15. +
  16. +
  17.     /**
  18. +
  19.      * Returns true if the given service has actually been initialized.
+
+ +
+
+
+ + + + + + + + + in + vendor/symfony/dependency-injection/Container.php->make (line 225) + +
+
+
  1.      */
  2. +
  3.     public function get($id$invalidBehavior /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
  4. +
  5.     {
  6. +
  7.         return $this->services[$id]
  8. +
  9.             ?? $this->services[$id $this->aliases[$id] ?? $id]
  10. +
  11.             ?? ('service_container' === $id $this : ($this->factories[$id] ?? array($this'make'))($id$invalidBehavior));
  12. +
  13.     }
  14. +
  15. +
  16.     /**
  17. +
  18.      * Creates a service.
  19. +
  20.      *
+
+ +
+
+
+ + + + + + + + + in + vendor/symfony/framework-bundle/Controller/ControllerTrait.php->get (line 66) + +
+
+
  1.      *
  2. +
  3.      * @final
  4. +
  5.      */
  6. +
  7.     protected function get(string $id)
  8. +
  9.     {
  10. +
  11.         return $this->container->get($id);
  12. +
  13.     }
  14. +
  15. +
  16.     /**
  17. +
  18.      * Generates a URL from the given parameters.
  19. +
  20.      *
+
+ +
+
+
+ + + + + + AbstractController->get('admin_authorization_checker') + + + + in + src/Controller/AdminController.php (line 62) + +
+
+
  1.         }
  2. +
  3. +
  4.         // Get item for edit/show or custom actions => security voters may apply
  5. +
  6.         $easyadmin $this->request->attributes->get('easyadmin');
  7. +
  8.         $subject $easyadmin['item'] ?? null;
  9. +
  10.         $this->get('admin_authorization_checker')->checksUserAccess($this->entity$actionName$subject);
  11. +
  12. +
  13.         return parent::isActionAllowed($actionName);
  14. +
  15.     }
  16. +
  17. +
  18.     /**
+
+ +
+
+
+ + + + + + + + + in + vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php->isActionAllowed (line 65) + +
+
+
  1.         if (null === $request->query->get('entity')) {
  2. +
  3.             return $this->redirectToBackendHomepage();
  4. +
  5.         }
  6. +
  7. +
  8.         $action $request->query->get('action''list');
  9. +
  10.         if (!$this->isActionAllowed($action)) {
  11. +
  12.             throw new ForbiddenActionException(['action' => $action'entity_name' => $this->entity['name']]);
  13. +
  14.         }
  15. +
  16. +
  17.         return $this->executeDynamicMethod($action.'<EntityName>Action');
  18. +
  19.     }
+
+ +
+
+
+ + + + + + + + + in + vendor/symfony/http-kernel/HttpKernel.php->indexAction (line 150) + +
+
+
  1.         $this->dispatcher->dispatch(KernelEvents::CONTROLLER_ARGUMENTS$event);
  2. +
  3.         $controller $event->getController();
  4. +
  5.         $arguments $event->getArguments();
  6. +
  7. +
  8.         // call controller
  9. +
  10.         $response $controller(...$arguments);
  11. +
  12. +
  13.         // view
  14. +
  15.         if (!$response instanceof Response) {
  16. +
  17.             $event = new GetResponseForControllerResultEvent($this$request$type$response);
  18. +
  19.             $this->dispatcher->dispatch(KernelEvents::VIEW$event);
+
+ +
+
+
+ + + + + + + + + in + vendor/symfony/http-kernel/HttpKernel.php->handleRaw (line 67) + +
+
+
  1.     public function handle(Request $request$type HttpKernelInterface::MASTER_REQUEST$catch true)
  2. +
  3.     {
  4. +
  5.         $request->headers->set('X-Php-Ob-Level'ob_get_level());
  6. +
  7. +
  8.         try {
  9. +
  10.             return $this->handleRaw($request$type);
  11. +
  12.         } catch (\Exception $e) {
  13. +
  14.             if ($e instanceof RequestExceptionInterface) {
  15. +
  16.                 $e = new BadRequestHttpException($e->getMessage(), $e);
  17. +
  18.             }
  19. +
  20.             if (false === $catch) {
+
+ +
+
+
+ + + + + + + + + in + vendor/symfony/http-kernel/Kernel.php->handle (line 198) + +
+
+
  1.         $this->boot();
  2. +
  3.         ++$this->requestStackSize;
  4. +
  5.         $this->resetServices true;
  6. +
  7. +
  8.         try {
  9. +
  10.             return $this->getHttpKernel()->handle($request$type$catch);
  11. +
  12.         } finally {
  13. +
  14.             --$this->requestStackSize;
  15. +
  16.         }
  17. +
  18.     }
  19. +
+
+ +
+
+
+ + + + + + + + + in + vendor/symfony/http-kernel/Client.php->handle (line 68) + +
+
+
  1.      *
  2. +
  3.      * @return Response A Response instance
  4. +
  5.      */
  6. +
  7.     protected function doRequest($request)
  8. +
  9.     {
  10. +
  11.         $response $this->kernel->handle($requestHttpKernelInterface::MASTER_REQUEST$this->catchExceptions);
  12. +
  13. +
  14.         if ($this->kernel instanceof TerminableInterface) {
  15. +
  16.             $this->kernel->terminate($request$response);
  17. +
  18.         }
  19. +
+
+ +
+
+
+ + + + + + + + + in + vendor/symfony/framework-bundle/Client.php->doRequest (line 131) + +
+
+
  1. +
  2.             $this->kernel->boot();
  3. +
  4.             $this->kernel->getContainer()->get('profiler')->enable();
  5. +
  6.         }
  7. +
  8. +
  9.         return parent::doRequest($request);
  10. +
  11.     }
  12. +
  13. +
  14.     /**
  15. +
  16.      * {@inheritdoc}
  17. +
  18.      *
+
+ +
+
+
+ + + + + + + + + in + vendor/symfony/browser-kit/Client.php->doRequest (line 405) + +
+
+
  1.         }
  2. +
  3. +
  4.         if ($this->insulated) {
  5. +
  6.             $this->response $this->doRequestInProcess($this->request);
  7. +
  8.         } else {
  9. +
  10.             $this->response $this->doRequest($this->request);
  11. +
  12.         }
  13. +
  14. +
  15.         $this->internalResponse $this->filterResponse($this->response);
  16. +
  17. +
  18.         $this->cookieJar->updateFromResponse($this->internalResponse$uri);
+
+ +
+
+
+ + + + + + Client->request('GET', 'http://localhost/admin/?action=new&entity=Product') + + + + in + tests/Fixtures/AbstractTestCase.php (line 64) + +
+
+
  1.      *
  2. +
  3.      * @return Crawler
  4. +
  5.      */
  6. +
  7.     protected function getBackendPage(array $queryParameters = [])
  8. +
  9.     {
  10. +
  11.         return $this->client->request('GET''/admin/?'.http_build_query($queryParameters'''&'));
  12. +
  13.     }
  14. +
  15. +
  16.     /**
  17. +
  18.      * @return Crawler
  19. +
  20.      */
+
+ +
+
+
+ + + + + + AbstractTestCase->getBackendPage(array('action' => 'new', 'entity' => 'Product')) + + + + in + tests/Fixtures/AbstractTestCase.php (line 121) + +
+
+
  1.      */
  2. +
  3.     protected function requestNewView($entityName 'Category')
  4. +
  5.     {
  6. +
  7.         return $this->getBackendPage(array(
  8. +
  9.             'action' => 'new',
  10. +
  11.             'entity' => $entityName,
  12. +
  13.         ));
  14. +
  15.     }
  16. +
  17. +
  18.     /**
  19. +
  20.      * @return Crawler
+
+ +
+
+
+ + + + + + AbstractTestCase->requestNewView('Product') + + + + in + tests/Controller/AutocompleteAddTest.php (line 18) + +
+
+
  1.         $this->initClient(array('environment' => 'autocomplete_add'));
  2. +
  3.     }
  4. +
  5. +
  6.     public function testNewEntityAutocompleteModal()
  7. +
  8.     {
  9. +
  10.         $crawler $this->requestNewView('Product');
  11. +
  12. +
  13.         if (200 !== $this->client->getResponse()->getStatusCode()) {
  14. +
  15.             echo $this->client->getResponse()->getContent();
  16. +
  17.         }
  18. +
+
+ +
+
+
+ + AutocompleteAddTest->testNewEntityAutocompleteModal() + +
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/src/Framework/TestCase.php->invokeArgs (line 1062) + +
+
+
  1.         $testArguments array_merge($this->data$this->dependencyInput);
  2. +
  3. +
  4.         $this->registerMockObjectsFromTestArguments($testArguments);
  5. +
  6. +
  7.         try {
  8. +
  9.             $testResult $method->invokeArgs($this$testArguments);
  10. +
  11.         } catch (Throwable $_e) {
  12. +
  13.             $e $_e;
  14. +
  15.         } catch (Exception $_e) {
  16. +
  17.             $e $_e;
  18. +
  19.         }
+
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/src/Framework/TestCase.php->runTest (line 913) + +
+
+
  1.             foreach ($hookMethods['before'] as $method) {
  2. +
  3.                 $this->$method();
  4. +
  5.             }
  6. +
  7. +
  8.             $this->assertPreConditions();
  9. +
  10.             $this->testResult $this->runTest();
  11. +
  12.             $this->verifyMockObjects();
  13. +
  14.             $this->assertPostConditions();
  15. +
  16. +
  17.             if (!empty($this->warnings)) {
  18. +
  19.                 throw new PHPUnit_Framework_Warning(
+
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/src/Framework/TestResult.php->runBare (line 686) + +
+
+
  1.                 }
  2. +
  3. +
  4.                 $invoker = new PHP_Invoker;
  5. +
  6.                 $invoker->invoke([$test'runBare'], [], $_timeout);
  7. +
  8.             } else {
  9. +
  10.                 $test->runBare();
  11. +
  12.             }
  13. +
  14.         } catch (PHP_Invoker_TimeoutException $e) {
  15. +
  16.             $this->addFailure(
  17. +
  18.                 $test,
  19. +
  20.                 new PHPUnit_Framework_RiskyTestError(
+
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/src/Framework/TestCase.php->run (line 868) + +
+
+
  1.             $this->prepareTemplate($template);
  2. +
  3. +
  4.             $php PHPUnit_Util_PHP::factory();
  5. +
  6.             $php->runTestJob($template->render(), $this$result);
  7. +
  8.         } else {
  9. +
  10.             $result->run($this);
  11. +
  12.         }
  13. +
  14. +
  15.         if (isset($oldErrorHandlerSetting)) {
  16. +
  17.             $result->convertErrorsToExceptions($oldErrorHandlerSetting);
  18. +
  19.         }
+
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/src/Framework/TestSuite.php->run (line 733) + +
+
+
  1.                 $test->setBackupGlobals($this->backupGlobals);
  2. +
  3.                 $test->setBackupStaticAttributes($this->backupStaticAttributes);
  4. +
  5.                 $test->setRunTestInSeparateProcess($this->runTestInSeparateProcess);
  6. +
  7.             }
  8. +
  9. +
  10.             $test->run($result);
  11. +
  12.         }
  13. +
  14. +
  15.         foreach ($hookMethods['afterClass'] as $afterClassMethod) {
  16. +
  17.             if ($this->testCase === true && class_exists($this->namefalse) && method_exists($this->name$afterClassMethod)) {
  18. +
  19.                 call_user_func([$this->name$afterClassMethod]);
+
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/src/Framework/TestSuite.php->run (line 733) + +
+
+
  1.                 $test->setBackupGlobals($this->backupGlobals);
  2. +
  3.                 $test->setBackupStaticAttributes($this->backupStaticAttributes);
  4. +
  5.                 $test->setRunTestInSeparateProcess($this->runTestInSeparateProcess);
  6. +
  7.             }
  8. +
  9. +
  10.             $test->run($result);
  11. +
  12.         }
  13. +
  14. +
  15.         foreach ($hookMethods['afterClass'] as $afterClassMethod) {
  16. +
  17.             if ($this->testCase === true && class_exists($this->namefalse) && method_exists($this->name$afterClassMethod)) {
  18. +
  19.                 call_user_func([$this->name$afterClassMethod]);
+
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/src/TextUI/TestRunner.php->run (line 517) + +
+
+
  1. +
  2.         if ($suite instanceof PHPUnit_Framework_TestSuite) {
  3. +
  4.             $suite->setRunTestInSeparateProcess($arguments['processIsolation']);
  5. +
  6.         }
  7. +
  8. +
  9.         $suite->run($result);
  10. +
  11. +
  12.         unset($suite);
  13. +
  14.         $result->flushListeners();
  15. +
  16. +
  17.         if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
+
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/src/TextUI/Command.php->doRun (line 186) + +
+
+
  1. +
  2.         unset($this->arguments['test']);
  3. +
  4.         unset($this->arguments['testFile']);
  5. +
  6. +
  7.         try {
  8. +
  9.             $result $runner->doRun($suite$this->arguments$exit);
  10. +
  11.         } catch (PHPUnit_Framework_Exception $e) {
  12. +
  13.             print $e->getMessage() . "\n";
  14. +
  15.         }
  16. +
  17. +
  18.         $return PHPUnit_TextUI_TestRunner::FAILURE_EXIT;
+
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/src/TextUI/Command.php->run (line 116) + +
+
+
  1.      */
  2. +
  3.     public static function main($exit true)
  4. +
  5.     {
  6. +
  7.         $command = new static;
  8. +
  9. +
  10.         return $command->run($_SERVER['argv'], $exit);
  11. +
  12.     }
  13. +
  14. +
  15.     /**
  16. +
  17.      * @param array $argv
  18. +
  19.      * @param bool  $exit
+
+ +
+
+
+ + + + + + + + + in + vendor/phpunit/phpunit/phpunit::main (line 52) + +
+
+
  1.     die(1);
  2. +
  3. }
  4. +
  5. +
  6. require PHPUNIT_COMPOSER_INSTALL;
  7. +
  8. +
  9. PHPUnit_TextUI_Command::main();
  10. +
  11. +
+
+ +
+
+
+
+ +
+
+ + +
+

+ Stack Trace +

+ +
+ + + + + + + + + + + + +
+

+ ServiceNotFoundException + + + + +

+
+
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
+You have requested a non-existent service "admin_authorization_checker". Did you mean this: "security.authorization_checker"?
+
+  at vendor/symfony/dependency-injection/Container.php:277
+  at Symfony\Component\DependencyInjection\Container->make('admin_authorization_checker', 1)
+     (vendor/symfony/dependency-injection/Container.php:225)
+  at Symfony\Component\DependencyInjection\Container->get('admin_authorization_checker')
+     (vendor/symfony/framework-bundle/Controller/ControllerTrait.php:66)
+  at Symfony\Bundle\FrameworkBundle\Controller\AbstractController->get('admin_authorization_checker')
+     (src/Controller/AdminController.php:62)
+  at AlterPHP\EasyAdminExtensionBundle\Controller\AdminController->isActionAllowed('new')
+     (vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php:65)
+  at EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController->indexAction(object(Request))
+     (vendor/symfony/http-kernel/HttpKernel.php:150)
+  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
+     (vendor/symfony/http-kernel/HttpKernel.php:67)
+  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
+     (vendor/symfony/http-kernel/Kernel.php:198)
+  at Symfony\Component\HttpKernel\Kernel->handle(object(Request), 1, true)
+     (vendor/symfony/http-kernel/Client.php:68)
+  at Symfony\Component\HttpKernel\Client->doRequest(object(Request))
+     (vendor/symfony/framework-bundle/Client.php:131)
+  at Symfony\Bundle\FrameworkBundle\Client->doRequest(object(Request))
+     (vendor/symfony/browser-kit/Client.php:405)
+  at Symfony\Component\BrowserKit\Client->request('GET', 'http://localhost/admin/?action=new&amp;entity=Product')
+     (tests/Fixtures/AbstractTestCase.php:64)
+  at AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AbstractTestCase->getBackendPage(array('action' => 'new', 'entity' => 'Product'))
+     (tests/Fixtures/AbstractTestCase.php:121)
+  at AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AbstractTestCase->requestNewView('Product')
+     (tests/Controller/AutocompleteAddTest.php:18)
+  at AlterPHP\EasyAdminExtensionBundle\Tests\Controller\AutocompleteAddTest->testNewEntityAutocompleteModal()
+  at ReflectionMethod->invokeArgs(object(AutocompleteAddTest), array())
+     (vendor/phpunit/phpunit/src/Framework/TestCase.php:1062)
+  at PHPUnit_Framework_TestCase->runTest()
+     (vendor/phpunit/phpunit/src/Framework/TestCase.php:913)
+  at PHPUnit_Framework_TestCase->runBare()
+     (vendor/phpunit/phpunit/src/Framework/TestResult.php:686)
+  at PHPUnit_Framework_TestResult->run(object(AutocompleteAddTest))
+     (vendor/phpunit/phpunit/src/Framework/TestCase.php:868)
+  at PHPUnit_Framework_TestCase->run(object(PHPUnit_Framework_TestResult))
+     (vendor/phpunit/phpunit/src/Framework/TestSuite.php:733)
+  at PHPUnit_Framework_TestSuite->run(object(PHPUnit_Framework_TestResult))
+     (vendor/phpunit/phpunit/src/Framework/TestSuite.php:733)
+  at PHPUnit_Framework_TestSuite->run(object(PHPUnit_Framework_TestResult))
+     (vendor/phpunit/phpunit/src/TextUI/TestRunner.php:517)
+  at PHPUnit_TextUI_TestRunner->doRun(object(PHPUnit_Framework_TestSuite), array('listGroups' => false, 'listSuites' => false, 'loader' => null, 'useDefaultConfiguration' => true, 'loadedExtensions' => array(), 'notLoadedExtensions' => array(), 'stopOnFailure' => true, 'testSuffixes' => array('Test.php', '.phpt'), 'configuration' => object(PHPUnit_Util_Configuration), 'debug' => false, 'filter' => false, 'listeners' => array(), 'backupGlobals' => false, 'backupStaticAttributes' => false, 'bootstrap' => '/app/tests/bootstrap.php', 'colors' => 'auto', 'convertErrorsToExceptions' => true, 'convertNoticesToExceptions' => true, 'convertWarningsToExceptions' => true, 'processIsolation' => false, 'testdoxGroups' => array(), 'testdoxExcludeGroups' => array(), 'addUncoveredFilesFromWhitelist' => true, 'processUncoveredFilesFromWhitelist' => false, 'beStrictAboutChangesToGlobalState' => null, 'cacheTokens' => false, 'columns' => 80, 'excludeGroups' => array(), 'groups' => array(), 'logIncompleteSkipped' => false, 'repeat' => false, 'reportHighLowerBound' => 90, 'reportLowUpperBound' => 50, 'crap4jThreshold' => 30, 'stopOnError' => false, 'stopOnWarning' => false, 'stopOnIncomplete' => false, 'stopOnRisky' => false, 'stopOnSkipped' => false, 'failOnWarning' => false, 'failOnRisky' => false, 'timeoutForSmallTests' => 1, 'timeoutForMediumTests' => 10, 'timeoutForLargeTests' => 60, 'reportUselessTests' => false, 'strictCoverage' => false, 'disallowTestOutput' => false, 'enforceTimeLimit' => false, 'disallowTodoAnnotatedTests' => false, 'beStrictAboutResourceUsageDuringSmallTests' => false, 'reverseList' => false, 'registerMockObjectsFromTestArgumentsRecursively' => false, 'verbose' => false), true)
+     (vendor/phpunit/phpunit/src/TextUI/Command.php:186)
+  at PHPUnit_TextUI_Command->run(array('/app/vendor/phpunit/phpunit/phpunit', '--stop-on-failure'), true)
+     (vendor/phpunit/phpunit/src/TextUI/Command.php:116)
+  at PHPUnit_TextUI_Command::main()
+     (vendor/phpunit/phpunit/phpunit:52)
+
+
+ +
+
+ +
+
+ + + + + + +Time: 1.67 seconds, Memory: 40.25MB + +There was 1 failure: + +1) AlterPHP\EasyAdminExtensionBundle\Tests\Controller\AutocompleteAddTest::testNewEntityAutocompleteModal +Failed asserting that 500 is identical to 200. + +/app/tests/Controller/AutocompleteAddTest.php:24 + +FAILURES! +Tests: 8, Assertions: 8, Failures: 1. + +Remaining deprecation notices (8) + + 3x: A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0. + 2x in AutocompleteAddTest::setUp from AlterPHP\EasyAdminExtensionBundle\Tests\Controller + 1x in Application::run from Symfony\Bundle\FrameworkBundle\Console + + 3x: Not implementing the static getExtendedTypes() method in AlterPHP\EasyAdminExtensionBundle\Form\Type\Extension\EasyAdminAutocompleteTypeExtension when implementing the Symfony\Component\Form\FormTypeExtensionInterface is deprecated since Symfony 4.2. The method will be added to the interface in 5.0. + 2x in AutocompleteAddTest::setUp from AlterPHP\EasyAdminExtensionBundle\Tests\Controller + 1x in Application::run from Symfony\Bundle\FrameworkBundle\Console + + 1x: The "Symfony\Component\HttpKernel\Kernel::getRootDir()" method is deprecated since Symfony 4.2, use getProjectDir() instead. + 1x in Application::run from Symfony\Bundle\FrameworkBundle\Console + + 1x: Auto-injection of the container for "AlterPHP\EasyAdminExtensionBundle\Controller\AdminController" is deprecated since Symfony 4.2. Configure it as a service instead. + 1x in AutocompleteAddTest::testNewEntityAutocompleteModal from AlterPHP\EasyAdminExtensionBundle\Tests\Controller + diff --git a/src/Configuration/EmbeddedListViewConfigPass.php b/src/Configuration/EmbeddedListViewConfigPass.php index 3d1d9959..a03a113a 100644 --- a/src/Configuration/EmbeddedListViewConfigPass.php +++ b/src/Configuration/EmbeddedListViewConfigPass.php @@ -61,9 +61,9 @@ private function processSortingConfig(array $backendConfig) } if (\is_string($sortConfig)) { - $sortConfig = array('field' => $sortConfig, 'direction' => 'DESC'); + $sortConfig = ['field' => $sortConfig, 'direction' => 'DESC']; } else { - $sortConfig = array('field' => $sortConfig[0], 'direction' => \strtoupper($sortConfig[1])); + $sortConfig = ['field' => $sortConfig[0], 'direction' => \strtoupper($sortConfig[1])]; } $backendConfig['entities'][$entityName]['embeddedList']['sort'] = $sortConfig; diff --git a/src/Configuration/ExcludeFieldsConfigPass.php b/src/Configuration/ExcludeFieldsConfigPass.php index c53a0984..62f57817 100644 --- a/src/Configuration/ExcludeFieldsConfigPass.php +++ b/src/Configuration/ExcludeFieldsConfigPass.php @@ -34,7 +34,7 @@ public function process(array $backendConfig): array } foreach ($backendConfig['entities'] as $entityName => $entityConfig) { - foreach (array('form', 'edit', 'new') as $section) { + foreach (['form', 'edit', 'new'] as $section) { if (!isset($entityConfig[$section]['exclude_fields'])) { continue; } diff --git a/src/Configuration/ListFormFiltersConfigPass.php b/src/Configuration/ListFormFiltersConfigPass.php index e0e5906e..de3b4e32 100644 --- a/src/Configuration/ListFormFiltersConfigPass.php +++ b/src/Configuration/ListFormFiltersConfigPass.php @@ -37,7 +37,7 @@ public function process(array $backendConfig): array continue; } - $formFilters = array(); + $formFilters = []; foreach ($entityConfig['list']['form_filters'] as $i => $formFilter) { // Detects invalid config node @@ -52,7 +52,7 @@ public function process(array $backendConfig): array // Key mapping if (\is_string($formFilter)) { - $filterConfig = array('property' => $formFilter); + $filterConfig = ['property' => $formFilter]; } else { if (!\array_key_exists('property', $formFilter)) { throw new \RuntimeException( @@ -121,22 +121,22 @@ private function configureFieldFilter(string $entityClass, array $fieldMapping, switch ($fieldMapping['type']) { case 'boolean': $filterConfig['type'] = ChoiceType::class; - $defaultFilterConfigTypeOptions = array( - 'choices' => array( + $defaultFilterConfigTypeOptions = [ + 'choices' => [ 'list_form_filters.default.boolean.true' => true, 'list_form_filters.default.boolean.false' => false, - ), + ], 'choice_translation_domain' => 'EasyAdminBundle', - ); + ]; break; case 'string': $filterConfig['type'] = ChoiceType::class; - $defaultFilterConfigTypeOptions = array( + $defaultFilterConfigTypeOptions = [ 'multiple' => true, 'choices' => $this->getChoiceList($entityClass, $filterConfig['property'], $filterConfig), - 'attr' => array('data-widget' => 'select2'), + 'attr' => ['data-widget' => 'select2'], 'choice_translation_domain' => $translationDomain, - ); + ]; break; default: return; @@ -146,7 +146,7 @@ private function configureFieldFilter(string $entityClass, array $fieldMapping, if (null !== $defaultFilterConfigTypeOptions) { $filterConfig['type_options'] = \array_merge( $defaultFilterConfigTypeOptions, - $filterConfig['type_options'] ?? array() + $filterConfig['type_options'] ?? [] ); } } @@ -157,12 +157,12 @@ private function configureAssociationFilter(string $entityClass, array $associat if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { $filterConfig['type'] = EasyAdminAutocompleteType::class; $filterConfig['type_options'] = \array_merge( - array( + [ 'class' => $associationMapping['targetEntity'], 'multiple' => true, - 'attr' => array('data-widget' => 'select2'), - ), - $filterConfig['type_options'] ?? array() + 'attr' => ['data-widget' => 'select2'], + ], + $filterConfig['type_options'] ?? [] ); } } @@ -186,11 +186,11 @@ private function getChoiceList(string $entityClass, string $property, array &$fi ); } - $callableParams = array(); + $callableParams = []; if (\is_string($filterConfig['type_options']['choices_static_callback'])) { - $callable = array($entityClass, $filterConfig['type_options']['choices_static_callback']); + $callable = [$entityClass, $filterConfig['type_options']['choices_static_callback']]; } else { - $callable = array($entityClass, $filterConfig['type_options']['choices_static_callback'][0]); + $callable = [$entityClass, $filterConfig['type_options']['choices_static_callback'][0]]; $callableParams = $filterConfig['type_options']['choices_static_callback'][1]; } unset($filterConfig['type_options']['choices_static_callback']); diff --git a/src/Configuration/ShortFormTypeConfigPass.php b/src/Configuration/ShortFormTypeConfigPass.php index 459dea91..30e2df2f 100644 --- a/src/Configuration/ShortFormTypeConfigPass.php +++ b/src/Configuration/ShortFormTypeConfigPass.php @@ -17,15 +17,15 @@ */ class ShortFormTypeConfigPass implements ConfigPassInterface { - private $customFormTypes = array(); + private $customFormTypes = []; - private static $configWithFormPaths = array('[form][fields]', '[edit][fields]', '[new][fields]', '[list][form_filters]'); - private static $nativeShortFormTypes = array( + private static $configWithFormPaths = ['[form][fields]', '[edit][fields]', '[new][fields]', '[list][form_filters]']; + private static $nativeShortFormTypes = [ 'embedded_list' => EasyAdminEmbeddedListType::class, 'admin_roles' => AdminRolesType::class, - ); + ]; - public function __construct(array $customFormTypes = array()) + public function __construct(array $customFormTypes = []) { $this->customFormTypes = $customFormTypes; } diff --git a/src/Configuration/ShowViewConfigPass.php b/src/Configuration/ShowViewConfigPass.php index 2841fbfe..7fb4c8c8 100644 --- a/src/Configuration/ShowViewConfigPass.php +++ b/src/Configuration/ShowViewConfigPass.php @@ -17,11 +17,11 @@ class ShowViewConfigPass implements ConfigPassInterface */ private $embeddedListHelper; - private static $mapTypeToTemplates = array( + private static $mapTypeToTemplates = [ // Use EasyAdminExtension namespace because EasyAdminTwigExtension checks namespaces // to detect custom templates. 'embedded_list' => '@EasyAdminExtension/default/field_embedded_list.html.twig', - ); + ]; /** * ShowViewConfigPass constructor. diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 9ca87f65..8ad1e0aa 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -9,10 +9,9 @@ class AdminController extends EasyAdminController { - public static function getSubscribedServices(): array { - return array_merge( + return \array_merge( parent::getSubscribedServices(), ['admin_authorization_checker' => AdminAuthorizationChecker::class] ); @@ -25,13 +24,13 @@ protected function embeddedListAction() $fields = $this->entity['list']['fields']; $paginator = $this->findAll($this->entity['class'], $this->request->query->get('page', 1), $this->config['list']['max_results'], $this->request->query->get('sortField'), $this->request->query->get('sortDirection')); - $this->dispatch(EasyAdminEvents::POST_LIST, array('paginator' => $paginator)); + $this->dispatch(EasyAdminEvents::POST_LIST, ['paginator' => $paginator]); - return $this->render('@EasyAdminExtension/default/embedded_list.html.twig', array( + return $this->render('@EasyAdminExtension/default/embedded_list.html.twig', [ 'paginator' => $paginator, 'fields' => $fields, 'masterRequest' => $this->get('request_stack')->getMasterRequest(), - )); + ]); } /** @@ -74,7 +73,7 @@ protected function newAjaxAction() $this->dispatch(EasyAdminEvents::PRE_NEW); $entity = $this->executeDynamicMethod('createNewEntity'); - $easyadmin = \array_merge($this->request->attributes->get('easyadmin'), array('item' => $entity)); + $easyadmin = \array_merge($this->request->attributes->get('easyadmin'), ['item' => $entity]); $this->request->attributes->set('easyadmin', $easyadmin); $fields = $this->entity['new']['fields']; diff --git a/src/DependencyInjection/Compiler/TwigPathPass.php b/src/DependencyInjection/Compiler/TwigPathPass.php index c4f1e49c..9478b0ee 100644 --- a/src/DependencyInjection/Compiler/TwigPathPass.php +++ b/src/DependencyInjection/Compiler/TwigPathPass.php @@ -21,7 +21,7 @@ public function process(ContainerBuilder $container) $easyAdminExtensionTwigPath = $easyAdminExtensionBundlePath.'/Resources/views'; $twigLoaderFilesystemDefinition->addMethodCall( 'prependPath', - array($easyAdminExtensionTwigPath, 'EasyAdmin') + [$easyAdminExtensionTwigPath, 'EasyAdmin'] ); } @@ -32,7 +32,7 @@ public function process(ContainerBuilder $container) // Defines a namespace from native EasyAdmin templates $twigLoaderFilesystemDefinition->addMethodCall( 'addPath', - array($nativeEasyAdminTwigPath, 'BaseEasyAdmin') + [$nativeEasyAdminTwigPath, 'BaseEasyAdmin'] ); } } diff --git a/src/EasyAdminExtensionBundle.php b/src/EasyAdminExtensionBundle.php index 2a5c0297..21c89a8f 100644 --- a/src/EasyAdminExtensionBundle.php +++ b/src/EasyAdminExtensionBundle.php @@ -37,9 +37,9 @@ private function addRegisterMappingsPass(ContainerBuilder $container) $easyAdminExtensionBundlePath = \dirname((string) $easyAdminExtensionBundleRefl->getFileName()); $easyAdminExtensionDoctrineMapping = $easyAdminExtensionBundlePath.'/Resources/config/doctrine-mapping'; - $mappings = array( + $mappings = [ \realpath($easyAdminExtensionDoctrineMapping) => 'AlterPHP\EasyAdminExtensionBundle\Model', - ); + ]; if (\class_exists(DoctrineOrmMappingsPass::class)) { $container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings)); } diff --git a/src/EventListener/PostQueryBuilderSubscriber.php b/src/EventListener/PostQueryBuilderSubscriber.php index 665561b3..984d3ab7 100644 --- a/src/EventListener/PostQueryBuilderSubscriber.php +++ b/src/EventListener/PostQueryBuilderSubscriber.php @@ -3,8 +3,8 @@ namespace AlterPHP\EasyAdminExtensionBundle\EventListener; use Doctrine\Common\Collections\Collection; -use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\Query\QueryException; +use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -34,10 +34,10 @@ public function __construct($listFormFiltersHelper) */ public static function getSubscribedEvents() { - return array( - EasyAdminEvents::POST_LIST_QUERY_BUILDER => array('onPostListQueryBuilder'), - EasyAdminEvents::POST_SEARCH_QUERY_BUILDER => array('onPostSearchQueryBuilder'), - ); + return [ + EasyAdminEvents::POST_LIST_QUERY_BUILDER => ['onPostListQueryBuilder'], + EasyAdminEvents::POST_SEARCH_QUERY_BUILDER => ['onPostSearchQueryBuilder'], + ]; } /** @@ -51,7 +51,7 @@ public function onPostListQueryBuilder(GenericEvent $event) // Request filters if ($event->hasArgument('request')) { - $this->applyRequestFilters($queryBuilder, $event->getArgument('request')->get('filters', array())); + $this->applyRequestFilters($queryBuilder, $event->getArgument('request')->get('filters', [])); } // List form filters @@ -76,7 +76,7 @@ public function onPostSearchQueryBuilder(GenericEvent $event) $queryBuilder = $event->getArgument('query_builder'); if ($event->hasArgument('request')) { - $this->applyRequestFilters($queryBuilder, $event->getArgument('request')->get('filters', array())); + $this->applyRequestFilters($queryBuilder, $event->getArgument('request')->get('filters', [])); } } @@ -86,7 +86,7 @@ public function onPostSearchQueryBuilder(GenericEvent $event) * @param QueryBuilder $queryBuilder * @param array $filters */ - protected function applyRequestFilters(QueryBuilder $queryBuilder, array $filters = array()) + protected function applyRequestFilters(QueryBuilder $queryBuilder, array $filters = []) { foreach ($filters as $field => $value) { // Empty string and numeric keys is considered as "not applied filter" @@ -112,7 +112,7 @@ protected function applyRequestFilters(QueryBuilder $queryBuilder, array $filter * @param QueryBuilder $queryBuilder * @param array $filters */ - protected function applyFormFilters(QueryBuilder $queryBuilder, array $filters = array()) + protected function applyFormFilters(QueryBuilder $queryBuilder, array $filters = []) { foreach ($filters as $field => $value) { $value = $this->filterEasyadminAutocompleteValue($value); diff --git a/src/Form/Transformer/RestoreRolesTransformer.php b/src/Form/Transformer/RestoreRolesTransformer.php index 22b66936..f841a21f 100644 --- a/src/Form/Transformer/RestoreRolesTransformer.php +++ b/src/Form/Transformer/RestoreRolesTransformer.php @@ -37,7 +37,7 @@ public function __construct(EditableRolesHelper $rolesBuilder) */ public function setOriginalRoles(array $originalRoles = null) { - $this->originalRoles = $originalRoles ?: array(); + $this->originalRoles = $originalRoles ?: []; } /** diff --git a/src/Form/Type/EasyAdminEmbeddedListType.php b/src/Form/Type/EasyAdminEmbeddedListType.php index 40432c28..f75bb07f 100644 --- a/src/Form/Type/EasyAdminEmbeddedListType.php +++ b/src/Form/Type/EasyAdminEmbeddedListType.php @@ -82,7 +82,7 @@ public function configureOptions(OptionsResolver $resolver) { $resolver ->setDefault('entity', null) - ->setDefault('filters', array()) + ->setDefault('filters', []) ->setDefault('sort', null) ->setAllowedTypes('entity', ['null', 'string']) ->setAllowedTypes('filters', ['array']) diff --git a/src/Form/Type/Extension/EasyAdminAutocompleteTypeExtension.php b/src/Form/Type/Extension/EasyAdminAutocompleteTypeExtension.php index 38f87d41..3e76d050 100644 --- a/src/Form/Type/Extension/EasyAdminAutocompleteTypeExtension.php +++ b/src/Form/Type/Extension/EasyAdminAutocompleteTypeExtension.php @@ -29,11 +29,11 @@ public function buildView(FormView $view, FormInterface $form, array $options) { if (isset($options['attr']['create']) && $options['attr']['create']) { $view->vars['attr']['data-easyadmin-autocomplete-create-action-url'] = $this->router->generate( - 'easyadmin', array('action' => 'newAjax', 'entity' => $view->vars['autocomplete_entity_name']) + 'easyadmin', ['action' => 'newAjax', 'entity' => $view->vars['autocomplete_entity_name']] ); $view->vars['attr']['data-easyadmin-autocomplete-create-field-name'] = \strtolower($view->vars['autocomplete_entity_name']); $view->vars['attr']['data-easyadmin-autocomplete-create-button-text'] = $this->translator->trans( - 'action.add_new_item', array(), 'EasyAdminBundle' + 'action.add_new_item', [], 'EasyAdminBundle' ); unset($view->vars['attr']['create']); diff --git a/src/Form/Type/Security/AdminRolesType.php b/src/Form/Type/Security/AdminRolesType.php index 9d15e29b..d7314bee 100644 --- a/src/Form/Type/Security/AdminRolesType.php +++ b/src/Form/Type/Security/AdminRolesType.php @@ -76,19 +76,19 @@ public function buildView(FormView $view, FormInterface $form, array $options) */ public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ // make expanded default value 'expanded' => true, 'choices' => function (Options $options, $parentChoices) { if (!empty($parentChoices)) { - return array(); + return []; } return $this->rolesBuilder->getRoles(); }, 'multiple' => true, 'data_class' => null, - )); + ]); } /** diff --git a/src/Helper/EditableRolesHelper.php b/src/Helper/EditableRolesHelper.php index 2195d3c2..84bf7a06 100644 --- a/src/Helper/EditableRolesHelper.php +++ b/src/Helper/EditableRolesHelper.php @@ -29,7 +29,7 @@ class EditableRolesHelper * @param TokenStorageInterface $tokenStorage * @param array $roleHierarchy */ - public function __construct(TokenStorageInterface $tokenStorage, array $roleHierarchy = array()) + public function __construct(TokenStorageInterface $tokenStorage, array $roleHierarchy = []) { $this->tokenStorage = $tokenStorage; $this->roleHierarchy = $roleHierarchy; @@ -40,7 +40,7 @@ public function __construct(TokenStorageInterface $tokenStorage, array $roleHier */ public function getRoles() { - $roles = array(); + $roles = []; if (!$this->tokenStorage->getToken()) { return $roles; diff --git a/src/Helper/ListFormFiltersHelper.php b/src/Helper/ListFormFiltersHelper.php index 4eaad94a..e86f9fd5 100644 --- a/src/Helper/ListFormFiltersHelper.php +++ b/src/Helper/ListFormFiltersHelper.php @@ -49,7 +49,7 @@ public function __construct(FormFactory $formFactory, RequestStack $requestStack public function getListFormFilters(array $formFilters): FormInterface { if (null === $this->listFiltersForm) { - $formOptions = array(); + $formOptions = []; if ($this->formCsrfEnabled) { $formOptions['csrf_protection'] = false; } @@ -62,7 +62,7 @@ public function getListFormFilters(array $formFilters): FormInterface $name, $config['type'] ?? null, \array_merge( - array('required' => false), + ['required' => false], isset($config['type_options']) ? $config['type_options'] : [] ) ); diff --git a/src/Model/AdminGroup.php b/src/Model/AdminGroup.php index 61bb428e..6c6db871 100644 --- a/src/Model/AdminGroup.php +++ b/src/Model/AdminGroup.php @@ -37,7 +37,7 @@ public function __toString() */ public function __construct() { - $this->roles = array(); + $this->roles = []; } /** diff --git a/src/Model/AdminUser.php b/src/Model/AdminUser.php index 0f74fdc4..d90a33ed 100644 --- a/src/Model/AdminUser.php +++ b/src/Model/AdminUser.php @@ -79,7 +79,7 @@ public function getGroups(): Collection */ public function getRoles() { - $roles = array('ROLE_ADMIN'); + $roles = ['ROLE_ADMIN']; foreach ($this->getGroups() as $group) { $roles = \array_merge($roles, $group->getRoles()); diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 48f82073..c4df020a 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -5,9 +5,9 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - +
diff --git a/src/Twig/AdminAuthorizationExtension.php b/src/Twig/AdminAuthorizationExtension.php index 6e19f63b..12776dc7 100644 --- a/src/Twig/AdminAuthorizationExtension.php +++ b/src/Twig/AdminAuthorizationExtension.php @@ -26,17 +26,17 @@ public function __construct($adminAuthorizationChecker, $menuHelper) public function getFilters() { - return array( - new TwigFilter('prune_item_actions', array($this, 'pruneItemsActions')), - new TwigFilter('prune_menu_items', array($this, 'pruneMenuItems')), - ); + return [ + new TwigFilter('prune_item_actions', [$this, 'pruneItemsActions']), + new TwigFilter('prune_menu_items', [$this, 'pruneMenuItems']), + ]; } public function getFunctions() { - return array( - new TwigFunction('is_easyadmin_granted', array($this, 'isEasyAdminGranted')), - ); + return [ + new TwigFunction('is_easyadmin_granted', [$this, 'isEasyAdminGranted']), + ]; } public function isEasyAdminGranted(array $entityConfig, string $actionName = 'list', $subject = null) diff --git a/src/Twig/CheckboxTreeExtension.php b/src/Twig/CheckboxTreeExtension.php index 12674edb..04c00dbf 100644 --- a/src/Twig/CheckboxTreeExtension.php +++ b/src/Twig/CheckboxTreeExtension.php @@ -11,19 +11,19 @@ class CheckboxTreeExtension extends AbstractExtension { public function getFunctions() { - return array( + return [ new TwigFunction( 'checkbox_tree', - array($this, 'renderCheckboxTree'), - array('is_safe' => array('html'), 'needs_environment' => true) + [$this, 'renderCheckboxTree'], + ['is_safe' => ['html'], 'needs_environment' => true] ), - new TwigFunction('pick_checkbox_form', array($this, 'pickCheckboxForm')), - ); + new TwigFunction('pick_checkbox_form', [$this, 'pickCheckboxForm']), + ]; } public function renderCheckboxTree(Environment $env, FormView $checkboxGroup) { - return $env->render('@EasyAdmin/form/checkbox_tree.html.twig', array('checkboxGroup' => $checkboxGroup)); + return $env->render('@EasyAdmin/form/checkbox_tree.html.twig', ['checkboxGroup' => $checkboxGroup]); } public function pickCheckboxForm(array $checkboxList, string $value) diff --git a/src/Twig/EmbeddedListExtension.php b/src/Twig/EmbeddedListExtension.php index ff2d21d1..453d5de1 100644 --- a/src/Twig/EmbeddedListExtension.php +++ b/src/Twig/EmbeddedListExtension.php @@ -25,16 +25,16 @@ public function __construct($embeddedListHelper) public function getFilters() { - return array( - new TwigFilter('embedded_list_identifier', array($this, 'getEmbeddedListIdentifier')), - ); + return [ + new TwigFilter('embedded_list_identifier', [$this, 'getEmbeddedListIdentifier']), + ]; } public function getFunctions() { - return array( - new TwigFunction('guess_default_filters', array($this, 'guessDefaultFilters')), - ); + return [ + new TwigFunction('guess_default_filters', [$this, 'guessDefaultFilters']), + ]; } public function getEmbeddedListIdentifier(string $requestUri) diff --git a/src/Twig/ListFormFiltersExtension.php b/src/Twig/ListFormFiltersExtension.php index d6a481f6..a2b48c74 100644 --- a/src/Twig/ListFormFiltersExtension.php +++ b/src/Twig/ListFormFiltersExtension.php @@ -24,9 +24,9 @@ public function __construct($listFormFiltersHelper) public function getFunctions() { - return array( - new TwigFunction('list_form_filters', array($this, 'getListFormFilters')), - ); + return [ + new TwigFunction('list_form_filters', [$this, 'getListFormFilters']), + ]; } public function getListFormFilters(array $filters) diff --git a/tests/Configuration/CustomFormTypeConfigPassTest.php b/tests/Configuration/CustomFormTypeConfigPassTest.php index 17d7a839..1edaa3e8 100644 --- a/tests/Configuration/CustomFormTypeConfigPassTest.php +++ b/tests/Configuration/CustomFormTypeConfigPassTest.php @@ -9,50 +9,50 @@ class ShortFormTypeConfigPassTest extends \PHPUnit_Framework_TestCase { public function testCustomFormTypesAreReplaced() { - $customFormTypesMap = array( + $customFormTypesMap = [ 'foo' => 'AppBundle\Form\Type\FooType', 'bar' => 'AppBundle\Form\Type\BarType', - ); + ]; $shortFormTypeConfigPass = new ShortFormTypeConfigPass($customFormTypesMap); - $backendConfig = array( - 'entities' => array( - 'TestEntity' => array( - 'form' => array('fields' => array('testField1' => array('type' => 'foo'))), - 'edit' => array('fields' => array('testField2' => array('type' => 'bar'))), - 'new' => array('fields' => array( - 'testField1' => array('type' => 'foo'), - 'testField2' => array('type' => 'bar'), - )), - ), - ), - ); + $backendConfig = [ + 'entities' => [ + 'TestEntity' => [ + 'form' => ['fields' => ['testField1' => ['type' => 'foo']]], + 'edit' => ['fields' => ['testField2' => ['type' => 'bar']]], + 'new' => ['fields' => [ + 'testField1' => ['type' => 'foo'], + 'testField2' => ['type' => 'bar'], + ]], + ], + ], + ]; $backendConfig = $shortFormTypeConfigPass->process($backendConfig); - $expectedBackendConfig = array( - 'entities' => array( - 'TestEntity' => array( - 'form' => array( - 'fields' => array( - 'testField1' => array('type' => 'AppBundle\Form\Type\FooType'), - ), - ), - 'edit' => array( - 'fields' => array( - 'testField2' => array('type' => 'AppBundle\Form\Type\BarType'), - ), - ), - 'new' => array( - 'fields' => array( - 'testField1' => array('type' => 'AppBundle\Form\Type\FooType'), - 'testField2' => array('type' => 'AppBundle\Form\Type\BarType'), - ), - ), - ), - ), - ); + $expectedBackendConfig = [ + 'entities' => [ + 'TestEntity' => [ + 'form' => [ + 'fields' => [ + 'testField1' => ['type' => 'AppBundle\Form\Type\FooType'], + ], + ], + 'edit' => [ + 'fields' => [ + 'testField2' => ['type' => 'AppBundle\Form\Type\BarType'], + ], + ], + 'new' => [ + 'fields' => [ + 'testField1' => ['type' => 'AppBundle\Form\Type\FooType'], + 'testField2' => ['type' => 'AppBundle\Form\Type\BarType'], + ], + ], + ], + ], + ]; $this->assertSame($backendConfig, $expectedBackendConfig); } @@ -60,37 +60,37 @@ public function testCustomFormTypesAreReplaced() public function testLegacyShortFormTypesAreReplaced() { // Legacy short form types may be overriden by configuration - $customFormTypesMap = array( + $customFormTypesMap = [ 'text' => 'AppBundle\Form\Type\TextType', - ); + ]; $shortFormTypeConfigPass = new ShortFormTypeConfigPass($customFormTypesMap); - $backendConfig = array( - 'entities' => array( - 'TestEntity' => array( - 'new' => array('fields' => array( - 'testField1' => array('type' => 'text'), - 'testField2' => array('type' => 'choice'), - )), - ), - ), - ); + $backendConfig = [ + 'entities' => [ + 'TestEntity' => [ + 'new' => ['fields' => [ + 'testField1' => ['type' => 'text'], + 'testField2' => ['type' => 'choice'], + ]], + ], + ], + ]; $backendConfig = $shortFormTypeConfigPass->process($backendConfig); - $expectedBackendConfig = array( - 'entities' => array( - 'TestEntity' => array( - 'new' => array( - 'fields' => array( - 'testField1' => array('type' => 'AppBundle\Form\Type\TextType'), - 'testField2' => array('type' => ChoiceType::class), - ), - ), - ), - ), - ); + $expectedBackendConfig = [ + 'entities' => [ + 'TestEntity' => [ + 'new' => [ + 'fields' => [ + 'testField1' => ['type' => 'AppBundle\Form\Type\TextType'], + 'testField2' => ['type' => ChoiceType::class], + ], + ], + ], + ], + ]; $this->assertSame($backendConfig, $expectedBackendConfig); } diff --git a/tests/Configuration/EmbeddedListViewConfigPassTest.php b/tests/Configuration/EmbeddedListViewConfigPassTest.php index 1e0bd083..90c929c3 100644 --- a/tests/Configuration/EmbeddedListViewConfigPassTest.php +++ b/tests/Configuration/EmbeddedListViewConfigPassTest.php @@ -10,40 +10,40 @@ public function testOpenNewTabOption() { $embeddedListViewConfigPass = new EmbeddedListViewConfigPass(true); - $backendConfig = array( - 'entities' => array( - 'NotSetEntity' => array( - ), - 'SetTrueEntity' => array( - 'embeddedList' => array('open_new_tab' => true), - ), - 'SetFalseEntity' => array( - 'embeddedList' => array('open_new_tab' => false), - ), - ), - ); + $backendConfig = [ + 'entities' => [ + 'NotSetEntity' => [ + ], + 'SetTrueEntity' => [ + 'embeddedList' => ['open_new_tab' => true], + ], + 'SetFalseEntity' => [ + 'embeddedList' => ['open_new_tab' => false], + ], + ], + ]; $backendConfig = $embeddedListViewConfigPass->process($backendConfig); - $expectedBackendConfig = array( - 'entities' => array( - 'NotSetEntity' => array( - 'embeddedList' => array( + $expectedBackendConfig = [ + 'entities' => [ + 'NotSetEntity' => [ + 'embeddedList' => [ 'open_new_tab' => true, - ), - ), - 'SetTrueEntity' => array( - 'embeddedList' => array( + ], + ], + 'SetTrueEntity' => [ + 'embeddedList' => [ 'open_new_tab' => true, - ), - ), - 'SetFalseEntity' => array( - 'embeddedList' => array( + ], + ], + 'SetFalseEntity' => [ + 'embeddedList' => [ 'open_new_tab' => false, - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertSame($backendConfig, $expectedBackendConfig); } diff --git a/tests/Configuration/ExcludeFieldsConfigPassTest.php b/tests/Configuration/ExcludeFieldsConfigPassTest.php index 79c0126e..f5c2375d 100644 --- a/tests/Configuration/ExcludeFieldsConfigPassTest.php +++ b/tests/Configuration/ExcludeFieldsConfigPassTest.php @@ -20,47 +20,47 @@ protected function setUp() public function testExcludeFields() { - $backendConfig = array( - 'entities' => array( - 'TestEntity' => array( + $backendConfig = [ + 'entities' => [ + 'TestEntity' => [ 'class' => Dummy::class, - 'form' => array( - 'exclude_fields' => array('exclude') - ), - ), - ), - ); + 'form' => [ + 'exclude_fields' => ['exclude'], + ], + ], + ], + ]; $processedBackendConfig = $this->excludeFieldsConfigPass->process($backendConfig); - $expectedBackendConfig = array( - 'entities' => array( - 'TestEntity' => array( + $expectedBackendConfig = [ + 'entities' => [ + 'TestEntity' => [ 'class' => Dummy::class, - 'form' => array( - 'exclude_fields' => array('exclude'), - 'fields' => array('name', 'title') - ), - ), - ), - ); + 'form' => [ + 'exclude_fields' => ['exclude'], + 'fields' => ['name', 'title'], + ], + ], + ], + ]; $this->assertSame($processedBackendConfig, $expectedBackendConfig); } public function testExcludeFieldThrowsConflictingConfigurationException() { - $backendConfig = array( - 'entities' => array( - 'TestEntity' => array( + $backendConfig = [ + 'entities' => [ + 'TestEntity' => [ 'class' => Dummy::class, - 'form' => array( - 'fields' => array('name', 'title'), - 'exclude_fields' => array('exclude'), - ), - ), - ), - ); + 'form' => [ + 'fields' => ['name', 'title'], + 'exclude_fields' => ['exclude'], + ], + ], + ], + ]; $this->expectException(ConflictingConfigurationException::class); diff --git a/tests/Configuration/ShowViewConfigPassTest.php b/tests/Configuration/ShowViewConfigPassTest.php index e1cade48..4933a5e1 100644 --- a/tests/Configuration/ShowViewConfigPassTest.php +++ b/tests/Configuration/ShowViewConfigPassTest.php @@ -23,53 +23,53 @@ public function testDefaultEmbeddedListShow() $showViewConfigPass = new ShowViewConfigPass($embeddedListHelper); - $backendConfig = array( - 'entities' => array( - 'MyEntity' => array( - 'show' => array( - 'fields' => array( - 'foo' => array('type' => 'string'), - 'bar' => array('type' => 'boolean'), - 'relations' => array( + $backendConfig = [ + 'entities' => [ + 'MyEntity' => [ + 'show' => [ + 'fields' => [ + 'foo' => ['type' => 'string'], + 'bar' => ['type' => 'boolean'], + 'relations' => [ 'property' => 'relations', 'type' => 'embedded_list', 'sourceEntity' => 'App\Entity\MyEntity', - ), - 'qux' => array('type' => 'integer'), - ), - ), - ), - ), - ); + ], + 'qux' => ['type' => 'integer'], + ], + ], + ], + ], + ]; $backendConfig = $showViewConfigPass->process($backendConfig); - $expectedBackendConfig = array( - 'entities' => array( - 'MyEntity' => array( - 'show' => array( - 'fields' => array( - 'foo' => array('type' => 'string'), - 'bar' => array('type' => 'boolean'), - 'relations' => array( + $expectedBackendConfig = [ + 'entities' => [ + 'MyEntity' => [ + 'show' => [ + 'fields' => [ + 'foo' => ['type' => 'string'], + 'bar' => ['type' => 'boolean'], + 'relations' => [ 'property' => 'relations', 'type' => 'embedded_list', 'sourceEntity' => 'App\Entity\MyEntity', 'template' => '@EasyAdminExtension/default/field_embedded_list.html.twig', - 'template_options' => array( + 'template_options' => [ 'entity_fqcn' => 'App\Entity\MyRelation', 'parent_entity_property' => 'relations', 'entity' => 'MyRelation', - 'filters' => array(), + 'filters' => [], 'sort' => null, - ), - ), - 'qux' => array('type' => 'integer'), - ), - ), - ), - ), - ); + ], + ], + 'qux' => ['type' => 'integer'], + ], + ], + ], + ], + ]; $this->assertSame($backendConfig, $expectedBackendConfig); } @@ -90,57 +90,57 @@ public function testDefinedEmbeddedListShow() $showViewConfigPass = new ShowViewConfigPass($embeddedListHelper); - $backendConfig = array( - 'entities' => array( - 'MyEntity' => array( - 'show' => array( - 'fields' => array( - 'relations' => array( + $backendConfig = [ + 'entities' => [ + 'MyEntity' => [ + 'show' => [ + 'fields' => [ + 'relations' => [ 'property' => 'relations', 'type' => 'embedded_list', 'sourceEntity' => 'App\Entity\MyEntity', 'template' => 'path/to/template.html.twig', - 'template_options' => array( + 'template_options' => [ 'parent_entity_fqcn' => 'Foo\Entity\MyEntity', 'parent_entity_property' => 'children', 'entity_fqcn' => 'Foo\Entity\Child', 'entity' => 'Child', - 'filters' => array('bar' => 'baz'), - 'sort' => array('qux', 'ASC'), - ), - ), - ), - ), - ), - ), - ); + 'filters' => ['bar' => 'baz'], + 'sort' => ['qux', 'ASC'], + ], + ], + ], + ], + ], + ], + ]; $backendConfig = $showViewConfigPass->process($backendConfig); - $expectedBackendConfig = array( - 'entities' => array( - 'MyEntity' => array( - 'show' => array( - 'fields' => array( - 'relations' => array( + $expectedBackendConfig = [ + 'entities' => [ + 'MyEntity' => [ + 'show' => [ + 'fields' => [ + 'relations' => [ 'property' => 'relations', 'type' => 'embedded_list', 'sourceEntity' => 'App\Entity\MyEntity', 'template' => 'path/to/template.html.twig', - 'template_options' => array( + 'template_options' => [ 'parent_entity_fqcn' => 'Foo\Entity\MyEntity', 'parent_entity_property' => 'children', 'entity_fqcn' => 'Foo\Entity\Child', 'entity' => 'Child', - 'filters' => array('bar' => 'baz'), - 'sort' => array('field' => 'qux', 'direction' => 'ASC'), - ), - ), - ), - ), - ), - ), - ); + 'filters' => ['bar' => 'baz'], + 'sort' => ['field' => 'qux', 'direction' => 'ASC'], + ], + ], + ], + ], + ], + ], + ]; $this->assertSame($backendConfig, $expectedBackendConfig); } diff --git a/tests/Controller/AutocompleteAddTest.php b/tests/Controller/AutocompleteAddTest.php index 04fa1b31..0055c6c6 100644 --- a/tests/Controller/AutocompleteAddTest.php +++ b/tests/Controller/AutocompleteAddTest.php @@ -10,13 +10,17 @@ public function setUp() { parent::setUp(); - $this->initClient(array('environment' => 'autocomplete_add')); + $this->initClient(['environment' => 'autocomplete_add']); } public function testNewEntityAutocompleteModal() { $crawler = $this->requestNewView('Product'); + if (200 !== $this->client->getResponse()->getStatusCode()) { + echo $this->client->getResponse()->getContent(); + } + $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(1, $crawler->filter('select#product_category_autocomplete[data-easyadmin-autocomplete-create-action-url="/admin/?action=newAjax&entity=Category"]')->count()); diff --git a/tests/Controller/EmbeddedListTest.php b/tests/Controller/EmbeddedListTest.php index 7840e10c..678f3055 100644 --- a/tests/Controller/EmbeddedListTest.php +++ b/tests/Controller/EmbeddedListTest.php @@ -10,14 +10,14 @@ public function setUp() { parent::setUp(); - $this->initClient(array('environment' => 'embedded_list')); + $this->initClient(['environment' => 'embedded_list']); } public function testManyToManyEmbedddLists() { $crawler = $this->requestEditView('AdminGroup', 1); - $forAttrValue = md5('/admin/?entity=AdminUser&action=embeddedList&filters%5Bentity.id%5D%5B0%5D=1&filters%5Bentity.id%5D%5B1%5D=2&filters%5Bentity.id%5D%5B2%5D=3&filters%5Bentity.id%5D%5B3%5D=4&filters%5Bentity.id%5D%5B4%5D=5&filters%5Bentity.id%5D%5B5%5D=6&filters%5Bentity.id%5D%5B6%5D=7&filters%5Bentity.id%5D%5B7%5D=8&filters%5Bentity.id%5D%5B8%5D=9&filters%5Bentity.id%5D%5B9%5D=10&filters%5Bentity.id%5D%5B10%5D=11&filters%5Bentity.id%5D%5B11%5D=12&filters%5Bentity.id%5D%5B12%5D=13&filters%5Bentity.id%5D%5B13%5D=14&filters%5Bentity.id%5D%5B14%5D=15&filters%5Bentity.id%5D%5B15%5D=16&filters%5Bentity.id%5D%5B16%5D=17&filters%5Bentity.id%5D%5B17%5D=18&filters%5Bentity.id%5D%5B18%5D=19&filters%5Bentity.id%5D%5B19%5D=20'); + $forAttrValue = \md5('/admin/?entity=AdminUser&action=embeddedList&filters%5Bentity.id%5D%5B0%5D=1&filters%5Bentity.id%5D%5B1%5D=2&filters%5Bentity.id%5D%5B2%5D=3&filters%5Bentity.id%5D%5B3%5D=4&filters%5Bentity.id%5D%5B4%5D=5&filters%5Bentity.id%5D%5B5%5D=6&filters%5Bentity.id%5D%5B6%5D=7&filters%5Bentity.id%5D%5B7%5D=8&filters%5Bentity.id%5D%5B8%5D=9&filters%5Bentity.id%5D%5B9%5D=10&filters%5Bentity.id%5D%5B10%5D=11&filters%5Bentity.id%5D%5B11%5D=12&filters%5Bentity.id%5D%5B12%5D=13&filters%5Bentity.id%5D%5B13%5D=14&filters%5Bentity.id%5D%5B14%5D=15&filters%5Bentity.id%5D%5B15%5D=16&filters%5Bentity.id%5D%5B16%5D=17&filters%5Bentity.id%5D%5B17%5D=18&filters%5Bentity.id%5D%5B18%5D=19&filters%5Bentity.id%5D%5B19%5D=20'); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(1, $crawler->filter('.embedded-list[for="'.$forAttrValue.'"]')->count()); @@ -27,7 +27,7 @@ public function testEmbeddedListIsDisplaidInEdit() { $crawler = $this->requestEditView('Category', 1); - $forAttrValue = md5('/admin/?entity=Product&action=embeddedList&filters%5Bentity.category%5D=1'); + $forAttrValue = \md5('/admin/?entity=Product&action=embeddedList&filters%5Bentity.category%5D=1'); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(1, $crawler->filter('.embedded-list[for="'.$forAttrValue.'"]')->count()); @@ -37,7 +37,7 @@ public function testEmbeddedListIsDisplaidInShow() { $crawler = $this->requestShowView('Category', 1); - $forAttrValue = md5('/admin/?entity=Product&action=embeddedList&filters%5Bentity.category%5D=1'); + $forAttrValue = \md5('/admin/?entity=Product&action=embeddedList&filters%5Bentity.category%5D=1'); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(1, $crawler->filter('.embedded-list[for="'.$forAttrValue.'"]')->count()); @@ -45,7 +45,7 @@ public function testEmbeddedListIsDisplaidInShow() public function testRequestSingleFilterIsApplied() { - $crawler = $this->requestListView('Product', array('entity.enabled' => false)); + $crawler = $this->requestListView('Product', ['entity.enabled' => false]); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(10, $crawler->filter('#main tr[data-id]')->count()); @@ -53,7 +53,7 @@ public function testRequestSingleFilterIsApplied() public function testRequestNoFieldFilterCausesNoError() { - $crawler = $this->requestListView('Product', array('entity.foo' => 'bar')); + $crawler = $this->requestListView('Product', ['entity.foo' => 'bar']); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(15, $crawler->filter('#main tr[data-id]')->count()); @@ -62,7 +62,7 @@ public function testRequestNoFieldFilterCausesNoError() public function testRequestManyFiltersAreApplied() { $crawler = $this->requestListView( - 'Product', array('entity.enabled' => false, 'entity.oddEven' => 'even') + 'Product', ['entity.enabled' => false, 'entity.oddEven' => 'even'] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -71,7 +71,7 @@ public function testRequestManyFiltersAreApplied() public function testRequestFilterWithoutAliasIsCompletedAndApplied() { - $crawler = $this->requestListView('Product', array('enabled' => false)); + $crawler = $this->requestListView('Product', ['enabled' => false]); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(10, $crawler->filter('#main tr[data-id]')->count()); @@ -80,7 +80,7 @@ public function testRequestFilterWithoutAliasIsCompletedAndApplied() public function testRequestFiltersArePassedToSearchForm() { $crawler = $this->requestListView( - 'Product', array('entity.enabled' => false, 'entity.oddEven' => 'even') + 'Product', ['entity.enabled' => false, 'entity.oddEven' => 'even'] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -100,7 +100,7 @@ public function testRequestFiltersArePassedToSearchForm() public function testRequestMultivalueFiltersAreApplied() { $crawler = $this->requestListView( - 'Product', array('entity.oddEven' => array('odd', 'even')) + 'Product', ['entity.oddEven' => ['odd', 'even']] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -123,7 +123,7 @@ public function testRequestMultivalueFiltersAreApplied() public function testRequestFilterIsAppliedToSearchAction() { - $crawler = $this->requestSearchView('ref000', 'Product', array('entity.enabled' => false)); + $crawler = $this->requestSearchView('ref000', 'Product', ['entity.enabled' => false]); $this->assertSame(10, $crawler->filter('#main tr[data-id]')->count()); } @@ -131,7 +131,7 @@ public function testRequestFilterIsAppliedToSearchAction() public function testRequestNullFilterIsApplied() { $crawler = $this->requestListView( - 'Product', array('entity.phone' => '_NULL') + 'Product', ['entity.phone' => '_NULL'] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -141,7 +141,7 @@ public function testRequestNullFilterIsApplied() public function testRequestNotNullFilterIsApplied() { $crawler = $this->requestListView( - 'Product', array('entity.phone' => '_NOT_NULL') + 'Product', ['entity.phone' => '_NOT_NULL'] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -155,7 +155,7 @@ public function testListSortIsUsedForEmbedddLists() { $crawler = $this->requestEditView('Category', 1); - $forAttrValue = md5('/admin/?entity=Product&action=embeddedList&filters%5Bentity.category%5D=1'); + $forAttrValue = \md5('/admin/?entity=Product&action=embeddedList&filters%5Bentity.category%5D=1'); $createdAtTh = 'th[data-property-name="createdAt"].sorted'; $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -164,9 +164,9 @@ public function testListSortIsUsedForEmbedddLists() public function testDefinedSortIsUsedForEmbedddLists() { - $crawler = $this->getBackendPage(array('entity' => 'Purchase', 'action' => 'embeddedList')); + $crawler = $this->getBackendPage(['entity' => 'Purchase', 'action' => 'embeddedList']); - $forAttrValue = md5('/admin/?entity=Purchase&action=embeddedList'); + $forAttrValue = \md5('/admin/?entity=Purchase&action=embeddedList'); $createdAtTh = 'th[data-property-name="createdAt"].sorted'; $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -175,7 +175,7 @@ public function testDefinedSortIsUsedForEmbedddLists() public function testDefaultOpenNewTabConfigForEmbedddLists() { - $crawler = $this->getBackendPage(array('entity' => 'Product', 'action' => 'embeddedList')); + $crawler = $this->getBackendPage(['entity' => 'Product', 'action' => 'embeddedList']); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(0, $crawler->filter('.embedded-list .open-new-tab')->count()); @@ -183,7 +183,7 @@ public function testDefaultOpenNewTabConfigForEmbedddLists() public function testSetOpenNewTabConfigForEmbedddLists() { - $crawler = $this->getBackendPage(array('entity' => 'Purchase', 'action' => 'embeddedList')); + $crawler = $this->getBackendPage(['entity' => 'Purchase', 'action' => 'embeddedList']); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(1, $crawler->filter('.embedded-list .open-new-tab')->count()); diff --git a/tests/Controller/ListFormFiltersTest.php b/tests/Controller/ListFormFiltersTest.php index ba53146c..33bdada2 100644 --- a/tests/Controller/ListFormFiltersTest.php +++ b/tests/Controller/ListFormFiltersTest.php @@ -10,7 +10,7 @@ public function setUp() { parent::setUp(); - $this->initClient(array('environment' => 'list_form_filters')); + $this->initClient(['environment' => 'list_form_filters']); } public function testListFiltersAreDisplaid() @@ -29,7 +29,7 @@ public function testListFiltersAreDisplaid() public function testFormSingleFilterIsApplied() { - $crawler = $this->requestListView('Product', array(), array('enabled' => false)); + $crawler = $this->requestListView('Product', [], ['enabled' => false]); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(10, $crawler->filter('#main tr[data-id]')->count()); @@ -37,7 +37,7 @@ public function testFormSingleFilterIsApplied() public function testFormSingleEasyadminAutocompleteFilterIsApplied() { - $crawler = $this->requestListView('Product', array(), array('category' => array('autocomplete' => array(1)))); + $crawler = $this->requestListView('Product', [], ['category' => ['autocomplete' => [1]]]); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(10, $crawler->filter('#main tr[data-id]')->count()); diff --git a/tests/Controller/RequestParametersTest.php b/tests/Controller/RequestParametersTest.php index 7653b856..777884db 100644 --- a/tests/Controller/RequestParametersTest.php +++ b/tests/Controller/RequestParametersTest.php @@ -10,12 +10,12 @@ public function setUp() { parent::setUp(); - $this->initClient(array('environment' => 'default_backend')); + $this->initClient(['environment' => 'default_backend']); } public function testRequestSingleFilterIsApplied() { - $crawler = $this->requestListView('Product', array('entity.enabled' => false)); + $crawler = $this->requestListView('Product', ['entity.enabled' => false]); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(10, $crawler->filter('#main tr[data-id]')->count()); @@ -23,7 +23,7 @@ public function testRequestSingleFilterIsApplied() public function testRequestNoFieldFilterCausesNoError() { - $crawler = $this->requestListView('Product', array('entity.foo' => 'bar')); + $crawler = $this->requestListView('Product', ['entity.foo' => 'bar']); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(15, $crawler->filter('#main tr[data-id]')->count()); @@ -32,7 +32,7 @@ public function testRequestNoFieldFilterCausesNoError() public function testRequestManyFiltersAreApplied() { $crawler = $this->requestListView( - 'Product', array('entity.enabled' => false, 'entity.oddEven' => 'even') + 'Product', ['entity.enabled' => false, 'entity.oddEven' => 'even'] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -41,7 +41,7 @@ public function testRequestManyFiltersAreApplied() public function testRequestFilterWithoutAliasIsCompletedAndApplied() { - $crawler = $this->requestListView('Product', array('enabled' => false)); + $crawler = $this->requestListView('Product', ['enabled' => false]); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(10, $crawler->filter('#main tr[data-id]')->count()); @@ -50,7 +50,7 @@ public function testRequestFilterWithoutAliasIsCompletedAndApplied() public function testRequestFiltersArePassedToSearchForm() { $crawler = $this->requestListView( - 'Product', array('entity.enabled' => false, 'entity.oddEven' => 'even') + 'Product', ['entity.enabled' => false, 'entity.oddEven' => 'even'] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -70,7 +70,7 @@ public function testRequestFiltersArePassedToSearchForm() public function testRequestMultivalueFiltersAreApplied() { $crawler = $this->requestListView( - 'Product', array('entity.oddEven' => array('odd', 'even')) + 'Product', ['entity.oddEven' => ['odd', 'even']] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -93,7 +93,7 @@ public function testRequestMultivalueFiltersAreApplied() public function testRequestFilterIsAppliedToSearchAction() { - $crawler = $this->requestSearchView('ref000', 'Product', array('entity.enabled' => false)); + $crawler = $this->requestSearchView('ref000', 'Product', ['entity.enabled' => false]); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(10, $crawler->filter('#main tr[data-id]')->count()); @@ -102,7 +102,7 @@ public function testRequestFilterIsAppliedToSearchAction() public function testRequestNullFilterIsApplied() { $crawler = $this->requestListView( - 'Product', array('entity.phone' => '_NULL') + 'Product', ['entity.phone' => '_NULL'] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -112,7 +112,7 @@ public function testRequestNullFilterIsApplied() public function testRequestNotNullFilterIsApplied() { $crawler = $this->requestListView( - 'Product', array('entity.phone' => '_NOT_NULL') + 'Product', ['entity.phone' => '_NOT_NULL'] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); @@ -125,7 +125,7 @@ public function testRequestNotNullFilterIsApplied() public function testRequestEmptyFilterIsIgnored() { $crawler = $this->requestListView( - 'Product', array('entity.phone' => '') + 'Product', ['entity.phone' => ''] ); $this->assertSame(200, $this->client->getResponse()->getStatusCode()); diff --git a/tests/Controller/UserRolesTest.php b/tests/Controller/UserRolesTest.php index 6e982fcd..c490e16b 100644 --- a/tests/Controller/UserRolesTest.php +++ b/tests/Controller/UserRolesTest.php @@ -12,7 +12,7 @@ public function setUp() { parent::setUp(); - $this->initClient(array('environment' => 'user_roles')); + $this->initClient(['environment' => 'user_roles']); } private function logIn($roles = ['ROLE_ADMIN']) @@ -23,7 +23,7 @@ private function logIn($roles = ['ROLE_ADMIN']) $firewallContext = 'secured_area'; $token = new UsernamePasswordToken('admin', null, $firewallContext, $roles); - $session->set('_security_'.$firewallContext, serialize($token)); + $session->set('_security_'.$firewallContext, \serialize($token)); $session->save(); $cookie = new Cookie($session->getName(), $session->getId()); @@ -42,7 +42,7 @@ public function testAdminIsNotReachableWithoutMinimumRole() $this->assertSame( 'You must be granted ROLE_ADMIN role to access admin ! (403 Forbidden)', - trim($crawler->filterXPath('//head/title')->text()) + \trim($crawler->filterXPath('//head/title')->text()) ); } @@ -152,7 +152,7 @@ public function testEntityActionsAreFilteredOnPrefixedRoles() $this->assertSame(403, $this->client->getResponse()->getStatusCode()); $this->assertSame( 'You must be granted ROLE_CATEGORY_EDIT role to perform this entity action ! (403 Forbidden)', - trim($crawler->filterXPath('//head/title')->text()) + \trim($crawler->filterXPath('//head/title')->text()) ); $this->getBackendPage(['entity' => 'Category', 'action' => 'show', 'id' => 1]); @@ -175,7 +175,7 @@ public function testEntityActionsAreFilteredOnSpecificRoles() $this->assertSame(403, $this->client->getResponse()->getStatusCode()); $this->assertSame( 'You must be granted ROLE_TEST_SHOW_PRODUCT role to perform this entity action ! (403 Forbidden)', - trim($crawler->filterXPath('//head/title')->text()) + \trim($crawler->filterXPath('//head/title')->text()) ); } @@ -205,19 +205,19 @@ public function testEntityActionsAreForbiddenOnCaseInsensitiveSpecificRoles() $this->assertSame(403, $this->client->getResponse()->getStatusCode()); $this->assertSame( 'You must be granted ROLE_TEST_EDIT_PRODUCT role to perform this entity action ! (403 Forbidden)', - trim($crawler->filterXPath('//head/title')->text()) + \trim($crawler->filterXPath('//head/title')->text()) ); $crawler = $this->getBackendPage(['entity' => 'Product', 'action' => 'Edit', 'id' => 1]); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); $this->assertSame( 'You must be granted ROLE_TEST_EDIT_PRODUCT role to perform this entity action ! (403 Forbidden)', - trim($crawler->filterXPath('//head/title')->text()) + \trim($crawler->filterXPath('//head/title')->text()) ); $crawler = $this->getBackendPage(['entity' => 'Product', 'action' => 'EDIT', 'id' => 1]); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); $this->assertSame( 'You must be granted ROLE_TEST_EDIT_PRODUCT role to perform this entity action ! (403 Forbidden)', - trim($crawler->filterXPath('//head/title')->text()) + \trim($crawler->filterXPath('//head/title')->text()) ); // Show @@ -225,19 +225,19 @@ public function testEntityActionsAreForbiddenOnCaseInsensitiveSpecificRoles() $this->assertSame(403, $this->client->getResponse()->getStatusCode()); $this->assertSame( 'You must be granted ROLE_TEST_SHOW_PRODUCT role to perform this entity action ! (403 Forbidden)', - trim($crawler->filterXPath('//head/title')->text()) + \trim($crawler->filterXPath('//head/title')->text()) ); $crawler = $this->getBackendPage(['entity' => 'Product', 'action' => 'Show', 'id' => 1]); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); $this->assertSame( 'You must be granted ROLE_TEST_SHOW_PRODUCT role to perform this entity action ! (403 Forbidden)', - trim($crawler->filterXPath('//head/title')->text()) + \trim($crawler->filterXPath('//head/title')->text()) ); $crawler = $this->getBackendPage(['entity' => 'Product', 'action' => 'SHOW', 'id' => 1]); $this->assertSame(403, $this->client->getResponse()->getStatusCode()); $this->assertSame( 'You must be granted ROLE_TEST_SHOW_PRODUCT role to perform this entity action ! (403 Forbidden)', - trim($crawler->filterXPath('//head/title')->text()) + \trim($crawler->filterXPath('//head/title')->text()) ); } } diff --git a/tests/Fixtures/AbstractTestCase.php b/tests/Fixtures/AbstractTestCase.php index 426217ef..523f8727 100644 --- a/tests/Fixtures/AbstractTestCase.php +++ b/tests/Fixtures/AbstractTestCase.php @@ -31,7 +31,7 @@ protected function setUp() $this->initDatabase(); } - protected function initClient(array $options = array()) + protected function initClient(array $options = []) { $this->client = static::createClient($options); } @@ -47,11 +47,11 @@ protected function initDatabase() $originalDbPath = $buildDir.'/original_test.db'; $targetDbPath = $buildDir.'/test.db'; - if (!file_exists($originalDbPath)) { - throw new \RuntimeException(sprintf("The fixtures file used for the tests (%s) doesn't exist. This means that the execution of the bootstrap.php script that generates that file failed. Open %s/bootstrap.php and replace `NullOutput as ConsoleOutput` by `ConsoleOutput` to see the actual errors in the console.", $originalDbPath, realpath(__DIR__.'/..'))); + if (!\file_exists($originalDbPath)) { + throw new \RuntimeException(\sprintf("The fixtures file used for the tests (%s) doesn't exist. This means that the execution of the bootstrap.php script that generates that file failed. Open %s/bootstrap.php and replace `NullOutput as ConsoleOutput` by `ConsoleOutput` to see the actual errors in the console.", $originalDbPath, \realpath(__DIR__.'/..'))); } - copy($originalDbPath, $targetDbPath); + \copy($originalDbPath, $targetDbPath); } /** @@ -61,7 +61,7 @@ protected function initDatabase() */ protected function getBackendPage(array $queryParameters = []) { - return $this->client->request('GET', '/admin/?'.http_build_query($queryParameters, '', '&')); + return $this->client->request('GET', '/admin/?'.\http_build_query($queryParameters, '', '&')); } /** @@ -69,21 +69,21 @@ protected function getBackendPage(array $queryParameters = []) */ protected function getBackendHomepage() { - return $this->getBackendPage(array('entity' => 'Category', 'view' => 'list')); + return $this->getBackendPage(['entity' => 'Category', 'view' => 'list']); } /** * @return Crawler */ - protected function requestListView($entityName = 'Category', array $requestFilters = array(), array $formFilters = array()) + protected function requestListView($entityName = 'Category', array $requestFilters = [], array $formFilters = []) { - return $this->getBackendPage(array( + return $this->getBackendPage([ 'action' => 'list', 'entity' => $entityName, 'view' => 'list', 'filters' => $requestFilters, 'form_filters' => $formFilters, - )); + ]); } /** @@ -91,24 +91,24 @@ protected function requestListView($entityName = 'Category', array $requestFilte */ protected function requestShowView($entityName = 'Category', $entityId = 200) { - return $this->getBackendPage(array( + return $this->getBackendPage([ 'action' => 'show', 'entity' => $entityName, 'id' => $entityId, - )); + ]); } /** * @return Crawler */ - protected function requestSearchView($searchQuery = 'cat', $entityName = 'Category', array $requestFilters = array()) + protected function requestSearchView($searchQuery = 'cat', $entityName = 'Category', array $requestFilters = []) { - return $this->getBackendPage(array( + return $this->getBackendPage([ 'action' => 'search', 'entity' => $entityName, 'query' => $searchQuery, 'filters' => $requestFilters, - )); + ]); } /** @@ -116,10 +116,10 @@ protected function requestSearchView($searchQuery = 'cat', $entityName = 'Catego */ protected function requestNewView($entityName = 'Category') { - return $this->getBackendPage(array( + return $this->getBackendPage([ 'action' => 'new', 'entity' => $entityName, - )); + ]); } /** @@ -127,11 +127,11 @@ protected function requestNewView($entityName = 'Category') */ protected function requestEditView($entityName = 'Category', $entityId = '200') { - return $this->getBackendPage(array( + return $this->getBackendPage([ 'action' => 'edit', 'entity' => $entityName, 'id' => $entityId, - )); + ]); } /** @@ -139,11 +139,12 @@ protected function requestEditView($entityName = 'Category', $entityId = '200') */ protected function requestNewAjaxView($entityName = 'Category') { - $this->getBackendPage(array( + $this->getBackendPage([ 'action' => 'newAjax', 'entity' => $entityName, - )); - $response = json_decode($this->client->getResponse()->getContent(), true); + ]); + $response = \json_decode($this->client->getResponse()->getContent(), true); + return new Crawler($response['html'], $this->client->getRequest()->getUri()); } } diff --git a/tests/Fixtures/App/AppKernel.php b/tests/Fixtures/App/AppKernel.php index 230752b7..8f6b4c4b 100644 --- a/tests/Fixtures/App/AppKernel.php +++ b/tests/Fixtures/App/AppKernel.php @@ -20,7 +20,7 @@ class AppKernel extends Kernel { public function registerBundles() { - return array( + return [ new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), @@ -29,16 +29,16 @@ public function registerBundles() new EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle(), new AlterPHP\EasyAdminExtensionBundle\EasyAdminExtensionBundle(), new AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\AppTestBundle(), - ); + ]; } public function registerContainerConfiguration(LoaderInterface $loader) { - $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); + $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yaml'); $loader->load(function (ContainerBuilder $container) { - $container->loadFromExtension('framework', array( + $container->loadFromExtension('framework', [ 'assets' => null, - )); + ]); }); } diff --git a/tests/Fixtures/App/DynamicConfigLoadingKernel.php b/tests/Fixtures/App/DynamicConfigLoadingKernel.php index fd6646ed..0b558538 100644 --- a/tests/Fixtures/App/DynamicConfigLoadingKernel.php +++ b/tests/Fixtures/App/DynamicConfigLoadingKernel.php @@ -33,7 +33,7 @@ public function __construct($backendConfig) */ public function getContainerClass() { - return 'TestDynamicConfigContainer'.md5(serialize($this->backendConfig)); + return 'TestDynamicConfigContainer'.\md5(\serialize($this->backendConfig)); } public function registerContainerConfiguration(LoaderInterface $loader) diff --git a/tests/Fixtures/App/config/config.yml b/tests/Fixtures/App/config/config.yaml similarity index 96% rename from tests/Fixtures/App/config/config.yml rename to tests/Fixtures/App/config/config.yaml index 406e0dad..ada16e14 100644 --- a/tests/Fixtures/App/config/config.yml +++ b/tests/Fixtures/App/config/config.yaml @@ -1,5 +1,8 @@ # Basic config common to all functional tests # Can be easily overridden in each test config +imports: + - { resource: services.yaml } + parameters: locale: en database_path: '%kernel.root_dir%/../../../build/test.db' @@ -9,7 +12,7 @@ framework: translator: ~ default_locale: '%locale%' test: ~ - router: { resource: '%kernel.root_dir%/config/routing_base.yml' } + router: { resource: '%kernel.root_dir%/config/routing_base.yaml' } form: true validation: { enable_annotations: true } templating: { engines: ['twig'] } diff --git a/tests/Fixtures/App/config/config_autocomplete_add.yml b/tests/Fixtures/App/config/config_autocomplete_add.yaml similarity index 93% rename from tests/Fixtures/App/config/config_autocomplete_add.yml rename to tests/Fixtures/App/config/config_autocomplete_add.yaml index 28582fd4..99eaede5 100644 --- a/tests/Fixtures/App/config/config_autocomplete_add.yml +++ b/tests/Fixtures/App/config/config_autocomplete_add.yaml @@ -1,5 +1,5 @@ imports: - - { resource: config.yml } + - { resource: config.yaml } easy_admin: entities: diff --git a/tests/Fixtures/App/config/config_custom_types.yml b/tests/Fixtures/App/config/config_custom_types.yaml similarity index 93% rename from tests/Fixtures/App/config/config_custom_types.yml rename to tests/Fixtures/App/config/config_custom_types.yaml index 9f9f763e..691a220c 100644 --- a/tests/Fixtures/App/config/config_custom_types.yml +++ b/tests/Fixtures/App/config/config_custom_types.yaml @@ -1,5 +1,5 @@ imports: - - { resource: config.yml } + - { resource: config.yaml } easy_admin_extension: custom_types: diff --git a/tests/Fixtures/App/config/config_default_backend.yml b/tests/Fixtures/App/config/config_default_backend.yaml similarity index 92% rename from tests/Fixtures/App/config/config_default_backend.yml rename to tests/Fixtures/App/config/config_default_backend.yaml index b768f632..74302759 100644 --- a/tests/Fixtures/App/config/config_default_backend.yml +++ b/tests/Fixtures/App/config/config_default_backend.yaml @@ -1,5 +1,5 @@ imports: - - { resource: config.yml } + - { resource: config.yaml } easy_admin: entities: diff --git a/tests/Fixtures/App/config/config_embedded_list.yml b/tests/Fixtures/App/config/config_embedded_list.yaml similarity index 97% rename from tests/Fixtures/App/config/config_embedded_list.yml rename to tests/Fixtures/App/config/config_embedded_list.yaml index cccd2c10..f3c724ff 100644 --- a/tests/Fixtures/App/config/config_embedded_list.yml +++ b/tests/Fixtures/App/config/config_embedded_list.yaml @@ -1,5 +1,5 @@ imports: - - { resource: config.yml } + - { resource: config.yaml } easy_admin_extension: embedded_list: diff --git a/tests/Fixtures/App/config/config_list_form_filters.yml b/tests/Fixtures/App/config/config_list_form_filters.yaml similarity index 94% rename from tests/Fixtures/App/config/config_list_form_filters.yml rename to tests/Fixtures/App/config/config_list_form_filters.yaml index f74e024a..1ccec7b6 100644 --- a/tests/Fixtures/App/config/config_list_form_filters.yml +++ b/tests/Fixtures/App/config/config_list_form_filters.yaml @@ -1,5 +1,5 @@ imports: - - { resource: config.yml } + - { resource: config.yaml } easy_admin: entities: diff --git a/tests/Fixtures/App/config/config_test.yaml b/tests/Fixtures/App/config/config_test.yaml new file mode 100644 index 00000000..cd90c172 --- /dev/null +++ b/tests/Fixtures/App/config/config_test.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: config.yaml } diff --git a/tests/Fixtures/App/config/config_test.yml b/tests/Fixtures/App/config/config_test.yml deleted file mode 100644 index 8e0b6ff0..00000000 --- a/tests/Fixtures/App/config/config_test.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: config.yml } diff --git a/tests/Fixtures/App/config/config_user_roles.yml b/tests/Fixtures/App/config/config_user_roles.yaml similarity index 98% rename from tests/Fixtures/App/config/config_user_roles.yml rename to tests/Fixtures/App/config/config_user_roles.yaml index 9cd0c26e..dec39559 100644 --- a/tests/Fixtures/App/config/config_user_roles.yml +++ b/tests/Fixtures/App/config/config_user_roles.yaml @@ -1,5 +1,5 @@ imports: - - { resource: config.yml } + - { resource: config.yaml } security: role_hierarchy: ROLE_GROUP_TEST: diff --git a/tests/Fixtures/App/config/routing_base.yml b/tests/Fixtures/App/config/routing_base.yaml similarity index 100% rename from tests/Fixtures/App/config/routing_base.yml rename to tests/Fixtures/App/config/routing_base.yaml diff --git a/tests/Fixtures/App/config/services.yaml b/tests/Fixtures/App/config/services.yaml new file mode 100644 index 00000000..2dda648c --- /dev/null +++ b/tests/Fixtures/App/config/services.yaml @@ -0,0 +1,4 @@ +services: + _defaults: + autowire: true + autoconfigure: true diff --git a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadAdminGroups.php b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadAdminGroups.php index fb1af853..160e7c6e 100644 --- a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadAdminGroups.php +++ b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadAdminGroups.php @@ -16,10 +16,10 @@ public function getOrder() public function load(ObjectManager $manager) { - foreach (range(1, 20) as $i) { + foreach (\range(1, 20) as $i) { $adminGroup = new AdminGroup(); $adminGroup->setName('admin-group'.$i); - $adminGroup->setRoles(array('ROLE_GROUP_'.$i, 'ROLE_GROUP_'.($i + 1))); + $adminGroup->setRoles(['ROLE_GROUP_'.$i, 'ROLE_GROUP_'.($i + 1)]); $this->addReference('admin-group-'.$i, $adminGroup); $manager->persist($adminGroup); diff --git a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadAdminUsers.php b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadAdminUsers.php index 85d8fc68..df6bd04e 100644 --- a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadAdminUsers.php +++ b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadAdminUsers.php @@ -16,14 +16,14 @@ public function getOrder() public function load(ObjectManager $manager) { - foreach (range(1, 20) as $i) { + foreach (\range(1, 20) as $i) { $adminUser = new AdminUser(); - $adminUser->updateFromData(array( + $adminUser->updateFromData([ 'gSuiteId' => 'g-suite-id-'.$i, 'email' => 'email-'.$i.'@easyadmin.com', 'lastname' => 'lastname-'.$i, 'firstname' => 'firstname-'.$i, - )); + ]); // All users are members of first AdminGroup $adminUser->addGroup($this->getReference('admin-group-1')); diff --git a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadCategories.php b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadCategories.php index 4472723a..4ff3e340 100644 --- a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadCategories.php +++ b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadCategories.php @@ -25,7 +25,7 @@ public function getOrder() public function load(ObjectManager $manager) { - foreach (range(1, 100) as $i) { + foreach (\range(1, 100) as $i) { $category = new Category(); $category->setName('Parent Category #'.$i); @@ -35,7 +35,7 @@ public function load(ObjectManager $manager) $manager->flush(); - foreach (range(1, 100) as $i) { + foreach (\range(1, 100) as $i) { $category = new Category(); $category->setName('Category #'.$i); $category->setParent($this->getReference('category-'.$i)); diff --git a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadProducts.php b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadProducts.php index 2bec0cb3..06ad7853 100644 --- a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadProducts.php +++ b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadProducts.php @@ -18,7 +18,7 @@ class LoadProducts extends AbstractFixture implements OrderedFixtureInterface { - private $phrases = array( + private $phrases = [ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'Pellentesque vitae velit ex.', 'Mauris dapibus, risus quis suscipit vulputate, eros diam egestas libero, eu vulputate eros eros eu risus.', @@ -36,7 +36,7 @@ class LoadProducts extends AbstractFixture implements OrderedFixtureInterface 'Sed varius a risus eget aliquam.', 'Nunc viverra elit ac laoreet suscipit.', 'Pellentesque et sapien pulvinar, consectetur eros ac, vehicula odio.', - ); + ]; public function getOrder() { @@ -45,12 +45,12 @@ public function getOrder() public function load(ObjectManager $manager) { - foreach (range(1, 100) as $i) { + foreach (\range(1, 100) as $i) { $category = $i <= 10 ? $this->getReference('category-1') : $this->getRandomCategory(); $product = new Product(); $product->setEnabled($i % 10 ? true : false); $product->setOddEven($i % 4 ? 'odd' : 'even'); - $product->setReference('ref'.str_pad($i, 6, '0', STR_PAD_LEFT)); + $product->setReference('ref'.\str_pad($i, 6, '0', STR_PAD_LEFT)); $product->setName($this->getRandomName()); $product->setReplenishmentType($this->getReplenishmentType()); $product->setPrice($this->getRandomPrice()); @@ -70,7 +70,7 @@ public function load(ObjectManager $manager) public function getRandomTags() { - $tags = array( + $tags = [ 'books', 'electronics', 'GPS', @@ -86,25 +86,25 @@ public function getRandomTags() 'TV & video', 'videogames', 'wearables', - ); + ]; - $numTags = mt_rand(2, 4); - shuffle($tags); + $numTags = \mt_rand(2, 4); + \shuffle($tags); - return array_slice($tags, 0, $numTags - 1); + return \array_slice($tags, 0, $numTags - 1); } public function getRandomEan() { - $chars = str_split('0123456789'); - $count = count($chars) - 1; + $chars = \str_split('0123456789'); + $count = \count($chars) - 1; $ean13 = ''; do { - $ean13 .= $chars[mt_rand(0, $count)]; - } while (strlen($ean13) < 13); + $ean13 .= $chars[\mt_rand(0, $count)]; + } while (\strlen($ean13) < 13); $checksum = 0; - foreach (str_split(strrev($ean13)) as $pos => $val) { + foreach (\str_split(\strrev($ean13)) as $pos => $val) { $checksum += $val * (3 - 2 * ($pos % 2)); } $checksum = ((10 - ($checksum % 10)) % 10); @@ -114,52 +114,52 @@ public function getRandomEan() public function getRandomName() { - $words = array( + $words = [ 'Lorem', 'Ipsum', 'Sit', 'Amet', 'Adipiscing', 'Elit', 'Vitae', 'Velit', 'Mauris', 'Dapibus', 'Suscipit', 'Vulputate', 'Eros', 'Diam', 'Egestas', 'Libero', 'Platea', 'Dictumst', 'Tempus', 'Commodo', 'Mattis', 'Donec', 'Posuere', 'Eleifend', - ); + ]; $numWords = 2; - shuffle($words); + \shuffle($words); - return 'Product '.implode(' ', array_slice($words, 0, $numWords)); + return 'Product '.\implode(' ', \array_slice($words, 0, $numWords)); } public function getRandomPrice() { - $cents = array('00', '29', '39', '49', '99'); + $cents = ['00', '29', '39', '49', '99']; - return (float) mt_rand(2, 79).'.'.$cents[array_rand($cents)]; + return (float) \mt_rand(2, 79).'.'.$cents[\array_rand($cents)]; } private function getRandomCategory() { // First category is reserved for first products (test purpose) - return $this->getReference('category-'.mt_rand(2, 100)); + return $this->getReference('category-'.\mt_rand(2, 100)); } public function getRandomDescription() { - $numPhrases = mt_rand(5, 10); - shuffle($this->phrases); + $numPhrases = \mt_rand(5, 10); + \shuffle($this->phrases); - return implode(' ', array_slice($this->phrases, 0, $numPhrases - 1)); + return \implode(' ', \array_slice($this->phrases, 0, $numPhrases - 1)); } public function getRandomHtmlFeatures() { $numFeatures = 2; - shuffle($this->phrases); + \shuffle($this->phrases); - return '
  • '.implode('
  • ', array_slice($this->phrases, 0, $numFeatures)).'
'; + return '
  • '.\implode('
  • ', \array_slice($this->phrases, 0, $numFeatures)).'
'; } public function getReplenishmentType() { $replenishmentTypeValues = Product::getReplenishmentTypeValues(); - return $replenishmentTypeValues[mt_rand(0, count($replenishmentTypeValues)-1)]; + return $replenishmentTypeValues[\mt_rand(0, \count($replenishmentTypeValues) - 1)]; } } diff --git a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadPurchases.php b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadPurchases.php index 439e6a78..dadf0f52 100644 --- a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadPurchases.php +++ b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadPurchases.php @@ -17,27 +17,27 @@ public function getOrder() public function load(ObjectManager $manager) { - foreach (range(1, 30) as $i) { + foreach (\range(1, 30) as $i) { $purchase = new Purchase(); $purchase->setGuid($this->generateGuid()); $purchase->setDeliveryDate(new \DateTime("+$i days")); $purchase->setCreatedAt(new \DateTime("now +$i seconds")); $purchase->setShipping(new \StdClass()); $purchase->setDeliveryHour($this->getRandomHour()); - $purchase->setBillingAddress(json_encode(array( + $purchase->setBillingAddress(\json_encode([ 'line1' => '1234 Main Street', 'line2' => 'Big City, XX 23456', - ))); + ])); $purchase->setBuyer($this->getReference('user-'.($i % 20 + 1))); $this->addReference('purchase-'.$i, $purchase); $manager->persist($purchase); $manager->flush(); - $numItemsPurchased = rand(1, 5); - foreach (range(1, $numItemsPurchased) as $j) { + $numItemsPurchased = \rand(1, 5); + foreach (\range(1, $numItemsPurchased) as $j) { $item = new PurchaseItem(); - $item->setQuantity(rand(1, 3)); + $item->setQuantity(\rand(1, 3)); $item->setProduct($this->getRandomProduct()); $item->setTaxRate(0.21); $item->setPurchase($this->getReference('purchase-'.$i)); @@ -51,12 +51,12 @@ public function load(ObjectManager $manager) private function generateGuid() { - return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', - mt_rand(0, 0xffff), mt_rand(0, 0xffff), - mt_rand(0, 0xffff), - mt_rand(0, 0x0fff) | 0x4000, - mt_rand(0, 0x3fff) | 0x8000, - mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + return \sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + \mt_rand(0, 0xffff), \mt_rand(0, 0xffff), + \mt_rand(0, 0xffff), + \mt_rand(0, 0x0fff) | 0x4000, + \mt_rand(0, 0x3fff) | 0x8000, + \mt_rand(0, 0xffff), \mt_rand(0, 0xffff), \mt_rand(0, 0xffff) ); } @@ -64,12 +64,12 @@ private function getRandomHour() { $date = new \DateTime(); - return $date->setTime(rand(0, 23), 0); + return $date->setTime(\rand(0, 23), 0); } private function getRandomProduct() { - $productId = rand(1, 100); + $productId = \rand(1, 100); return $this->getReference('product-'.$productId); } diff --git a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadUsers.php b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadUsers.php index e2aee50e..2ad39b01 100644 --- a/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadUsers.php +++ b/tests/Fixtures/AppTestBundle/DataFixtures/ORM/LoadUsers.php @@ -16,7 +16,7 @@ public function getOrder() public function load(ObjectManager $manager) { - foreach (range(1, 20) as $i) { + foreach (\range(1, 20) as $i) { $user = new User(); $user->setUsername('user'.$i); $user->setEmail('user'.$i.'@example.com'); diff --git a/tests/Fixtures/AppTestBundle/Entity/FunctionalTests/Dummy.php b/tests/Fixtures/AppTestBundle/Entity/FunctionalTests/Dummy.php index 16497232..ed4c9207 100644 --- a/tests/Fixtures/AppTestBundle/Entity/FunctionalTests/Dummy.php +++ b/tests/Fixtures/AppTestBundle/Entity/FunctionalTests/Dummy.php @@ -1,4 +1,6 @@ - 'auto', 'replenishment_type.trigger' => 'trigger', 'replenishment_type.manual' => 'manual', - ); + ]; if (!$withLabelsAsIndexes) { - return array_values($replenishmentTypeValues); + return \array_values($replenishmentTypeValues); } return $replenishmentTypeValues; diff --git a/tests/Fixtures/AppTestBundle/Entity/FunctionalTests/Purchase.php b/tests/Fixtures/AppTestBundle/Entity/FunctionalTests/Purchase.php index 21627415..82bf24b9 100644 --- a/tests/Fixtures/AppTestBundle/Entity/FunctionalTests/Purchase.php +++ b/tests/Fixtures/AppTestBundle/Entity/FunctionalTests/Purchase.php @@ -76,7 +76,7 @@ class Purchase * @var array * @ORM\Column(type="json_array") */ - protected $billingAddress = array(); + protected $billingAddress = []; /** * The user who made the purchase. @@ -228,7 +228,7 @@ public function getShipping() */ public function generateId($storeId = 1) { - return preg_replace('/[^0-9]/i', '', sprintf('%d%d%03d%s', $storeId, date('Y'), date('z'), microtime())); + return \preg_replace('/[^0-9]/i', '', \sprintf('%d%d%03d%s', $storeId, \date('Y'), \date('z'), \microtime())); } public function __toString() diff --git a/tests/Form/Transformer/RestoreRolesTransformerTest.php b/tests/Form/Transformer/RestoreRolesTransformerTest.php index b9816700..380c9daa 100644 --- a/tests/Form/Transformer/RestoreRolesTransformerTest.php +++ b/tests/Form/Transformer/RestoreRolesTransformerTest.php @@ -23,7 +23,7 @@ public function testInvalidStateTransform() $roleBuilder = $this->createMock(EditableRolesHelper::class); $transformer = new RestoreRolesTransformer($roleBuilder); - $transformer->transform(array()); + $transformer->transform([]); } public function testInvalidStateReverseTransform() @@ -33,7 +33,7 @@ public function testInvalidStateReverseTransform() $roleBuilder = $this->createMock(EditableRolesHelper::class); $transformer = new RestoreRolesTransformer($roleBuilder); - $transformer->reverseTransform(array()); + $transformer->reverseTransform([]); } public function testNullIsTransformedToNull() @@ -41,7 +41,7 @@ public function testNullIsTransformedToNull() $roleBuilder = $this->createMock(EditableRolesHelper::class); $transformer = new RestoreRolesTransformer($roleBuilder); - $transformer->setOriginalRoles(array()); + $transformer->setOriginalRoles([]); $this->assertNull($transformer->transform(null)); } @@ -51,9 +51,9 @@ public function testValidTransform() $roleBuilder = $this->createMock(EditableRolesHelper::class); $transformer = new RestoreRolesTransformer($roleBuilder); - $transformer->setOriginalRoles(array()); + $transformer->setOriginalRoles([]); - $data = array('ROLE_FOO'); + $data = ['ROLE_FOO']; $this->assertSame($data, $transformer->transform($data)); } @@ -62,14 +62,14 @@ public function testValidReverseTransform() { $roleBuilder = $this->createMock(EditableRolesHelper::class); - $roleBuilder->expects($this->once())->method('getRoles')->will($this->returnValue(array())); + $roleBuilder->expects($this->once())->method('getRoles')->will($this->returnValue([])); $transformer = new RestoreRolesTransformer($roleBuilder); - $transformer->setOriginalRoles(array('ROLE_HIDDEN')); + $transformer->setOriginalRoles(['ROLE_HIDDEN']); - $data = array('ROLE_FOO'); + $data = ['ROLE_FOO']; - $this->assertSame(array('ROLE_FOO', 'ROLE_HIDDEN'), $transformer->reverseTransform($data)); + $this->assertSame(['ROLE_FOO', 'ROLE_HIDDEN'], $transformer->reverseTransform($data)); } public function testTransformAllowEmptyOriginalRoles() @@ -79,7 +79,7 @@ public function testTransformAllowEmptyOriginalRoles() $transformer = new RestoreRolesTransformer($roleBuilder); $transformer->setOriginalRoles(null); - $data = array('ROLE_FOO'); + $data = ['ROLE_FOO']; $this->assertSame($data, $transformer->transform($data)); } @@ -88,36 +88,36 @@ public function testReverseTransformAllowEmptyOriginalRoles() { $roleBuilder = $this->createMock(EditableRolesHelper::class); - $roleBuilder->expects($this->once())->method('getRoles')->will($this->returnValue(array())); + $roleBuilder->expects($this->once())->method('getRoles')->will($this->returnValue([])); $transformer = new RestoreRolesTransformer($roleBuilder); $transformer->setOriginalRoles(null); - $data = array('ROLE_FOO'); + $data = ['ROLE_FOO']; - $this->assertSame(array('ROLE_FOO'), $transformer->reverseTransform($data)); + $this->assertSame(['ROLE_FOO'], $transformer->reverseTransform($data)); } public function testReverseTransformRevokedHierarchicalRole() { $roleBuilder = $this->createMock(EditableRolesHelper::class); - $availableRoles = array( + $availableRoles = [ 'ROLE_SONATA_ADMIN' => 'ROLE_SONATA_ADMIN', 'ROLE_COMPANY_PERSONAL_MODERATOR' => 'ROLE_COMPANY_PERSONAL_MODERATOR: ROLE_COMPANY_USER', 'ROLE_COMPANY_NEWS_MODERATOR' => 'ROLE_COMPANY_NEWS_MODERATOR: ROLE_COMPANY_USER', 'ROLE_COMPANY_BOOKKEEPER' => 'ROLE_COMPANY_BOOKKEEPER: ROLE_COMPANY_USER', 'ROLE_USER' => 'ROLE_USER', - ); + ]; $roleBuilder->expects($this->once())->method('getRoles')->will($this->returnValue($availableRoles)); // user roles - $userRoles = array('ROLE_COMPANY_PERSONAL_MODERATOR', 'ROLE_COMPANY_NEWS_MODERATOR', 'ROLE_COMPANY_BOOKKEEPER'); + $userRoles = ['ROLE_COMPANY_PERSONAL_MODERATOR', 'ROLE_COMPANY_NEWS_MODERATOR', 'ROLE_COMPANY_BOOKKEEPER']; $transformer = new RestoreRolesTransformer($roleBuilder); $transformer->setOriginalRoles($userRoles); // now we want to revoke role ROLE_COMPANY_PERSONAL_MODERATOR - $revokedRole = array_shift($userRoles); + $revokedRole = \array_shift($userRoles); $processedRoles = $transformer->reverseTransform($userRoles); $this->assertNotContains($revokedRole, $processedRoles); @@ -127,21 +127,21 @@ public function testReverseTransformHiddenRole() { $roleBuilder = $this->createMock(EditableRolesHelper::class); - $availableRoles = array( + $availableRoles = [ 'ROLE_SONATA_ADMIN' => 'ROLE_SONATA_ADMIN', 'ROLE_ADMIN' => 'ROLE_ADMIN: ROLE_USER ROLE_COMPANY_ADMIN', - ); + ]; $roleBuilder->expects($this->once())->method('getRoles')->will($this->returnValue($availableRoles)); // user roles - $userRoles = array('ROLE_USER', 'ROLE_SUPER_ADMIN'); + $userRoles = ['ROLE_USER', 'ROLE_SUPER_ADMIN']; $transformer = new RestoreRolesTransformer($roleBuilder); $transformer->setOriginalRoles($userRoles); // add a new role - array_push($userRoles, 'ROLE_SONATA_ADMIN'); + \array_push($userRoles, 'ROLE_SONATA_ADMIN'); // remove existing user role that is not availableRoles - unset($userRoles[array_search('ROLE_SUPER_ADMIN', $userRoles)]); + unset($userRoles[\array_search('ROLE_SUPER_ADMIN', $userRoles)]); $processedRoles = $transformer->reverseTransform($userRoles); $this->assertContains('ROLE_SUPER_ADMIN', $processedRoles); diff --git a/tests/Helper/EditableRolesHelperTest.php b/tests/Helper/EditableRolesHelperTest.php index 6ab08cdd..9bee0d25 100644 --- a/tests/Helper/EditableRolesHelperTest.php +++ b/tests/Helper/EditableRolesHelperTest.php @@ -8,38 +8,38 @@ class EditableRolesHelperTest extends TestCase { - private static $roleHierarchy = array( - 'ROLE_SUPER_ADMIN' => array( + private static $roleHierarchy = [ + 'ROLE_SUPER_ADMIN' => [ 0 => 'ROLE_ORGANIZATION', 3 => 'ROLE_SYSTEM', - ), - 'ROLE_SYSTEM' => array( + ], + 'ROLE_SYSTEM' => [ 0 => 'ROLE_ADMINUSER', 1 => 'ROLE_ADMINGROUP', - ), - 'ROLE_ORGANIZATION' => array( + ], + 'ROLE_ORGANIZATION' => [ 0 => 'ROLE_ORGANIZATION_LIST', 1 => 'ROLE_ORGANIZATION_SEARCH', 2 => 'ROLE_ORGANIZATION_NEW', 3 => 'ROLE_ORGANIZATION_EDIT', 4 => 'ROLE_ORGANIZATION_SHOW', - ), - 'ROLE_ADMINUSER' => array( + ], + 'ROLE_ADMINUSER' => [ 0 => 'ROLE_ADMINUSER_LIST', 1 => 'ROLE_ADMINUSER_SEARCH', 2 => 'ROLE_ADMINUSER_EDIT', 3 => 'ROLE_ADMINUSER_SHOW', 4 => 'ROLE_ADMINUSER_DELETE', - ), - 'ROLE_ADMINGROUP' => array( + ], + 'ROLE_ADMINGROUP' => [ 0 => 'ROLE_ADMINGROUP_LIST', 1 => 'ROLE_ADMINGROUP_SEARCH', 2 => 'ROLE_ADMINGROUP_NEW', 3 => 'ROLE_ADMINGROUP_EDIT', 4 => 'ROLE_ADMINGROUP_SHOW', 5 => 'ROLE_ADMINGROUP_DELETE', - ), - ); + ], + ]; public function testNoTokenReturnsNoRole() { @@ -50,7 +50,7 @@ public function testNoTokenReturnsNoRole() $editableRolesHelper = new EditableRolesHelper($tokenStorage, static::$roleHierarchy); - $this->assertSame(array(), $editableRolesHelper->getRoles()); + $this->assertSame([], $editableRolesHelper->getRoles()); } public function testRoleHierarchyIsMappedForChoicesWithoutSuperAdmin() @@ -58,38 +58,38 @@ public function testRoleHierarchyIsMappedForChoicesWithoutSuperAdmin() $tokenStorage = $this->createMock(TokenStorageInterface::class); // We just tell tokenStorage to return a not null value - $tokenStorage->method('getToken')->will($this->returnValue(array('ROLE_ADMIN'))); + $tokenStorage->method('getToken')->will($this->returnValue(['ROLE_ADMIN'])); $editableRolesHelper = new EditableRolesHelper($tokenStorage, static::$roleHierarchy); - $expected = array( - 'ROLE_SYSTEM' => array( + $expected = [ + 'ROLE_SYSTEM' => [ 'ROLE_ADMINUSER' => 'ROLE_ADMINUSER', 'ROLE_ADMINGROUP' => 'ROLE_ADMINGROUP', - ), - 'ROLE_ORGANIZATION' => array( + ], + 'ROLE_ORGANIZATION' => [ 'ROLE_ORGANIZATION_LIST' => 'ROLE_ORGANIZATION_LIST', 'ROLE_ORGANIZATION_SEARCH' => 'ROLE_ORGANIZATION_SEARCH', 'ROLE_ORGANIZATION_NEW' => 'ROLE_ORGANIZATION_NEW', 'ROLE_ORGANIZATION_EDIT' => 'ROLE_ORGANIZATION_EDIT', 'ROLE_ORGANIZATION_SHOW' => 'ROLE_ORGANIZATION_SHOW', - ), - 'ROLE_ADMINUSER' => array( + ], + 'ROLE_ADMINUSER' => [ 'ROLE_ADMINUSER_LIST' => 'ROLE_ADMINUSER_LIST', 'ROLE_ADMINUSER_SEARCH' => 'ROLE_ADMINUSER_SEARCH', 'ROLE_ADMINUSER_EDIT' => 'ROLE_ADMINUSER_EDIT', 'ROLE_ADMINUSER_SHOW' => 'ROLE_ADMINUSER_SHOW', 'ROLE_ADMINUSER_DELETE' => 'ROLE_ADMINUSER_DELETE', - ), - 'ROLE_ADMINGROUP' => array( + ], + 'ROLE_ADMINGROUP' => [ 'ROLE_ADMINGROUP_LIST' => 'ROLE_ADMINGROUP_LIST', 'ROLE_ADMINGROUP_SEARCH' => 'ROLE_ADMINGROUP_SEARCH', 'ROLE_ADMINGROUP_NEW' => 'ROLE_ADMINGROUP_NEW', 'ROLE_ADMINGROUP_EDIT' => 'ROLE_ADMINGROUP_EDIT', 'ROLE_ADMINGROUP_SHOW' => 'ROLE_ADMINGROUP_SHOW', 'ROLE_ADMINGROUP_DELETE' => 'ROLE_ADMINGROUP_DELETE', - ), - ); + ], + ]; $this->assertSame($expected, $editableRolesHelper->getRoles()); } diff --git a/tests/Helper/MenuHelperTest.php b/tests/Helper/MenuHelperTest.php index 9bd10dab..82d257f0 100644 --- a/tests/Helper/MenuHelperTest.php +++ b/tests/Helper/MenuHelperTest.php @@ -9,136 +9,135 @@ class MenuHelperTest extends TestCase { - public function testAcessDeniedEntityEntriesArePruned() { - $menuConfig = array( - 0 => array('label' => 'Dashboard', 'type' => 'route', 'children' => array()), - 1 => array('label' => 'Organizations', 'type' => 'entity', 'entity' => 'Organization'), - 2 => array('label' => 'Members', 'type' => 'entity', 'entity' => 'Member'), - 3 => array('label' => 'Events', 'type' => 'empty', 'children' => array( - 0 => array('label' => 'Seminaries', 'type' => 'entity', 'entity' => 'Seminary'), - 1 => array('label' => 'Meetings', 'type' => 'entity', 'entity' => 'Meeting'), - 2 => array('label' => 'Plenary meetings', 'type' => 'entity', 'entity' => 'PlenaryMeeting'), - )), - 4 => array('label' => 'System', 'type' => 'empty', 'children' => array( - 0 => array('label' => 'Admin users', 'type' => 'entity', 'entity' => 'AdminUser'), - 1 => array('label' => 'Admin groups', 'type' => 'entity', 'entity' => 'AdminGroup'), - )), - ); - - $entitiesConfig = array( - 'Organization' => array('role_prefix' => 'ROLE_ORGANIZATION'), - 'Member' => array('role_prefix' => 'ROLE_MEMBER'), - 'Seminary' => array('role_prefix' => 'ROLE_SEMINARY'), - 'Meeting' => array('role_prefix' => 'ROLE_MEETING'), - 'PlenaryMeeting' => array('role_prefix' => 'ROLE_PLENARYMEETING'), - 'AdminUser' => array('role_prefix' => 'ROLE_ADMINUSER'), - 'AdminGroup' => array('role_prefix' => 'ROLE_ADMINGROUP'), - ); + $menuConfig = [ + 0 => ['label' => 'Dashboard', 'type' => 'route', 'children' => []], + 1 => ['label' => 'Organizations', 'type' => 'entity', 'entity' => 'Organization'], + 2 => ['label' => 'Members', 'type' => 'entity', 'entity' => 'Member'], + 3 => ['label' => 'Events', 'type' => 'empty', 'children' => [ + 0 => ['label' => 'Seminaries', 'type' => 'entity', 'entity' => 'Seminary'], + 1 => ['label' => 'Meetings', 'type' => 'entity', 'entity' => 'Meeting'], + 2 => ['label' => 'Plenary meetings', 'type' => 'entity', 'entity' => 'PlenaryMeeting'], + ]], + 4 => ['label' => 'System', 'type' => 'empty', 'children' => [ + 0 => ['label' => 'Admin users', 'type' => 'entity', 'entity' => 'AdminUser'], + 1 => ['label' => 'Admin groups', 'type' => 'entity', 'entity' => 'AdminGroup'], + ]], + ]; + + $entitiesConfig = [ + 'Organization' => ['role_prefix' => 'ROLE_ORGANIZATION'], + 'Member' => ['role_prefix' => 'ROLE_MEMBER'], + 'Seminary' => ['role_prefix' => 'ROLE_SEMINARY'], + 'Meeting' => ['role_prefix' => 'ROLE_MEETING'], + 'PlenaryMeeting' => ['role_prefix' => 'ROLE_PLENARYMEETING'], + 'AdminUser' => ['role_prefix' => 'ROLE_ADMINUSER'], + 'AdminGroup' => ['role_prefix' => 'ROLE_ADMINGROUP'], + ]; $adminAuthorizationChecker = $this->createMock(AdminAuthorizationChecker::class); $symfonyAuthorizationChecker = $this->createMock(AuthorizationCheckerInterface::class); - $grantedRoleMap = array( - array($entitiesConfig['Organization'], 'list', null, true), - array($entitiesConfig['Member'], 'list', null, false), - array($entitiesConfig['Seminary'], 'list', null, true), - array($entitiesConfig['Meeting'], 'list', null, false), - array($entitiesConfig['PlenaryMeeting'], 'list', null, true), - array($entitiesConfig['AdminUser'], 'list', null, false), - array($entitiesConfig['AdminGroup'], 'list', null, false), - ); + $grantedRoleMap = [ + [$entitiesConfig['Organization'], 'list', null, true], + [$entitiesConfig['Member'], 'list', null, false], + [$entitiesConfig['Seminary'], 'list', null, true], + [$entitiesConfig['Meeting'], 'list', null, false], + [$entitiesConfig['PlenaryMeeting'], 'list', null, true], + [$entitiesConfig['AdminUser'], 'list', null, false], + [$entitiesConfig['AdminGroup'], 'list', null, false], + ]; $adminAuthorizationChecker->method('isEasyAdminGranted')->will($this->returnValueMap($grantedRoleMap)); $helper = new MenuHelper($adminAuthorizationChecker, $symfonyAuthorizationChecker); $prunedMenu = $helper->pruneMenuItems($menuConfig, $entitiesConfig); - $expectedPrunedMenu = array( - 0 => array( + $expectedPrunedMenu = [ + 0 => [ 'label' => 'Dashboard', 'type' => 'route', - 'children' => array(), + 'children' => [], 'menu_index' => 0, 'submenu_index' => -1, - ), - 1 => array( + ], + 1 => [ 'label' => 'Organizations', 'type' => 'entity', 'entity' => 'Organization', 'menu_index' => 1, 'submenu_index' => -1, - ), - 2 => array( + ], + 2 => [ 'label' => 'Events', 'type' => 'empty', - 'children' => array( - 0 => array( + 'children' => [ + 0 => [ 'label' => 'Seminaries', 'type' => 'entity', 'entity' => 'Seminary', 'menu_index' => 2, 'submenu_index' => 0, - ), - 1 => array( + ], + 1 => [ 'label' => 'Plenary meetings', 'type' => 'entity', 'entity' => 'PlenaryMeeting', 'menu_index' => 2, 'submenu_index' => 1, - ), - ), + ], + ], 'menu_index' => 2, 'submenu_index' => -1, - ), - ); + ], + ]; $this->assertSame($expectedPrunedMenu, $prunedMenu); } public function testAcessDeniedStaticEntriesArePruned() { - $menuConfig = array( - 0 => array('label' => 'Link allowed', 'type' => 'link', 'url' => 'https://github.com', 'role' => 'ROLE_ALLOWED'), - 1 => array('label' => 'Link disallowed', 'type' => 'link', 'url' => 'https://gitlab.com', 'role' => 'ROLE_DISALLOWED'), - 2 => array('label' => 'Route allowed', 'type' => 'route', 'route' => 'route_allowed', 'role' => 'ROLE_ALLOWED'), - 3 => array('label' => 'Route disallowed', 'type' => 'route', 'route' => 'route_disallowed', 'role' => 'ROLE_DISALLOWED'), - ); + $menuConfig = [ + 0 => ['label' => 'Link allowed', 'type' => 'link', 'url' => 'https://github.com', 'role' => 'ROLE_ALLOWED'], + 1 => ['label' => 'Link disallowed', 'type' => 'link', 'url' => 'https://gitlab.com', 'role' => 'ROLE_DISALLOWED'], + 2 => ['label' => 'Route allowed', 'type' => 'route', 'route' => 'route_allowed', 'role' => 'ROLE_ALLOWED'], + 3 => ['label' => 'Route disallowed', 'type' => 'route', 'route' => 'route_disallowed', 'role' => 'ROLE_DISALLOWED'], + ]; $adminAuthorizationChecker = $this->createMock(AdminAuthorizationChecker::class); $symfonyAuthorizationChecker = $this->createMock(AuthorizationCheckerInterface::class); - $grantedRoleMap = array( - array($menuConfig[0]['role'], null, true), - array($menuConfig[1]['role'], null, false), - array($menuConfig[2]['role'], null, true), - array($menuConfig[3]['role'], null, false), - ); + $grantedRoleMap = [ + [$menuConfig[0]['role'], null, true], + [$menuConfig[1]['role'], null, false], + [$menuConfig[2]['role'], null, true], + [$menuConfig[3]['role'], null, false], + ]; $symfonyAuthorizationChecker->method('isGranted')->will($this->returnValueMap($grantedRoleMap)); $helper = new MenuHelper($adminAuthorizationChecker, $symfonyAuthorizationChecker); - $prunedMenu = $helper->pruneMenuItems($menuConfig, array()); + $prunedMenu = $helper->pruneMenuItems($menuConfig, []); - $expectedPrunedMenu = array( - 0 => array( + $expectedPrunedMenu = [ + 0 => [ 'label' => 'Link allowed', 'type' => 'link', 'url' => 'https://github.com', 'role' => 'ROLE_ALLOWED', 'menu_index' => 0, 'submenu_index' => -1, - ), - 1 => array( + ], + 1 => [ 'label' => 'Route allowed', 'type' => 'route', 'route' => 'route_allowed', 'role' => 'ROLE_ALLOWED', 'menu_index' => 1, 'submenu_index' => -1, - ), - ); + ], + ]; $this->assertSame($expectedPrunedMenu, $prunedMenu); } diff --git a/tests/Model/AdminUserTest.php b/tests/Model/AdminUserTest.php index 15ab62f4..3bdd8251 100644 --- a/tests/Model/AdminUserTest.php +++ b/tests/Model/AdminUserTest.php @@ -12,16 +12,16 @@ class AdminUserTest extends TestCase public function testAdminUserGetRolesFromGroups() { $aGroup = new AdminGroup(); - $aGroup->setRoles(array('ROLE_COMMON', 'ROLE_A_1', 'ROLE_A_2')); + $aGroup->setRoles(['ROLE_COMMON', 'ROLE_A_1', 'ROLE_A_2']); $bGroup = new AdminGroup(); - $bGroup->setRoles(array('ROLE_COMMON', 'ROLE_B_1', 'ROLE_B_2')); + $bGroup->setRoles(['ROLE_COMMON', 'ROLE_B_1', 'ROLE_B_2']); - $user = $this->createPartialMock(AdminUser::class, array('getGroups')); + $user = $this->createPartialMock(AdminUser::class, ['getGroups']); $user->method('getGroups')->will($this->returnValue(new ArrayCollection([$aGroup, $bGroup]))); $this->assertSame( - array('ROLE_ADMIN', 'ROLE_COMMON', 'ROLE_A_1', 'ROLE_A_2', 'ROLE_B_1', 'ROLE_B_2'), + ['ROLE_ADMIN', 'ROLE_COMMON', 'ROLE_A_1', 'ROLE_A_2', 'ROLE_B_1', 'ROLE_B_2'], $user->getRoles() ); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d914c95f..106d68dd 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -24,7 +24,7 @@ * (c) Alexandre Rock Ancelet */ $file = __DIR__.'/../vendor/autoload.php'; -if (!file_exists($file)) { +if (!\file_exists($file)) { throw new RuntimeException('Install dependencies using Composer to run the test suite.'); } $autoload = require $file; @@ -32,19 +32,19 @@ AnnotationRegistry::registerLoader(function ($class) use ($autoload) { $autoload->loadClass($class); - return class_exists($class, false); + return \class_exists($class, false); }); // Test Setup: remove all the contents in the build/ directory // (PHP doesn't allow to delete directories unless they are empty) -if (is_dir($buildDir = __DIR__.'/../build')) { +if (\is_dir($buildDir = __DIR__.'/../build')) { $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($buildDir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST ); foreach ($files as $fileinfo) { - $fileinfo->isDir() ? rmdir($fileinfo->getRealPath()) : unlink($fileinfo->getRealPath()); + $fileinfo->isDir() ? \rmdir($fileinfo->getRealPath()) : \unlink($fileinfo->getRealPath()); } } @@ -54,18 +54,18 @@ $application->setAutoExit(false); // Create database -$input = new ArrayInput(array('command' => 'doctrine:database:create')); +$input = new ArrayInput(['command' => 'doctrine:database:create']); $application->run($input, new ConsoleOutput()); // Create database schema -$input = new ArrayInput(array('command' => 'doctrine:schema:create')); +$input = new ArrayInput(['command' => 'doctrine:schema:create']); $application->run($input, new ConsoleOutput()); // Load fixtures of the AppTestBundle -$input = new ArrayInput(array('command' => 'doctrine:fixtures:load', '--no-interaction' => true, '--append' => false)); +$input = new ArrayInput(['command' => 'doctrine:fixtures:load', '--no-interaction' => true, '--append' => false]); $application->run($input, new ConsoleOutput()); // Make a copy of the original SQLite database to use the same unmodified database in every test -copy($buildDir.'/test.db', $buildDir.'/original_test.db'); +\copy($buildDir.'/test.db', $buildDir.'/original_test.db'); unset($input, $application); From df138acab67641a664d5cf3ff6f57086d67062bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Mon, 10 Dec 2018 13:57:44 +0100 Subject: [PATCH 09/15] Fix AdminController wiring in test suite --- debug.txt | 1548 ---------------------- src/Resources/config/services.xml | 2 +- tests/Controller/AutocompleteAddTest.php | 4 - 3 files changed, 1 insertion(+), 1553 deletions(-) delete mode 100644 debug.txt diff --git a/debug.txt b/debug.txt deleted file mode 100644 index b7ed310c..00000000 --- a/debug.txt +++ /dev/null @@ -1,1548 +0,0 @@ -Created database /app/tests/Fixtures/App/../../../build/test.db for connection named default - - !  - ! [CAUTION] This operation should not be executed in a production environment!  - !  - - Creating database schema... - -  - [OK] Database schema created successfully!  -  - - > purging database - > loading [10] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadAdminGroups - > loading [10] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadUsers - > loading [11] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadAdminUsers - > loading [20] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\ORM\LoadCategories - > loading [100] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadProducts - > loading [200] AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AppTestBundle\DataFixtures\ORM\LoadPurchases -PHPUnit 5.7.27 by Sebastian Bergmann and contributors. - -.......F - - - - - - You have requested a non-existent service "admin_authorization_checker". Did you mean this: "security.authorization_checker"? (500 Internal Server Error) - - - - - - -
-
-

- Symfony Exception

- - - - -
-
- -
- - -
-
-

You have requested a non-existent service "admin_authorization_checker". Did you mean this: "security.authorization_checker"?

- -
- - -
-
-
-
- -
-
-
-

- Exception -

- -
-
-
-
- -

- - - - - - - Symfony\Component\DependencyInjection\Exception\ - - ServiceNotFoundException -

- -
-
- -
-
-
- - - - - - - - - in - vendor/symfony/dependency-injection/Container.php (line 277) - -
-
-
  1.                 if ($lev <= \strlen($id) / || false !== strpos($knownId$id)) {
  2. -
  3.                     $alternatives[] = $knownId;
  4. -
  5.                 }
  6. -
  7.             }
  8. -
  9. -
  10.             throw new ServiceNotFoundException($idnullnull$alternatives);
  11. -
  12.         }
  13. -
  14.     }
  15. -
  16. -
  17.     /**
  18. -
  19.      * Returns true if the given service has actually been initialized.
-
- -
-
-
- - - - - - - - - in - vendor/symfony/dependency-injection/Container.php->make (line 225) - -
-
-
  1.      */
  2. -
  3.     public function get($id$invalidBehavior /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
  4. -
  5.     {
  6. -
  7.         return $this->services[$id]
  8. -
  9.             ?? $this->services[$id $this->aliases[$id] ?? $id]
  10. -
  11.             ?? ('service_container' === $id $this : ($this->factories[$id] ?? array($this'make'))($id$invalidBehavior));
  12. -
  13.     }
  14. -
  15. -
  16.     /**
  17. -
  18.      * Creates a service.
  19. -
  20.      *
-
- -
-
-
- - - - - - - - - in - vendor/symfony/framework-bundle/Controller/ControllerTrait.php->get (line 66) - -
-
-
  1.      *
  2. -
  3.      * @final
  4. -
  5.      */
  6. -
  7.     protected function get(string $id)
  8. -
  9.     {
  10. -
  11.         return $this->container->get($id);
  12. -
  13.     }
  14. -
  15. -
  16.     /**
  17. -
  18.      * Generates a URL from the given parameters.
  19. -
  20.      *
-
- -
-
-
- - - - - - AbstractController->get('admin_authorization_checker') - - - - in - src/Controller/AdminController.php (line 62) - -
-
-
  1.         }
  2. -
  3. -
  4.         // Get item for edit/show or custom actions => security voters may apply
  5. -
  6.         $easyadmin $this->request->attributes->get('easyadmin');
  7. -
  8.         $subject $easyadmin['item'] ?? null;
  9. -
  10.         $this->get('admin_authorization_checker')->checksUserAccess($this->entity$actionName$subject);
  11. -
  12. -
  13.         return parent::isActionAllowed($actionName);
  14. -
  15.     }
  16. -
  17. -
  18.     /**
-
- -
-
-
- - - - - - - - - in - vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php->isActionAllowed (line 65) - -
-
-
  1.         if (null === $request->query->get('entity')) {
  2. -
  3.             return $this->redirectToBackendHomepage();
  4. -
  5.         }
  6. -
  7. -
  8.         $action $request->query->get('action''list');
  9. -
  10.         if (!$this->isActionAllowed($action)) {
  11. -
  12.             throw new ForbiddenActionException(['action' => $action'entity_name' => $this->entity['name']]);
  13. -
  14.         }
  15. -
  16. -
  17.         return $this->executeDynamicMethod($action.'<EntityName>Action');
  18. -
  19.     }
-
- -
-
-
- - - - - - - - - in - vendor/symfony/http-kernel/HttpKernel.php->indexAction (line 150) - -
-
-
  1.         $this->dispatcher->dispatch(KernelEvents::CONTROLLER_ARGUMENTS$event);
  2. -
  3.         $controller $event->getController();
  4. -
  5.         $arguments $event->getArguments();
  6. -
  7. -
  8.         // call controller
  9. -
  10.         $response $controller(...$arguments);
  11. -
  12. -
  13.         // view
  14. -
  15.         if (!$response instanceof Response) {
  16. -
  17.             $event = new GetResponseForControllerResultEvent($this$request$type$response);
  18. -
  19.             $this->dispatcher->dispatch(KernelEvents::VIEW$event);
-
- -
-
-
- - - - - - - - - in - vendor/symfony/http-kernel/HttpKernel.php->handleRaw (line 67) - -
-
-
  1.     public function handle(Request $request$type HttpKernelInterface::MASTER_REQUEST$catch true)
  2. -
  3.     {
  4. -
  5.         $request->headers->set('X-Php-Ob-Level'ob_get_level());
  6. -
  7. -
  8.         try {
  9. -
  10.             return $this->handleRaw($request$type);
  11. -
  12.         } catch (\Exception $e) {
  13. -
  14.             if ($e instanceof RequestExceptionInterface) {
  15. -
  16.                 $e = new BadRequestHttpException($e->getMessage(), $e);
  17. -
  18.             }
  19. -
  20.             if (false === $catch) {
-
- -
-
-
- - - - - - - - - in - vendor/symfony/http-kernel/Kernel.php->handle (line 198) - -
-
-
  1.         $this->boot();
  2. -
  3.         ++$this->requestStackSize;
  4. -
  5.         $this->resetServices true;
  6. -
  7. -
  8.         try {
  9. -
  10.             return $this->getHttpKernel()->handle($request$type$catch);
  11. -
  12.         } finally {
  13. -
  14.             --$this->requestStackSize;
  15. -
  16.         }
  17. -
  18.     }
  19. -
-
- -
-
-
- - - - - - - - - in - vendor/symfony/http-kernel/Client.php->handle (line 68) - -
-
-
  1.      *
  2. -
  3.      * @return Response A Response instance
  4. -
  5.      */
  6. -
  7.     protected function doRequest($request)
  8. -
  9.     {
  10. -
  11.         $response $this->kernel->handle($requestHttpKernelInterface::MASTER_REQUEST$this->catchExceptions);
  12. -
  13. -
  14.         if ($this->kernel instanceof TerminableInterface) {
  15. -
  16.             $this->kernel->terminate($request$response);
  17. -
  18.         }
  19. -
-
- -
-
-
- - - - - - - - - in - vendor/symfony/framework-bundle/Client.php->doRequest (line 131) - -
-
-
  1. -
  2.             $this->kernel->boot();
  3. -
  4.             $this->kernel->getContainer()->get('profiler')->enable();
  5. -
  6.         }
  7. -
  8. -
  9.         return parent::doRequest($request);
  10. -
  11.     }
  12. -
  13. -
  14.     /**
  15. -
  16.      * {@inheritdoc}
  17. -
  18.      *
-
- -
-
-
- - - - - - - - - in - vendor/symfony/browser-kit/Client.php->doRequest (line 405) - -
-
-
  1.         }
  2. -
  3. -
  4.         if ($this->insulated) {
  5. -
  6.             $this->response $this->doRequestInProcess($this->request);
  7. -
  8.         } else {
  9. -
  10.             $this->response $this->doRequest($this->request);
  11. -
  12.         }
  13. -
  14. -
  15.         $this->internalResponse $this->filterResponse($this->response);
  16. -
  17. -
  18.         $this->cookieJar->updateFromResponse($this->internalResponse$uri);
-
- -
-
-
- - - - - - Client->request('GET', 'http://localhost/admin/?action=new&entity=Product') - - - - in - tests/Fixtures/AbstractTestCase.php (line 64) - -
-
-
  1.      *
  2. -
  3.      * @return Crawler
  4. -
  5.      */
  6. -
  7.     protected function getBackendPage(array $queryParameters = [])
  8. -
  9.     {
  10. -
  11.         return $this->client->request('GET''/admin/?'.http_build_query($queryParameters'''&'));
  12. -
  13.     }
  14. -
  15. -
  16.     /**
  17. -
  18.      * @return Crawler
  19. -
  20.      */
-
- -
-
-
- - - - - - AbstractTestCase->getBackendPage(array('action' => 'new', 'entity' => 'Product')) - - - - in - tests/Fixtures/AbstractTestCase.php (line 121) - -
-
-
  1.      */
  2. -
  3.     protected function requestNewView($entityName 'Category')
  4. -
  5.     {
  6. -
  7.         return $this->getBackendPage(array(
  8. -
  9.             'action' => 'new',
  10. -
  11.             'entity' => $entityName,
  12. -
  13.         ));
  14. -
  15.     }
  16. -
  17. -
  18.     /**
  19. -
  20.      * @return Crawler
-
- -
-
-
- - - - - - AbstractTestCase->requestNewView('Product') - - - - in - tests/Controller/AutocompleteAddTest.php (line 18) - -
-
-
  1.         $this->initClient(array('environment' => 'autocomplete_add'));
  2. -
  3.     }
  4. -
  5. -
  6.     public function testNewEntityAutocompleteModal()
  7. -
  8.     {
  9. -
  10.         $crawler $this->requestNewView('Product');
  11. -
  12. -
  13.         if (200 !== $this->client->getResponse()->getStatusCode()) {
  14. -
  15.             echo $this->client->getResponse()->getContent();
  16. -
  17.         }
  18. -
-
- -
-
-
- - AutocompleteAddTest->testNewEntityAutocompleteModal() - -
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/src/Framework/TestCase.php->invokeArgs (line 1062) - -
-
-
  1.         $testArguments array_merge($this->data$this->dependencyInput);
  2. -
  3. -
  4.         $this->registerMockObjectsFromTestArguments($testArguments);
  5. -
  6. -
  7.         try {
  8. -
  9.             $testResult $method->invokeArgs($this$testArguments);
  10. -
  11.         } catch (Throwable $_e) {
  12. -
  13.             $e $_e;
  14. -
  15.         } catch (Exception $_e) {
  16. -
  17.             $e $_e;
  18. -
  19.         }
-
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/src/Framework/TestCase.php->runTest (line 913) - -
-
-
  1.             foreach ($hookMethods['before'] as $method) {
  2. -
  3.                 $this->$method();
  4. -
  5.             }
  6. -
  7. -
  8.             $this->assertPreConditions();
  9. -
  10.             $this->testResult $this->runTest();
  11. -
  12.             $this->verifyMockObjects();
  13. -
  14.             $this->assertPostConditions();
  15. -
  16. -
  17.             if (!empty($this->warnings)) {
  18. -
  19.                 throw new PHPUnit_Framework_Warning(
-
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/src/Framework/TestResult.php->runBare (line 686) - -
-
-
  1.                 }
  2. -
  3. -
  4.                 $invoker = new PHP_Invoker;
  5. -
  6.                 $invoker->invoke([$test'runBare'], [], $_timeout);
  7. -
  8.             } else {
  9. -
  10.                 $test->runBare();
  11. -
  12.             }
  13. -
  14.         } catch (PHP_Invoker_TimeoutException $e) {
  15. -
  16.             $this->addFailure(
  17. -
  18.                 $test,
  19. -
  20.                 new PHPUnit_Framework_RiskyTestError(
-
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/src/Framework/TestCase.php->run (line 868) - -
-
-
  1.             $this->prepareTemplate($template);
  2. -
  3. -
  4.             $php PHPUnit_Util_PHP::factory();
  5. -
  6.             $php->runTestJob($template->render(), $this$result);
  7. -
  8.         } else {
  9. -
  10.             $result->run($this);
  11. -
  12.         }
  13. -
  14. -
  15.         if (isset($oldErrorHandlerSetting)) {
  16. -
  17.             $result->convertErrorsToExceptions($oldErrorHandlerSetting);
  18. -
  19.         }
-
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/src/Framework/TestSuite.php->run (line 733) - -
-
-
  1.                 $test->setBackupGlobals($this->backupGlobals);
  2. -
  3.                 $test->setBackupStaticAttributes($this->backupStaticAttributes);
  4. -
  5.                 $test->setRunTestInSeparateProcess($this->runTestInSeparateProcess);
  6. -
  7.             }
  8. -
  9. -
  10.             $test->run($result);
  11. -
  12.         }
  13. -
  14. -
  15.         foreach ($hookMethods['afterClass'] as $afterClassMethod) {
  16. -
  17.             if ($this->testCase === true && class_exists($this->namefalse) && method_exists($this->name$afterClassMethod)) {
  18. -
  19.                 call_user_func([$this->name$afterClassMethod]);
-
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/src/Framework/TestSuite.php->run (line 733) - -
-
-
  1.                 $test->setBackupGlobals($this->backupGlobals);
  2. -
  3.                 $test->setBackupStaticAttributes($this->backupStaticAttributes);
  4. -
  5.                 $test->setRunTestInSeparateProcess($this->runTestInSeparateProcess);
  6. -
  7.             }
  8. -
  9. -
  10.             $test->run($result);
  11. -
  12.         }
  13. -
  14. -
  15.         foreach ($hookMethods['afterClass'] as $afterClassMethod) {
  16. -
  17.             if ($this->testCase === true && class_exists($this->namefalse) && method_exists($this->name$afterClassMethod)) {
  18. -
  19.                 call_user_func([$this->name$afterClassMethod]);
-
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/src/TextUI/TestRunner.php->run (line 517) - -
-
-
  1. -
  2.         if ($suite instanceof PHPUnit_Framework_TestSuite) {
  3. -
  4.             $suite->setRunTestInSeparateProcess($arguments['processIsolation']);
  5. -
  6.         }
  7. -
  8. -
  9.         $suite->run($result);
  10. -
  11. -
  12.         unset($suite);
  13. -
  14.         $result->flushListeners();
  15. -
  16. -
  17.         if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
-
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/src/TextUI/Command.php->doRun (line 186) - -
-
-
  1. -
  2.         unset($this->arguments['test']);
  3. -
  4.         unset($this->arguments['testFile']);
  5. -
  6. -
  7.         try {
  8. -
  9.             $result $runner->doRun($suite$this->arguments$exit);
  10. -
  11.         } catch (PHPUnit_Framework_Exception $e) {
  12. -
  13.             print $e->getMessage() . "\n";
  14. -
  15.         }
  16. -
  17. -
  18.         $return PHPUnit_TextUI_TestRunner::FAILURE_EXIT;
-
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/src/TextUI/Command.php->run (line 116) - -
-
-
  1.      */
  2. -
  3.     public static function main($exit true)
  4. -
  5.     {
  6. -
  7.         $command = new static;
  8. -
  9. -
  10.         return $command->run($_SERVER['argv'], $exit);
  11. -
  12.     }
  13. -
  14. -
  15.     /**
  16. -
  17.      * @param array $argv
  18. -
  19.      * @param bool  $exit
-
- -
-
-
- - - - - - - - - in - vendor/phpunit/phpunit/phpunit::main (line 52) - -
-
-
  1.     die(1);
  2. -
  3. }
  4. -
  5. -
  6. require PHPUNIT_COMPOSER_INSTALL;
  7. -
  8. -
  9. PHPUnit_TextUI_Command::main();
  10. -
  11. -
-
- -
-
-
-
- -
-
- - -
-

- Stack Trace -

- -
- - - - - - - - - - - - -
-

- ServiceNotFoundException - - - - -

-
-
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
-You have requested a non-existent service "admin_authorization_checker". Did you mean this: "security.authorization_checker"?
-
-  at vendor/symfony/dependency-injection/Container.php:277
-  at Symfony\Component\DependencyInjection\Container->make('admin_authorization_checker', 1)
-     (vendor/symfony/dependency-injection/Container.php:225)
-  at Symfony\Component\DependencyInjection\Container->get('admin_authorization_checker')
-     (vendor/symfony/framework-bundle/Controller/ControllerTrait.php:66)
-  at Symfony\Bundle\FrameworkBundle\Controller\AbstractController->get('admin_authorization_checker')
-     (src/Controller/AdminController.php:62)
-  at AlterPHP\EasyAdminExtensionBundle\Controller\AdminController->isActionAllowed('new')
-     (vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php:65)
-  at EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController->indexAction(object(Request))
-     (vendor/symfony/http-kernel/HttpKernel.php:150)
-  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
-     (vendor/symfony/http-kernel/HttpKernel.php:67)
-  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
-     (vendor/symfony/http-kernel/Kernel.php:198)
-  at Symfony\Component\HttpKernel\Kernel->handle(object(Request), 1, true)
-     (vendor/symfony/http-kernel/Client.php:68)
-  at Symfony\Component\HttpKernel\Client->doRequest(object(Request))
-     (vendor/symfony/framework-bundle/Client.php:131)
-  at Symfony\Bundle\FrameworkBundle\Client->doRequest(object(Request))
-     (vendor/symfony/browser-kit/Client.php:405)
-  at Symfony\Component\BrowserKit\Client->request('GET', 'http://localhost/admin/?action=new&amp;entity=Product')
-     (tests/Fixtures/AbstractTestCase.php:64)
-  at AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AbstractTestCase->getBackendPage(array('action' => 'new', 'entity' => 'Product'))
-     (tests/Fixtures/AbstractTestCase.php:121)
-  at AlterPHP\EasyAdminExtensionBundle\Tests\Fixtures\AbstractTestCase->requestNewView('Product')
-     (tests/Controller/AutocompleteAddTest.php:18)
-  at AlterPHP\EasyAdminExtensionBundle\Tests\Controller\AutocompleteAddTest->testNewEntityAutocompleteModal()
-  at ReflectionMethod->invokeArgs(object(AutocompleteAddTest), array())
-     (vendor/phpunit/phpunit/src/Framework/TestCase.php:1062)
-  at PHPUnit_Framework_TestCase->runTest()
-     (vendor/phpunit/phpunit/src/Framework/TestCase.php:913)
-  at PHPUnit_Framework_TestCase->runBare()
-     (vendor/phpunit/phpunit/src/Framework/TestResult.php:686)
-  at PHPUnit_Framework_TestResult->run(object(AutocompleteAddTest))
-     (vendor/phpunit/phpunit/src/Framework/TestCase.php:868)
-  at PHPUnit_Framework_TestCase->run(object(PHPUnit_Framework_TestResult))
-     (vendor/phpunit/phpunit/src/Framework/TestSuite.php:733)
-  at PHPUnit_Framework_TestSuite->run(object(PHPUnit_Framework_TestResult))
-     (vendor/phpunit/phpunit/src/Framework/TestSuite.php:733)
-  at PHPUnit_Framework_TestSuite->run(object(PHPUnit_Framework_TestResult))
-     (vendor/phpunit/phpunit/src/TextUI/TestRunner.php:517)
-  at PHPUnit_TextUI_TestRunner->doRun(object(PHPUnit_Framework_TestSuite), array('listGroups' => false, 'listSuites' => false, 'loader' => null, 'useDefaultConfiguration' => true, 'loadedExtensions' => array(), 'notLoadedExtensions' => array(), 'stopOnFailure' => true, 'testSuffixes' => array('Test.php', '.phpt'), 'configuration' => object(PHPUnit_Util_Configuration), 'debug' => false, 'filter' => false, 'listeners' => array(), 'backupGlobals' => false, 'backupStaticAttributes' => false, 'bootstrap' => '/app/tests/bootstrap.php', 'colors' => 'auto', 'convertErrorsToExceptions' => true, 'convertNoticesToExceptions' => true, 'convertWarningsToExceptions' => true, 'processIsolation' => false, 'testdoxGroups' => array(), 'testdoxExcludeGroups' => array(), 'addUncoveredFilesFromWhitelist' => true, 'processUncoveredFilesFromWhitelist' => false, 'beStrictAboutChangesToGlobalState' => null, 'cacheTokens' => false, 'columns' => 80, 'excludeGroups' => array(), 'groups' => array(), 'logIncompleteSkipped' => false, 'repeat' => false, 'reportHighLowerBound' => 90, 'reportLowUpperBound' => 50, 'crap4jThreshold' => 30, 'stopOnError' => false, 'stopOnWarning' => false, 'stopOnIncomplete' => false, 'stopOnRisky' => false, 'stopOnSkipped' => false, 'failOnWarning' => false, 'failOnRisky' => false, 'timeoutForSmallTests' => 1, 'timeoutForMediumTests' => 10, 'timeoutForLargeTests' => 60, 'reportUselessTests' => false, 'strictCoverage' => false, 'disallowTestOutput' => false, 'enforceTimeLimit' => false, 'disallowTodoAnnotatedTests' => false, 'beStrictAboutResourceUsageDuringSmallTests' => false, 'reverseList' => false, 'registerMockObjectsFromTestArgumentsRecursively' => false, 'verbose' => false), true)
-     (vendor/phpunit/phpunit/src/TextUI/Command.php:186)
-  at PHPUnit_TextUI_Command->run(array('/app/vendor/phpunit/phpunit/phpunit', '--stop-on-failure'), true)
-     (vendor/phpunit/phpunit/src/TextUI/Command.php:116)
-  at PHPUnit_TextUI_Command::main()
-     (vendor/phpunit/phpunit/phpunit:52)
-
-
- -
-
- -
-
- - - - - - -Time: 1.67 seconds, Memory: 40.25MB - -There was 1 failure: - -1) AlterPHP\EasyAdminExtensionBundle\Tests\Controller\AutocompleteAddTest::testNewEntityAutocompleteModal -Failed asserting that 500 is identical to 200. - -/app/tests/Controller/AutocompleteAddTest.php:24 - -FAILURES! -Tests: 8, Assertions: 8, Failures: 1. - -Remaining deprecation notices (8) - - 3x: A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0. - 2x in AutocompleteAddTest::setUp from AlterPHP\EasyAdminExtensionBundle\Tests\Controller - 1x in Application::run from Symfony\Bundle\FrameworkBundle\Console - - 3x: Not implementing the static getExtendedTypes() method in AlterPHP\EasyAdminExtensionBundle\Form\Type\Extension\EasyAdminAutocompleteTypeExtension when implementing the Symfony\Component\Form\FormTypeExtensionInterface is deprecated since Symfony 4.2. The method will be added to the interface in 5.0. - 2x in AutocompleteAddTest::setUp from AlterPHP\EasyAdminExtensionBundle\Tests\Controller - 1x in Application::run from Symfony\Bundle\FrameworkBundle\Console - - 1x: The "Symfony\Component\HttpKernel\Kernel::getRootDir()" method is deprecated since Symfony 4.2, use getProjectDir() instead. - 1x in Application::run from Symfony\Bundle\FrameworkBundle\Console - - 1x: Auto-injection of the container for "AlterPHP\EasyAdminExtensionBundle\Controller\AdminController" is deprecated since Symfony 4.2. Configure it as a service instead. - 1x in AutocompleteAddTest::testNewEntityAutocompleteModal from AlterPHP\EasyAdminExtensionBundle\Tests\Controller - diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index c4df020a..b47ceef1 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + diff --git a/tests/Controller/AutocompleteAddTest.php b/tests/Controller/AutocompleteAddTest.php index 0055c6c6..4089daeb 100644 --- a/tests/Controller/AutocompleteAddTest.php +++ b/tests/Controller/AutocompleteAddTest.php @@ -17,10 +17,6 @@ public function testNewEntityAutocompleteModal() { $crawler = $this->requestNewView('Product'); - if (200 !== $this->client->getResponse()->getStatusCode()) { - echo $this->client->getResponse()->getContent(); - } - $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(1, $crawler->filter('select#product_category_autocomplete[data-easyadmin-autocomplete-create-action-url="/admin/?action=newAjax&entity=Category"]')->count()); From be2575c6aa8c347b1927e082d42babb757d40f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Mon, 10 Dec 2018 21:55:40 +0100 Subject: [PATCH 10/15] Adapt templates and tests --- TODO-UPGRADE-EAB2.md | 5 +++++ .../{bootstrap_3_layout.html.twig => bootstrap_4.html.twig} | 0 tests/Controller/EmbeddedListTest.php | 4 ++-- tests/Controller/RequestParametersTest.php | 6 +++--- 4 files changed, 10 insertions(+), 5 deletions(-) rename src/Resources/views/form/{bootstrap_3_layout.html.twig => bootstrap_4.html.twig} (100%) diff --git a/TODO-UPGRADE-EAB2.md b/TODO-UPGRADE-EAB2.md index e69de29b..9f4d30f2 100644 --- a/TODO-UPGRADE-EAB2.md +++ b/TODO-UPGRADE-EAB2.md @@ -0,0 +1,5 @@ +- Loading Bootstrap with required 4 plugins (https://github.com/EasyCorp/EasyAdminBundle/compare/1.x...master#diff-d61a48328b309920085232ff9a96fbd9) +- Services id from class names +- Config for Travis CI (https://github.com/EasyCorp/EasyAdminBundle/compare/1.x...master#diff-354f30a63fb0907d4ad57269548329e3) +- Upgrade to Bootstrap 4 + diff --git a/src/Resources/views/form/bootstrap_3_layout.html.twig b/src/Resources/views/form/bootstrap_4.html.twig similarity index 100% rename from src/Resources/views/form/bootstrap_3_layout.html.twig rename to src/Resources/views/form/bootstrap_4.html.twig diff --git a/tests/Controller/EmbeddedListTest.php b/tests/Controller/EmbeddedListTest.php index 678f3055..2c267bb7 100644 --- a/tests/Controller/EmbeddedListTest.php +++ b/tests/Controller/EmbeddedListTest.php @@ -106,7 +106,7 @@ public function testRequestMultivalueFiltersAreApplied() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( '1 - 15 of 100', - $crawler->filter('#main .list-pagination')->text() + $crawler->filter('section.content-footer .list-pagination')->text() ); $searchFormCrawler = $crawler->filter('.action-search form'); @@ -147,7 +147,7 @@ public function testRequestNotNullFilterIsApplied() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( '1 - 15 of 90', - $crawler->filter('#main .list-pagination')->text() + $crawler->filter('section.content-footer .list-pagination')->text() ); } diff --git a/tests/Controller/RequestParametersTest.php b/tests/Controller/RequestParametersTest.php index 777884db..cbf1c9d5 100644 --- a/tests/Controller/RequestParametersTest.php +++ b/tests/Controller/RequestParametersTest.php @@ -76,7 +76,7 @@ public function testRequestMultivalueFiltersAreApplied() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( '1 - 15 of 100', - $crawler->filter('#main .list-pagination')->text() + $crawler->filter('section.content-footer .list-pagination')->text() ); $searchFormCrawler = $crawler->filter('.action-search form'); @@ -118,7 +118,7 @@ public function testRequestNotNullFilterIsApplied() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( '1 - 15 of 90', - $crawler->filter('#main .list-pagination')->text() + $crawler->filter('section.content-footer .list-pagination')->text() ); } @@ -131,7 +131,7 @@ public function testRequestEmptyFilterIsIgnored() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( '1 - 15 of 100', - $crawler->filter('#main .list-pagination')->text() + $crawler->filter('section.content-footer .list-pagination')->text() ); } } From 37c3e06f62bb1acbc7dba7326d302f72315da747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Mon, 10 Dec 2018 22:20:08 +0100 Subject: [PATCH 11/15] Fix tests based on pagination counter --- TODO-UPGRADE-EAB2.md | 1 + tests/Controller/EmbeddedListTest.php | 8 ++++---- tests/Controller/RequestParametersTest.php | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/TODO-UPGRADE-EAB2.md b/TODO-UPGRADE-EAB2.md index 9f4d30f2..c922f111 100644 --- a/TODO-UPGRADE-EAB2.md +++ b/TODO-UPGRADE-EAB2.md @@ -3,3 +3,4 @@ - Config for Travis CI (https://github.com/EasyCorp/EasyAdminBundle/compare/1.x...master#diff-354f30a63fb0907d4ad57269548329e3) - Upgrade to Bootstrap 4 +- Début modif templates : https://github.com/EasyCorp/EasyAdminBundle/compare/1.x...master#diff-f79d865e04c5546d92f8fcec7ae94b19 diff --git a/tests/Controller/EmbeddedListTest.php b/tests/Controller/EmbeddedListTest.php index 2c267bb7..7ebe90bd 100644 --- a/tests/Controller/EmbeddedListTest.php +++ b/tests/Controller/EmbeddedListTest.php @@ -105,8 +105,8 @@ public function testRequestMultivalueFiltersAreApplied() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( - '1 - 15 of 100', - $crawler->filter('section.content-footer .list-pagination')->text() + '100 results', + $crawler->filter('section.content-footer .list-pagination-counter')->text() ); $searchFormCrawler = $crawler->filter('.action-search form'); @@ -146,8 +146,8 @@ public function testRequestNotNullFilterIsApplied() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( - '1 - 15 of 90', - $crawler->filter('section.content-footer .list-pagination')->text() + '90 results', + $crawler->filter('section.content-footer .list-pagination-counter')->text() ); } diff --git a/tests/Controller/RequestParametersTest.php b/tests/Controller/RequestParametersTest.php index cbf1c9d5..e50f696a 100644 --- a/tests/Controller/RequestParametersTest.php +++ b/tests/Controller/RequestParametersTest.php @@ -75,8 +75,8 @@ public function testRequestMultivalueFiltersAreApplied() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( - '1 - 15 of 100', - $crawler->filter('section.content-footer .list-pagination')->text() + '100 results', + $crawler->filter('section.content-footer .list-pagination-counter')->text() ); $searchFormCrawler = $crawler->filter('.action-search form'); @@ -117,8 +117,8 @@ public function testRequestNotNullFilterIsApplied() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( - '1 - 15 of 90', - $crawler->filter('section.content-footer .list-pagination')->text() + '90 results', + $crawler->filter('section.content-footer .list-pagination-counter')->text() ); } @@ -130,8 +130,8 @@ public function testRequestEmptyFilterIsIgnored() $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertContains( - '1 - 15 of 100', - $crawler->filter('section.content-footer .list-pagination')->text() + '100 results', + $crawler->filter('section.content-footer .list-pagination-counter')->text() ); } } From ee704d92fbe8d8c76fea56f91ef79295f00f8148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Tue, 11 Dec 2018 15:06:30 +0100 Subject: [PATCH 12/15] bootstrap4 migration (btn and card) --- src/Resources/public/js/easyadmin-extension.js | 9 --------- src/Resources/public/stylesheet/easyadmin-extension.css | 4 ++++ src/Resources/views/default/embedded_list.html.twig | 2 +- src/Resources/views/default/list.html.twig | 8 ++++---- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Resources/public/js/easyadmin-extension.js b/src/Resources/public/js/easyadmin-extension.js index c59c04bc..fbb27cb2 100644 --- a/src/Resources/public/js/easyadmin-extension.js +++ b/src/Resources/public/js/easyadmin-extension.js @@ -74,15 +74,6 @@ $(function() { $('#modal-confirm').modal({ backdrop: true, keyboard: true }); }); - - // Deal with panel-heading toggling collapsible panel-body - // (@see https://stackoverflow.com/questions/33725181/bootstrap-using-panel-heading-to-collapse-panel-body) - $('.panel-heading[data-toggle^="collapse"]').click(function(){ - var target = $(this).attr('data-target'); - $(target).collapse('toggle'); - }).children().click(function(e) { - e.stopPropagation(); - }); }); function serializeForm(form) { diff --git a/src/Resources/public/stylesheet/easyadmin-extension.css b/src/Resources/public/stylesheet/easyadmin-extension.css index a2061867..1f232c28 100644 --- a/src/Resources/public/stylesheet/easyadmin-extension.css +++ b/src/Resources/public/stylesheet/easyadmin-extension.css @@ -1,3 +1,7 @@ #list-form-filters { margin: 10px 0; } + +#list-form-filters .card-header[data-toggle^="collapse"] { + cursor: pointer; +} diff --git a/src/Resources/views/default/embedded_list.html.twig b/src/Resources/views/default/embedded_list.html.twig index eff15e53..0fb55aaf 100644 --- a/src/Resources/views/default/embedded_list.html.twig +++ b/src/Resources/views/default/embedded_list.html.twig @@ -103,7 +103,7 @@ {% block open_new_tab %} - + {{ 'open.new_tab'|trans({}, 'EasyAdminBundle') }} diff --git a/src/Resources/views/default/list.html.twig b/src/Resources/views/default/list.html.twig index 378a16c8..1ba8490d 100644 --- a/src/Resources/views/default/list.html.twig +++ b/src/Resources/views/default/list.html.twig @@ -67,15 +67,15 @@ {% block list_form_filters %} {% if _entity_config.list.form_filters is defined and _entity_config.list.form_filters is not empty %} {% set list_form_filters = list_form_filters(_entity_config.list.form_filters) %} -
-
- {{ 'list_form_filters.heading_title'|trans(_trans_parameters, 'EasyAdminBundle') }} +
+
+ {{ 'list_form_filters.heading_title'|trans(_trans_parameters, 'EasyAdminBundle') }} {{ 'list_form_filters.heading_expandcollapse'|trans(_trans_parameters, 'EasyAdminBundle') }}
-
+
{% form_theme list_form_filters '@EasyAdmin/form/bootstrap_4.html.twig' %} From 583781cd90b696d97c12e9a8cbfb4c25e397392b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Tue, 11 Dec 2018 16:57:58 +0100 Subject: [PATCH 13/15] col-* refacto --- .../public/stylesheet/easyadmin-extension.css | 2 +- src/Resources/views/default/edit.html.twig | 4 +- src/Resources/views/default/list.html.twig | 56 +++++++++---------- src/Resources/views/default/show.html.twig | 4 +- .../views/default/show_vertical.html.twig | 2 +- 5 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/Resources/public/stylesheet/easyadmin-extension.css b/src/Resources/public/stylesheet/easyadmin-extension.css index 1f232c28..71332458 100644 --- a/src/Resources/public/stylesheet/easyadmin-extension.css +++ b/src/Resources/public/stylesheet/easyadmin-extension.css @@ -2,6 +2,6 @@ margin: 10px 0; } -#list-form-filters .card-header[data-toggle^="collapse"] { +#list-form-filters-header[data-toggle^="collapse"] { cursor: pointer; } diff --git a/src/Resources/views/default/edit.html.twig b/src/Resources/views/default/edit.html.twig index 35d91adc..8c7ff7d9 100644 --- a/src/Resources/views/default/edit.html.twig +++ b/src/Resources/views/default/edit.html.twig @@ -2,13 +2,13 @@ {% block content_header %}
-
+
{% block content_title_wrapper %}

{{ block('content_title') }}

{% endblock %}
-
+
{% block header_actions '' %}
diff --git a/src/Resources/views/default/list.html.twig b/src/Resources/views/default/list.html.twig index 1ba8490d..abb11aed 100644 --- a/src/Resources/views/default/list.html.twig +++ b/src/Resources/views/default/list.html.twig @@ -30,9 +30,10 @@ {% endif %}
-
+
{% for filterKey, filterValue in requestFilters %} -
{{ filterKey }}
{{ filterValue is iterable ? filterValue|join(',') : filterValue }}
+
{{ filterKey }}
+
{{ filterValue is iterable ? filterValue|join(',') : filterValue }}
{% endfor %}
@@ -68,38 +69,36 @@ {% if _entity_config.list.form_filters is defined and _entity_config.list.form_filters is not empty %} {% set list_form_filters = list_form_filters(_entity_config.list.form_filters) %}
-
- {{ 'list_form_filters.heading_title'|trans(_trans_parameters, 'EasyAdminBundle') }} +
+ {{ 'list_form_filters.heading_title'|trans(_trans_parameters, 'EasyAdminBundle') }} {{ 'list_form_filters.heading_expandcollapse'|trans(_trans_parameters, 'EasyAdminBundle') }}
-
-
-
- {% form_theme list_form_filters '@EasyAdmin/form/bootstrap_4.html.twig' %} - {{ block('request_parameters_as_hidden') }} - - - - - -
- {% for field in list_form_filters %} -
{{ form_row(field) }}
- {% endfor %} -
-
+ {#
#} +
+ {% form_theme list_form_filters '@EasyAdmin/form/bootstrap_4.html.twig' %} + {{ block('request_parameters_as_hidden') }} + + + + + +
+ {% for field in list_form_filters %} +
{{ form_row(field) }}
+ {% endfor %} +
-
- -
-
-
+
+ +
+
+ {#
#}
{% endif %} @@ -118,8 +117,5 @@ $(function () { createAutoCompleteFields(); }); - $("#list-form-filters [data-toggle][data-target=\"#list-form-filters-form\"] *").click(function() { - $('#list-form-filters-form').collapse('toggle'); - }); {% endblock %} diff --git a/src/Resources/views/default/show.html.twig b/src/Resources/views/default/show.html.twig index 9902c95a..83ecd611 100644 --- a/src/Resources/views/default/show.html.twig +++ b/src/Resources/views/default/show.html.twig @@ -2,13 +2,13 @@ {% block content_header %}
-
+
{% block content_title_wrapper %}

{{ block('content_title') }}

{% endblock %}
-
+
{% block header_actions '' %}
diff --git a/src/Resources/views/default/show_vertical.html.twig b/src/Resources/views/default/show_vertical.html.twig index c80f3d3e..1f34c21f 100644 --- a/src/Resources/views/default/show_vertical.html.twig +++ b/src/Resources/views/default/show_vertical.html.twig @@ -22,7 +22,7 @@ {% endblock %}
-
+
{{ block('item_actions') }}
From 83366d9a40a039252a45c76e1e1879ecaaa815f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Wed, 12 Dec 2018 22:27:15 +0100 Subject: [PATCH 14/15] Trying to display list filters block --- src/Resources/views/default/edit.html.twig | 17 -------- src/Resources/views/default/list.html.twig | 51 ++++++++++------------ src/Resources/views/default/show.html.twig | 16 ------- 3 files changed, 24 insertions(+), 60 deletions(-) delete mode 100644 src/Resources/views/default/edit.html.twig diff --git a/src/Resources/views/default/edit.html.twig b/src/Resources/views/default/edit.html.twig deleted file mode 100644 index 8c7ff7d9..00000000 --- a/src/Resources/views/default/edit.html.twig +++ /dev/null @@ -1,17 +0,0 @@ -{% extends '@BaseEasyAdmin/default/edit.html.twig' %} - -{% block content_header %} -
-
- {% block content_title_wrapper %} -

{{ block('content_title') }}

- {% endblock %} -
- -
-
- {% block header_actions '' %} -
-
-
-{% endblock content_header %} diff --git a/src/Resources/views/default/list.html.twig b/src/Resources/views/default/list.html.twig index abb11aed..99e1d998 100644 --- a/src/Resources/views/default/list.html.twig +++ b/src/Resources/views/default/list.html.twig @@ -17,27 +17,25 @@ {% endfor %} {% endblock %} -{% block content_title_wrapper %} -

- {{ block('content_title') }} - {# Show applied filters informations #} - {% if requestFilters|length > 0 %} - - - - - - {% endif %} -

-
-
- {% for filterKey, filterValue in requestFilters %} -
{{ filterKey }}
-
{{ filterValue is iterable ? filterValue|join(',') : filterValue }}
- {% endfor %} -
-
-{% endblock %} +{#% block global_actions %#} + {#{ dump(requestFilters) }#} + {#{% if requestFilters|length > 0 %} + + + + + +
+
+ {% for filterKey, filterValue in requestFilters %} +
{{ filterKey }}
+
{{ filterValue is iterable ? filterValue|join(',') : filterValue }}
+ {% endfor %} +
+
+ {% endif %}#} + {#{ parent() }#} +{#% endblock %#} {# Do not display SEARCH form if not granted #} {% block search_action %} @@ -45,6 +43,11 @@ {{ parent() }} {% endif %} {% endblock %} +{# Adds request filters to the search form #} +{% block search_form %} + {{ block('request_parameters_as_hidden') }} + {{ parent() }} +{% endblock %} {# Do not display NEW button if not granted #} {% block new_action %} @@ -59,12 +62,6 @@ {{ parent() }} {% endblock %} -{# Adds request filters to the search form #} -{% block search_form %} - {{ block('request_parameters_as_hidden') }} - {{ parent() }} -{% endblock %} - {% block list_form_filters %} {% if _entity_config.list.form_filters is defined and _entity_config.list.form_filters is not empty %} {% set list_form_filters = list_form_filters(_entity_config.list.form_filters) %} diff --git a/src/Resources/views/default/show.html.twig b/src/Resources/views/default/show.html.twig index 83ecd611..2239b6bb 100644 --- a/src/Resources/views/default/show.html.twig +++ b/src/Resources/views/default/show.html.twig @@ -1,21 +1,5 @@ {% extends '@BaseEasyAdmin/default/show.html.twig' %} -{% block content_header %} -
-
- {% block content_title_wrapper %} -

{{ block('content_title') }}

- {% endblock %} -
- -
-
- {% block header_actions '' %} -
-
-
-{% endblock content_header %} - {# Do not display list action items if not granted #} {% block item_actions %} {% set _show_actions = easyadmin_get_actions_for_show_item(_entity_config.name)|prune_item_actions(_entity_config, [], entity) %} From f223d6bf410d388324b51113e3ad7690417e4e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Thu, 13 Dec 2018 12:32:18 +0100 Subject: [PATCH 15/15] Fix btn size class --- src/Resources/views/default/embedded_list.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/views/default/embedded_list.html.twig b/src/Resources/views/default/embedded_list.html.twig index 0fb55aaf..0e5077b9 100644 --- a/src/Resources/views/default/embedded_list.html.twig +++ b/src/Resources/views/default/embedded_list.html.twig @@ -103,7 +103,7 @@ {% block open_new_tab %} - + {{ 'open.new_tab'|trans({}, 'EasyAdminBundle') }}