Skip to content

Commit 6b51f88

Browse files
Merge branch '6.1' into 6.2
* 6.1: Fix integration test gha Update RedisTrait.php Use static methods inside data providers [VarExporter] Fix exporting classes with __unserialize() but not __serialize() [Validator] Fix IBAN format for Tunisia and Mauritania [Workflow] Allow spaces in place names so the PUML dump doesn't break
2 parents 3ee1548 + 404d8ae commit 6b51f88

File tree

5 files changed

+60
-9
lines changed

5 files changed

+60
-9
lines changed

Dumper/PlantUmlDumper.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Workflow\Dumper;
1313

14-
use InvalidArgumentException;
1514
use Symfony\Component\Workflow\Definition;
1615
use Symfony\Component\Workflow\Marking;
1716
use Symfony\Component\Workflow\Metadata\MetadataStoreInterface;
@@ -57,7 +56,7 @@ class PlantUmlDumper implements DumperInterface
5756
public function __construct(string $transitionType)
5857
{
5958
if (!\in_array($transitionType, self::TRANSITION_TYPES, true)) {
60-
throw new InvalidArgumentException("Transition type '$transitionType' does not exist.");
59+
throw new \InvalidArgumentException("Transition type '$transitionType' does not exist.");
6160
}
6261
$this->transitionType = $transitionType;
6362
}
@@ -209,9 +208,7 @@ private function getState(string $place, Definition $definition, Marking $markin
209208

210209
$description = $workflowMetadata->getMetadata('description', $place);
211210
if (null !== $description) {
212-
$output .= ' as '.$place.
213-
\PHP_EOL.
214-
$place.' : '.$description;
211+
$output .= \PHP_EOL.$placeEscaped.' : '.$description;
215212
}
216213

217214
return $output;

Tests/Dumper/PlantUmlDumperTest.php

+31
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
namespace Symfony\Component\Workflow\Tests\Dumper;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Workflow\Definition;
1516
use Symfony\Component\Workflow\Dumper\PlantUmlDumper;
1617
use Symfony\Component\Workflow\Marking;
18+
use Symfony\Component\Workflow\Metadata\InMemoryMetadataStore;
1719
use Symfony\Component\Workflow\Tests\WorkflowBuilderTrait;
20+
use Symfony\Component\Workflow\Transition;
1821

1922
class PlantUmlDumperTest extends TestCase
2023
{
@@ -63,6 +66,34 @@ public function provideStateMachineDefinitionWithoutMarking()
6366
yield [$this->createComplexStateMachineDefinition(), $marking, 'complex-state-machine-marking', 'SimpleDiagram'];
6467
}
6568

69+
public function testDumpWorkflowWithSpacesInTheStateNamesAndDescription()
70+
{
71+
$dumper = new PlantUmlDumper(PlantUmlDumper::WORKFLOW_TRANSITION);
72+
73+
// The graph looks like:
74+
//
75+
// +---------+ t 1 +----------+ |
76+
// | place a | -----> | place b | |
77+
// +---------+ +----------+ |
78+
$places = ['place a', 'place b'];
79+
80+
$transitions = [];
81+
$transition = new Transition('t 1', 'place a', 'place b');
82+
$transitions[] = $transition;
83+
84+
$placesMetadata = [];
85+
$placesMetadata['place a'] = [
86+
'description' => 'My custom place description',
87+
];
88+
$inMemoryMetadataStore = new InMemoryMetadataStore([], $placesMetadata);
89+
$definition = new Definition($places, $transitions, null, $inMemoryMetadataStore);
90+
91+
$dump = $dumper->dump($definition, null, ['title' => 'SimpleDiagram']);
92+
$dump = str_replace(\PHP_EOL, "\n", $dump.\PHP_EOL);
93+
$file = $this->getFixturePath('simple-workflow-with-spaces', PlantUmlDumper::WORKFLOW_TRANSITION);
94+
$this->assertStringEqualsFile($file, $dump);
95+
}
96+
6697
private function getFixturePath($name, $transitionType)
6798
{
6899
return __DIR__.'/../fixtures/puml/'.$transitionType.'/'.$name.'.puml';

Tests/fixtures/puml/square/simple-workflow-marking.puml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ skinparam agent {
1717
}
1818
state "a" <<initial>>
1919
state "b" <<marked>>
20-
state "c" <<DeepSkyBlue>> as c
21-
c : My custom place description
20+
state "c" <<DeepSkyBlue>>
21+
"c" : My custom place description
2222
agent "t1"
2323
agent "t2"
2424
"a" -[#Purple]-> "t1": "<font color=Grey>My custom transition label 2</font>"

Tests/fixtures/puml/square/simple-workflow-nomarking.puml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ skinparam agent {
1717
}
1818
state "a" <<initial>>
1919
state "b"
20-
state "c" <<DeepSkyBlue>> as c
21-
c : My custom place description
20+
state "c" <<DeepSkyBlue>>
21+
"c" : My custom place description
2222
agent "t1"
2323
agent "t2"
2424
"a" -[#Purple]-> "t1": "<font color=Grey>My custom transition label 2</font>"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@startuml
2+
allow_mixing
3+
title SimpleDiagram
4+
skinparam titleBorderRoundCorner 15
5+
skinparam titleBorderThickness 2
6+
skinparam state {
7+
BackgroundColor<<initial>> #87b741
8+
BackgroundColor<<marked>> #3887C6
9+
BorderColor #3887C6
10+
BorderColor<<marked>> Black
11+
FontColor<<marked>> White
12+
}
13+
skinparam agent {
14+
BackgroundColor #ffffff
15+
BorderColor #3887C6
16+
}
17+
state "place a" <<initial>>
18+
"place a" : My custom place description
19+
state "place b"
20+
agent "t 1"
21+
"place a" --> "t 1"
22+
"t 1" --> "place b"
23+
@enduml

0 commit comments

Comments
 (0)