|
12 | 12 | namespace Symfony\Component\Workflow\Tests\Dumper;
|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
| 15 | +use Symfony\Component\Workflow\Definition; |
15 | 16 | use Symfony\Component\Workflow\Dumper\PlantUmlDumper;
|
16 | 17 | use Symfony\Component\Workflow\Marking;
|
| 18 | +use Symfony\Component\Workflow\Metadata\InMemoryMetadataStore; |
17 | 19 | use Symfony\Component\Workflow\Tests\WorkflowBuilderTrait;
|
| 20 | +use Symfony\Component\Workflow\Transition; |
18 | 21 |
|
19 | 22 | class PlantUmlDumperTest extends TestCase
|
20 | 23 | {
|
@@ -63,6 +66,34 @@ public function provideStateMachineDefinitionWithoutMarking()
|
63 | 66 | yield [$this->createComplexStateMachineDefinition(), $marking, 'complex-state-machine-marking', 'SimpleDiagram'];
|
64 | 67 | }
|
65 | 68 |
|
| 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 | + |
66 | 97 | private function getFixturePath($name, $transitionType)
|
67 | 98 | {
|
68 | 99 | return __DIR__.'/../fixtures/puml/'.$transitionType.'/'.$name.'.puml';
|
|
0 commit comments