8000 [FrameworkBundle][Workflow] Throw exception is workflow.xxx.transitions is not an array by lyrixx · Pull Request #51078 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle][Workflow] Throw exception is workflow.xxx.transitions is not an array #51078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle][Workflow] Throw exception is workflow.xxx.transitio…
…ns is not an array
  • Loading branch information
lyrixx committed Jul 24, 2023
commit f585930d6d2e88f92c8309548345049a1fa842ee
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
0