From f585930d6d2e88f92c8309548345049a1fa842ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 24 Jul 2023 10:32:32 +0200 Subject: [PATCH] [FrameworkBundle][Workflow] Throw exception is workflow.xxx.transitions is not an array --- .../DependencyInjection/Configuration.php | 8 +++++ .../PhpFrameworkExtensionTest.php | 31 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index e9b95db35a0c2..156c16b27ae8f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -446,6 +446,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) ->beforeNormalization() ->always() ->then(function ($places) { + if (!\is_array($places)) { + throw new InvalidConfigurationException('The "places" option must be an array in workflow configuration.'); + } + // It's an indexed array of shape ['place1', 'place2'] if (isset($places[0]) && \is_string($places[0])) { return array_map(function (string $place) { @@ -491,6 +495,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) ->beforeNormalization() ->always() ->then(function ($transitions) { + if (!\is_array($transitions)) { + throw new InvalidConfigurationException('The "transitions" option must be an array in workflow configuration.'); + } + // It's an indexed array, we let the validation occur if (isset($transitions[0]) && \is_array($transitions[0])) { return $transitions; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index 871b62e8811da..77332f5a6b95c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection; +use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\LogicException; @@ -56,6 +57,36 @@ public function testAssetPackageCannotHavePathAndUrl() }); } + public function testWorkflowValidationPlacesIsArray() + { + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('The "places" option must be an array in workflow configuration.'); + $this->createContainerFromClosure(function ($container) { + $container->loadFromExtension('framework', [ + 'workflows' => [ + 'article' => [ + 'places' => null, + ], + ], + ]); + }); + } + + public function testWorkflowValidationTransitonsIsArray() + { + $this->expectException(InvalidConfigurationException::class); + $this->expectExceptionMessage('The "transitions" option must be an array in workflow configuration.'); + $this->createContainerFromClosure(function ($container) { + $container->loadFromExtension('framework', [ + 'workflows' => [ + 'article' => [ + 'transitions' => null, + ], + ], + ]); + }); + } + public function testWorkflowValidationStateMachine() { $this->expectException(InvalidDefinitionException::class); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy