Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d418395

Browse files
committed
minor #26123 [Workflow] Drop nofooter option in PlantUmlDumper (dead code) (lyrixx)
This PR was merged into the 4.1-dev branch. Discussion ---------- [Workflow] Drop nofooter option in PlantUmlDumper (dead code) | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | --- I also update the test suite: Dumping a worklow with a state machine dumper does not make sense. Commits ------- 9b94647 [Workflow] Drop nofooter option in PlantUmlDumper (dead code)
2 parents 7822436 + 9b94647 commit d418395

18 files changed

+37
-436
lines changed

src/Symfony/Component/Workflow/Dumper/PlantUmlDumper.php

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@
2626
*/
2727
class PlantUmlDumper implements DumperInterface
2828
{
29-
private const SYMFONY_LOGO = 'sprite $sf_logo [81x20/16z] {
30-
hPNRaYiX24K1xwBo_tyx6-qaCtDEJ-KXLYMTLbp0HWcHZr3KRDJ8z94HG3jZn4_mijbQ2ryJoFePtXLWA_qxyGy19DpdY_10z11ZAbGjFHRwcEbcKx5-wqsV
31-
yIMo8StMCHKh8ZUxnEwrZiwRAUOvy1lLcPQF4lEFAjhzMd5WOAqvKflS0Enx8PbihiSYXM8ClGVAseIWTAjCgVSAcnYbQG79xKFsZ0VnDCNc7AVBoPSMcTsX
32-
UnrujbYjjz0NnsObkTgnmolqJD4QgGUYTQiNe8eIjtx4b6Vv8nPGpncn3NJ8Geo9W9VW2wGACm_JzgIO8A8KXr2jUBCVGEAAJSZ6JUlsNnmOzmIYti9G7bjL
33-
8InaHM9G40NkwTG7OxrggvNIejA8AZuqyWjOzTIKi-wwYvjeHYesSWuPiTGDN5THzkYLU4MD5r2_0PDhG7LIUG33z5HtM6CP3icyWEVOS61sD_2ZsBfJdbVA
34-
qM53XHDUwhY0TAwPug3OG9NonRFhO8ynF3I4unuAMDHmSrXH57V1RGvl9jafuZF9ZhqjWOEh98y0tUYGsUxkBSllIyBdT2oM5Fn2-ut-fzsq_cQNuL6Uvwqr
35-
knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
36-
}';
3729
private const INITIAL = '<<initial>>';
3830
private const MARKED = '<<marked>>';
3931

@@ -62,7 +54,7 @@ class PlantUmlDumper implements DumperInterface
6254

