diff --git a/Tests/Attribute/AsListenerTest.php b/Tests/Attribute/AsListenerTest.php index 0a8c232..0656574 100644 --- a/Tests/Attribute/AsListenerTest.php +++ b/Tests/Attribute/AsListenerTest.php @@ -11,15 +11,14 @@ namespace Symfony\Component\Workflow\Tests\Attribute; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Workflow\Attribute; use Symfony\Component\Workflow\Exception\LogicException; class AsListenerTest extends TestCase { - /** - * @dataProvider provideOkTests - */ + #[DataProvider('provideOkTests')] public function testOk(string $class, string $expectedEvent, ?string $workflow = null, ?string $node = null) { $attribute = new $class($workflow, $node); @@ -58,9 +57,7 @@ public static function provideOkTests(): iterable yield [Attribute\AsTransitionListener::class, 'workflow.w.transition.n', 'w', 'n']; } - /** - * @dataProvider provideTransitionThrowException - */ + #[DataProvider('provideTransitionThrowException')] public function testTransitionThrowException(string $class) { $this->expectException(LogicException::class); @@ -71,15 +68,13 @@ public function testTransitionThrowException(string $class) public static function provideTransitionThrowException(): iterable { - yield [Attribute\AsAnnounceListener::class, 'workflow.announce']; - yield [Attribute\AsCompletedListener::class, 'workflow.completed']; - yield [Attribute\AsGuardListener::class, 'workflow.guard']; - yield [Attribute\AsTransitionListener::class, 'workflow.transition']; + yield [Attribute\AsAnnounceListener::class]; + yield [Attribute\AsCompletedListener::class]; + yield [Attribute\AsGuardListener::class]; + yield [Attribute\AsTransitionListener::class]; } - /** - * @dataProvider providePlaceThrowException - */ + #[DataProvider('providePlaceThrowException')] public function testPlaceThrowException(string $class) { $this->expectException(LogicException::class); @@ -90,8 +85,8 @@ public function testPlaceThrowException(string $class) public static function providePlaceThrowException(): iterable { - yield [Attribute\AsEnteredListener::class, 'workflow.entered']; - yield [Attribute\AsEnterListener::class, 'workflow.enter']; - yield [Attribute\AsLeaveListener::class, 'workflow.leave']; + yield [Attribute\AsEnteredListener::class]; + yield [Attribute\AsEnterListener::class]; + yield [Attribute\AsLeaveListener::class]; } } diff --git a/Tests/Debug/TraceableWorkflowTest.php b/Tests/Debug/TraceableWorkflowTest.php index 257ad66..d513450 100644 --- a/Tests/Debug/TraceableWorkflowTest.php +++ b/Tests/Debug/TraceableWorkflowTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Workflow\Tests\Debug; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Stopwatch\Stopwatch; @@ -38,9 +39,7 @@ protected function setUp(): void ); } - /** - * @dataProvider provideFunctionNames - */ + #[DataProvider('provideFunctionNames')] public function testCallsInner(string $function, array $args, mixed $returnValue) { $this->innerWorkflow->expects($this->once()) diff --git a/Tests/Dumper/GraphvizDumperTest.php b/Tests/Dumper/GraphvizDumperTest.php index 9356715..228c496 100644 --- a/Tests/Dumper/GraphvizDumperTest.php +++ b/Tests/Dumper/GraphvizDumperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Workflow\Tests\Dumper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Workflow\Dumper\GraphvizDumper; use Symfony\Component\Workflow\Marking; @@ -20,9 +21,7 @@ class GraphvizDumperTest extends TestCase { use WorkflowBuilderTrait; - /** - * @dataProvider provideWorkflowDefinitionWithoutMarking - */ + #[DataProvider('provideWorkflowDefinitionWithoutMarking')] public function testDumpWithoutMarking($definition, $expected, $withMetadata) { $dump = (new GraphvizDumper())->dump($definition, null, ['with-metadata' => $withMetadata]); @@ -30,9 +29,7 @@ public function testDumpWithoutMarking($definition, $expected, $withMetadata) $this->assertEquals($expected, $dump); } - /** - * @dataProvider provideWorkflowDefinitionWithMarking - */ + #[DataProvider('provideWorkflowDefinitionWithMarking')] public function testDumpWithMarking($definition, $marking, $expected, $withMetadata) { $dump = (new GraphvizDumper())->dump($definition, $marking, ['with-metadata' => $withMetadata]); diff --git a/Tests/Dumper/MermaidDumperTest.php b/Tests/Dumper/MermaidDumperTest.php index a8d1978..639f67c 100644 --- a/Tests/Dumper/MermaidDumperTest.php +++ b/Tests/Dumper/MermaidDumperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Workflow\Tests\Dumper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Workflow\Definition; use Symfony\Component\Workflow\DefinitionBuilder; @@ -23,9 +24,7 @@ class MermaidDumperTest extends TestCase { use WorkflowBuilderTrait; - /** - * @dataProvider provideWorkflowDefinitionWithoutMarking - */ + #[DataProvider('provideWorkflowDefinitionWithoutMarking')] public function testDumpWithoutMarking(Definition $definition, string $expected) { $dumper = new MermaidDumper(MermaidDumper::TRANSITION_TYPE_WORKFLOW); @@ -35,9 +34,7 @@ public function testDumpWithoutMarking(Definition $definition, string $expected) $this->assertEquals($expected, $dump); } - /** - * @dataProvider provideWorkflowWithReservedWords - */ + #[DataProvider('provideWorkflowWithReservedWords')] public function testDumpWithReservedWordsAsPlacenames(Definition $definition, string $expected) { $dumper = new MermaidDumper(MermaidDumper::TRANSITION_TYPE_WORKFLOW); @@ -47,9 +44,7 @@ public function testDumpWithReservedWordsAsPlacenames(Definition $definition, st $this->assertEquals($expected, $dump); } - /** - * @dataProvider provideStateMachine - */ + #[DataProvider('provideStateMachine')] public function testDumpAsStateMachine(Definition $definition, string $expected) { $dumper = new MermaidDumper(MermaidDumper::TRANSITION_TYPE_STATEMACHINE); @@ -59,9 +54,7 @@ public function testDumpAsStateMachine(Definition $definition, string $expected) $this->assertEquals($expected, $dump); } - /** - * @dataProvider provideWorkflowWithMarking - */ + #[DataProvider('provideWorkflowWithMarking')] public function testDumpWorkflowWithMarking(Definition $definition, Marking $marking, string $expected) { $dumper = new MermaidDumper(MermaidDumper::TRANSITION_TYPE_WORKFLOW); diff --git a/Tests/Dumper/PlantUmlDumperTest.php b/Tests/Dumper/PlantUmlDumperTest.php index a018a4e..838c9bd 100644 --- a/Tests/Dumper/PlantUmlDumperTest.php +++ b/Tests/Dumper/PlantUmlDumperTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Workflow\Tests\Dumper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Workflow\Definition; use Symfony\Component\Workflow\Dumper\PlantUmlDumper; @@ -23,9 +24,7 @@ class PlantUmlDumperTest extends TestCase { use WorkflowBuilderTrait; - /** - * @dataProvider provideWorkflowDefinitionWithoutMarking - */ + #[DataProvider('provideWorkflowDefinitionWithoutMarking')] public function testDumpWorkflowWithoutMarking($definition, $marking, $expectedFileName, $title) { $dumper = new PlantUmlDumper(PlantUmlDumper::WORKFLOW_TRANSITION); @@ -46,9 +45,7 @@ public static function provideWorkflowDefinitionWithoutMarking(): \Generator yield [self::createComplexWorkflowDefinition(), $marking, 'complex-workflow-marking', 'ComplexDiagram']; } - /** - * @dataProvider provideStateMachineDefinitionWithoutMarking - */ + #[DataProvider('provideStateMachineDefinitionWithoutMarking')] public function testDumpStateMachineWithoutMarking($definition, $marking, $expectedFileName, $title) { $dumper = new PlantUmlDumper(PlantUmlDumper::STATEMACHINE_TRANSITION); diff --git a/Tests/Dumper/StateMachineGraphvizDumperTest.php b/Tests/Dumper/StateMachineGraphvizDumperTest.php index 20b3694..52779e4 100644 --- a/Tests/Dumper/StateMachineGraphvizDumperTest.php +++ b/Tests/Dumper/StateMachineGraphvizDumperTest.php @@ -27,23 +27,23 @@ public function testDumpWithoutMarking() $dump = (new StateMachineGraphvizDumper())->dump($definition); $expected = <<<'EOGRAPH' -digraph workflow { - ratio="compress" rankdir="LR" - node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="false" width="1"]; - edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"]; - - place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle style="filled"]; - place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle]; - place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle]; - place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle]; - place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"]; - place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition -label 3" style="solid" fontcolor="Grey" color="Red"]; - place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid" color="Blue"]; - place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"]; -} - -EOGRAPH; + digraph workflow { + ratio="compress" rankdir="LR" + node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="false" width="1"]; + edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"]; + + place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle style="filled"]; + place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle]; + place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle]; + place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle]; + place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"]; + place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition + label 3" style="solid" fontcolor="Grey" color="Red"]; + place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid" color="Blue"]; + place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"]; + } + + EOGRAPH; $this->assertEquals($expected, $dump); } @@ -54,23 +54,23 @@ public function testDumpWithMarking() $marking = new Marking(['b' => 1]); $expected = <<<'EOGRAPH' -digraph workflow { - ratio="compress" rankdir="LR" - node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="false" width="1"]; - edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"]; - - place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle style="filled"]; - place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle color="#FF0000" shape="doublecircle"]; - place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle]; - place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle]; - place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"]; - place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition -label 3" style="solid" fontcolor="Grey" color="Red"]; - place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid" color="Blue"]; - place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"]; -} - -EOGRAPH; + digraph workflow { + ratio="compress" rankdir="LR" + node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="false" width="1"]; + edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"]; + + place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle style="filled"]; + place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle color="#FF0000" shape="doublecircle"]; + place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle]; + place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle]; + place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"]; + place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition + label 3" style="solid" fontcolor="Grey" color="Red"]; + place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid" color="Blue"]; + place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"]; + } + + EOGRAPH; $dump = (new StateMachineGraphvizDumper())->dump($definition, $marking); diff --git a/Tests/Event/EventNameTraitTest.php b/Tests/Event/EventNameTraitTest.php index 3c74523..24780f4 100644 --- a/Tests/Event/EventNameTraitTest.php +++ b/Tests/Event/EventNameTraitTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Workflow\Tests\Event; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Workflow\Event\AnnounceEvent; use Symfony\Component\Workflow\Event\CompletedEvent; @@ -23,10 +24,9 @@ class EventNameTraitTest extends TestCase { /** - * @dataProvider getEvents - * * @param class-string $class */ + #[DataProvider('getEvents')] public function testEventNames(string $class, ?string $workflowName, ?string $transitionOrPlaceName, string $expected) { $name = $class::getName($workflowName, $transitionOrPlaceName); diff --git a/Tests/WorkflowBuilderTrait.php b/Tests/WorkflowBuilderTrait.php index 86478bb..99a07d7 100644 --- a/Tests/WorkflowBuilderTrait.php +++ b/Tests/WorkflowBuilderTrait.php @@ -129,9 +129,9 @@ private static function createComplexStateMachineDefinition(): Definition $transitionsMetadata = new \SplObjectStorage(); // PHP 7.2 doesn't allow this heredoc syntax in an array, use a dedicated variable instead $label = <<<'EOTXT' -My custom transition -label 3 -EOTXT; + My custom transition + label 3 + EOTXT; $transitionsMetadata[$transitionWithMetadataDumpStyle] = [ 'label' => $label, 'color' => 'Grey', diff --git a/Tests/WorkflowTest.php b/Tests/WorkflowTest.php index 48e2209..d44d2c6 100644 --- a/Tests/WorkflowTest.php +++ b/Tests/WorkflowTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Workflow\Tests; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Workflow\Definition; @@ -27,6 +29,7 @@ use Symfony\Component\Workflow\TransitionBlocker; use Symfony\Component\Workflow\Workflow; use Symfony\Component\Workflow\WorkflowEvents; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; class WorkflowTest extends TestCase { @@ -439,9 +442,7 @@ public static function provideApplyWithEventDispatcherForAnnounceTests(): \Gener yield [true, []]; } - /** - * @dataProvider provideApplyWithEventDispatcherForAnnounceTests - */ + #[DataProvider('provideApplyWithEventDispatcherForAnnounceTests')] public function testApplyWithEventDispatcherForAnnounce(bool $fired, array $context) { $definition = $this->createComplexWorkflowDefinition(); @@ -820,10 +821,8 @@ public function testGetEnabledTransitionsWithSameNameTransition() $this->assertSame('to_a', $transitions[2]->getName()); } - /** - * @@testWith ["back1"] - * ["back2"] - */ + #[TestWith(['back1'])] + #[TestWith(['back2'])] public function testApplyWithSameNameBackTransition(string $transition) { $definition = $this->createWorkflowWithSameNameBackTransition(); @@ -878,7 +877,7 @@ private function assertPlaces(array $expected, Marking $marking) } } -class EventDispatcherMock implements \Symfony\Contracts\EventDispatcher\EventDispatcherInterface +class EventDispatcherMock implements EventDispatcherInterface { public array $dispatchedEvents = []; diff --git a/composer.json b/composer.json index 3e2c50a..ff8561c 100644 --- a/composer.json +++ b/composer.json @@ -25,15 +25,15 @@ }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^6.4|^7.0", - "symfony/dependency-injection": "^6.4|^7.0", - "symfony/error-handler": "^6.4|^7.0", - "symfony/event-dispatcher": "^6.4|^7.0", - "symfony/expression-language": "^6.4|^7.0", - "symfony/http-kernel": "^6.4|^7.0", - "symfony/security-core": "^6.4|^7.0", - "symfony/stopwatch": "^6.4|^7.0", - "symfony/validator": "^6.4|^7.0" + "symfony/config": "^6.4|^7.0|^8.0", + "symfony/dependency-injection": "^6.4|^7.0|^8.0", + "symfony/error-handler": "^6.4|^7.0|^8.0", + "symfony/event-dispatcher": "^6.4|^7.0|^8.0", + "symfony/expression-language": "^6.4|^7.0|^8.0", + "symfony/http-kernel": "^6.4|^7.0|^8.0", + "symfony/security-core": "^6.4|^7.0|^8.0", + "symfony/stopwatch": "^6.4|^7.0|^8.0", + "symfony/validator": "^6.4|^7.0|^8.0" }, "conflict": { "symfony/event-dispatcher": "<6.4" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 15e5deb..f4d8267 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,11 @@ @@ -18,7 +19,7 @@ - + ./ @@ -26,5 +27,9 @@ ./Tests ./vendor - + + + + +