6355
public function __construct(string $transitionType = null)
6456
{
65-
if (!in_array($transitionType, self::TRANSITION_TYPES)) {
57+
if (!\in_array($transitionType, self::TRANSITION_TYPES, true)) {
6658
throw new InvalidArgumentException("Transition type '$transitionType' does not exist.");
6759
}
6860
$this->transitionType = $transitionType;
@@ -121,21 +113,12 @@ private function startPuml(array $options): string
121113
$start = '@startuml'.PHP_EOL;
122114
$start .= 'allow_mixing'.PHP_EOL;
123115

124-
if ($options['nofooter'] ?? false) {
125-
return $start;
126-
}
127-
128-
return $start.self::SYMFONY_LOGO.PHP_EOL;
116+
return $start;
129117
}
130118

131119
private function endPuml(array $options): string
132120
{
133-
$end = PHP_EOL.'@enduml';
134-
if ($options['nofooter'] ?? false) {
135-
return $end;
136-
}
137-
138-
return PHP_EOL.'footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**'.$end;
121+
return PHP_EOL.'@enduml';
139122
}
140123

141124
private function getLines(array $code): string

src/Symfony/Component/Workflow/Tests/Dumper/PlantUmlDumperTest.php

Lines changed: 26 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
namespace Symfony\Component\Workflow\Tests\Dumper;
1212

1313
use PHPUnit\Framework\TestCase;
14-
use Symfony\Component\Workflow\Dumper\DumperInterface;
1514
use Symfony\Component\Workflow\Dumper\PlantUmlDumper;
1615
use Symfony\Component\Workflow\Marking;
1716
use Symfony\Component\Workflow\Tests\WorkflowBuilderTrait;
@@ -21,73 +20,46 @@ class PlantUmlDumperTest extends TestCase
2120
use WorkflowBuilderTrait;
2221

2322
/**
24-
* @var DumperInterface[]
23+
* @dataProvider provideWorkflowDefinitionWithoutMarking
2524
*/
26-
private $dumpers;
27-
28-
protected function setUp()
25+
public function testDumpWorkflowWithoutMarking($definition, $marking, $expectedFileName, $title)
2926
{
30-
$this->dumpers =
31-
array(
32-
PlantUmlDumper::STATEMACHINE_TRANSITION => new PlantUmlDumper(PlantUmlDumper::STATEMACHINE_TRANSITION),
33-
PlantUmlDumper::WORKFLOW_TRANSITION => new PlantUmlDumper(PlantUmlDumper::WORKFLOW_TRANSITION),
34-
);
27+
$dumper = new PlantUmlDumper(PlantUmlDumper::WORKFLOW_TRANSITION);
28+
$dump = $dumper->dump($definition, $marking, array('title' => $title));
29+
// handle windows, and avoid to create more fixtures
30+
$dump = str_replace(PHP_EOL, "\n", $dump.PHP_EOL);
31+
$file = $this->getFixturePath($expectedFileName, PlantUmlDumper::WORKFLOW_TRANSITION);
32+
$this->assertStringEqualsFile($file, $dump);
3533
}
3634

37-
/**
38-
* @dataProvider provideWorkflowDefinitionWithoutMarking
39-
*/
40-
public function testDumpWithoutMarking($definition, $expectedFileName, $title, $nofooter)
35+
public function provideWorkflowDefinitionWithoutMarking()
4136
{
42-
foreach ($this->dumpers as $transitionType => $dumper) {
43-
$dump = $dumper->dump($definition, null, array('title' => $title, 'nofooter' => $nofooter));
44-
// handle windows, and avoid to create more fixtures
45-
$dump = str_replace(PHP_EOL, "\n", $dump.PHP_EOL);
46-
$this->assertStringEqualsFile($this->getFixturePath($expectedFileName, $transitionType), $dump);
47-
}
37+
yield array($this->createSimpleWorkflowDefinition(), null, 'simple-workflow-nomarking', 'SimpleDiagram');
38+
yield array($this->createComplexWorkflowDefinition(), null, 'complex-workflow-nomarking', 'ComplexDiagram');
39+
$marking = new Marking(array('b' => 1));
40+
yield array($this->createSimpleWorkflowDefinition(), $marking, 'simple-workflow-marking', 'SimpleDiagram');
41+
$marking = new Marking(array('c' => 1, 'e' => 1));
42+
yield array($this->createComplexWorkflowDefinition(), $marking, 'complex-workflow-marking', 'ComplexDiagram');
4843
}
4944

5045
/**
51-
* @dataProvider provideWorkflowDefinitionWithMarking
46+
* @dataProvider provideStateMachineDefinitionWithoutMarking
5247
*/
53-
public function testDumpWithMarking($definition, $marking, $expectedFileName, $title, $footer)
54-
{
55-
foreach ($this->dumpers as $transitionType => $dumper) {
56-
$dump = $dumper->dump($definition, $marking, array('title' => $title, 'nofooter' => $footer));
57-
// handle windows, and avoid to create more fixtures
58-
$dump = str_replace(PHP_EOL, "\n", $dump.PHP_EOL);
59-
$this->assertStringEqualsFile($this->getFixturePath($expectedFileName, $transitionType), $dump);
60-
}
61-
}
62-
63-
public function provideWorkflowDefinitionWithoutMarking()
48+
public function testDumpStateMachineWithoutMarking($definition, $marking, $expectedFileName, $title)
6449
{
65-
$title = 'SimpleDiagram';
66-
yield array($this->createSimpleWorkflowDefinition(), 'simple-workflow-nomarking-nofooter', $title, true);
67-
yield array($this->createSimpleWorkflowDefinition(), 'simple-workflow-nomarking', $title, false);
68-
$title = 'ComplexDiagram';
69-
yield array($this->createComplexWorkflowDefinition(), 'complex-workflow-nomarking-nofooter', $title, true);
70-
yield array($this->createComplexWorkflowDefinition(), 'complex-workflow-nomarking', $title, false);
50+
$dumper = new PlantUmlDumper(PlantUmlDumper::STATEMACHINE_TRANSITION);
51+
$dump = $dumper->dump($definition, $marking, array('title' => $title));
52+
// handle windows, and avoid to create more fixtures
53+
$dump = str_replace(PHP_EOL, "\n", $dump.PHP_EOL);
54+
$file = $this->getFixturePath($expectedFileName, PlantUmlDumper::STATEMACHINE_TRANSITION);
55+
$this->assertStringEqualsFile($file, $dump);
7156
}
7257

73-
public function provideWorkflowDefinitionWithMarking()
58+
public function provideStateMachineDefinitionWithoutMarking()
7459
{
75-
$title = 'SimpleDiagram';
76-
$marking = new Marking(array('b' => 1));
77-
yield array(
78-
$this->createSimpleWorkflowDefinition(), $marking, 'simple-workflow-marking-nofooter', $title, true,
79-
);
80-
yield array(
81-
$this->createSimpleWorkflowDefinition(), $marking, 'simple-workflow-marking', $title, false,
82-
);
83-
$title = 'ComplexDiagram';
60+
yield array($this->createComplexStateMachineDefinition(), null, 'complex-state-machine-nomarking', 'SimpleDiagram');
8461
$marking = new Marking(array('c' => 1, 'e' => 1));
85-
yield array(
86-
$this->createComplexWorkflowDefinition(), $marking, 'complex-workflow-marking-nofooter', $title, true,
87-
);
88-
yield array(
89-
$this->createComplexWorkflowDefinition(), $marking, 'complex-workflow-marking', $title, false,
90-
);
62+
yield array($this->createComplexStateMachineDefinition(), $marking, 'complex-state-machine-marking', 'SimpleDiagram');
9163
}
9264

9365
private function getFixturePath($name, $transitionType)

src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/simple-workflow-marking-nofooter.puml renamed to src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-marking.puml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ skinparam state {
1111
FontColor<<marked>> White
1212
}
1313
state "a" <<initial>>
14-
state "b" <<marked>>
15-
state "c"
14+
state "b"
15+
state "c" <<marked>>
16+
state "d"
1617
"a" --> "b": "t1"
18+
"d" --> "b": "t1"
1719
"b" --> "c": "t2"
20+
"b" --> "d": "t3"
1821
@enduml

src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/simple-workflow-nomarking-nofooter.puml renamed to src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-nomarking.puml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ skinparam state {
1313
state "a" <<initial>>
1414
state "b"
1515
state "c"
16+
state "d"
1617
"a" --> "b": "t1"
18+
"d" --> "b": "t1"
1719
"b" --> "c": "t2"
20+
"b" --> "d": "t3"
1821
@enduml

src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-workflow-marking-nofooter.puml

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-workflow-marking.puml

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-workflow-nomarking-nofooter.puml

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-workflow-nomarking.puml

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/simple-workflow-marking.puml

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/simple-workflow-nomarking.puml

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)