From 7f9adc8a31173899e3f0b9dc691798118c8f2a02 Mon Sep 17 00:00:00 2001 From: 77web Date: Sun, 21 May 2023 17:36:30 +0900 Subject: [PATCH 1/6] update deps: require php 8.1+ and phpunit 10+, allow Symfony6 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 20324f6..58025e9 100644 --- a/composer.json +++ b/composer.json @@ -11,12 +11,12 @@ } ], "require": { - "php": "^7.1.3", + "php": "^8.1.0", "ext-dom": "*", - "symfony/expression-language": "~3.4|~4.0|~5.0" + "symfony/expression-language": "~3.4|~4.0|~5.0|~6.0" }, "require-dev": { - "phpunit/phpunit": "~6.5" + "phpunit/phpunit": "~10.0" }, "autoload": { "psr-4": { From 0cd496468fcc765022a8224ea97a402d08f33acc Mon Sep 17 00:00:00 2001 From: 77web Date: Sun, 21 May 2023 17:37:14 +0900 Subject: [PATCH 2/6] phpunit: added type declaration to setUp() method --- tests/Workflow/ProcessInstanceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Workflow/ProcessInstanceTest.php b/tests/Workflow/ProcessInstanceTest.php index 319f504..a1013fa 100644 --- a/tests/Workflow/ProcessInstanceTest.php +++ b/tests/Workflow/ProcessInstanceTest.php @@ -30,7 +30,7 @@ class ProcessInstanceTest extends TestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { $this->workflowRepository = new WorkflowRepository(); } From 757213f16661ceddb7527aa788a50ca14df30760 Mon Sep 17 00:00:00 2001 From: 77web Date: Sun, 21 May 2023 17:40:52 +0900 Subject: [PATCH 3/6] phpunit: made dataProvider methods to static --- tests/Workflow/ProcessInstanceTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Workflow/ProcessInstanceTest.php b/tests/Workflow/ProcessInstanceTest.php index a1013fa..1571f6d 100644 --- a/tests/Workflow/ProcessInstanceTest.php +++ b/tests/Workflow/ProcessInstanceTest.php @@ -153,7 +153,7 @@ public function completeWorkItem() /** * @return array */ - public function completeActivityOnConditionalSequenceFlowsData() + public static function completeActivityOnConditionalSequenceFlowsData() { return [ [true, null], @@ -196,7 +196,7 @@ public function completeActivityOnConditionalSequenceFlow($rejected, $nextFlowOb /** * @return array */ - public function selectSequenceFlowOnExclusiveGatewayData() + public static function selectSequenceFlowOnExclusiveGatewayData() { return [ [true, 'InformRejection'], From 86e44da11241d549531769c0a060071b0d4b6f94 Mon Sep 17 00:00:00 2001 From: 77web Date: Sun, 21 May 2023 17:41:51 +0900 Subject: [PATCH 4/6] phpunit: updated configuration schema --- phpunit.xml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index c9dd1dc..fdc1f96 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,19 +1,14 @@ - + + ./tests - - - + + ./src - - + + From 6847a507c6e5813b227c36d9cc6be73e5523ad3c Mon Sep 17 00:00:00 2001 From: 77web Date: Sun, 21 May 2023 17:48:07 +0900 Subject: [PATCH 5/6] phpunit: stopped using setMethods() --- tests/Workflow/ProcessInstanceTest.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/tests/Workflow/ProcessInstanceTest.php b/tests/Workflow/ProcessInstanceTest.php index 1571f6d..415138c 100644 --- a/tests/Workflow/ProcessInstanceTest.php +++ b/tests/Workflow/ProcessInstanceTest.php @@ -400,9 +400,7 @@ public function executeServiceTasks() { $participant = $this->createMock(ParticipantInterface::class); $participant->method('hasRole')->willReturn(true); - $operationRunner = $this->getMockBuilder(OperationRunnerInterface::class) - ->setMethods(['provideParticipant', 'run']) - ->getMock(); + $operationRunner = $this->createMock(OperationRunnerInterface::class); $operationRunner->method('provideParticipant')->willReturn($participant); $self = $this; $operationRunner->expects($this->exactly(2))->method('run')->willReturnCallback(function (WorkItemInterface $workItem) use ($self) { @@ -428,9 +426,7 @@ public function executeServiceTasks() */ public function provideDefaultRoleForWorkflowWithoutLanes() { - $participant = $this->getMockBuilder(ParticipantInterface::class) - ->setMethods(['hasRole', 'setResource', 'getResource', 'getName', 'getId']) - ->getMock(); + $participant = $this->createMock(ParticipantInterface::class); $participant->expects($this->exactly(3))->method('hasRole')->with($this->equalTo(ProcessInstance::DEFAULT_ROLE_ID))->willReturn(true); $workflow = $this->workflowRepository->findById('NoLanesProcess'); @@ -453,9 +449,7 @@ public function executeSendTasks() { $participant = $this->createMock(ParticipantInterface::class); $participant->method('hasRole')->willReturn(true); - $operationRunner = $this->getMockBuilder(OperationRunnerInterface::class) - ->setMethods(['provideParticipant', 'run']) - ->getMock(); + $operationRunner = $this->createMock(OperationRunnerInterface::class); $operationRunner->method('provideParticipant')->willReturn($participant); $self = $this; $operationRunner->expects($this->exactly(2))->method('run')->willReturnCallback(function (WorkItemInterface $workItem) use ($self) { @@ -723,9 +717,7 @@ public function executeParallelUserTasks() ['test' => 3], ['test' => 4], ]; - $dataProvider = $this->getMockBuilder(DataProviderInterface::class) - ->setMethods(['getParallelInstancesData', 'getSequentialInstanceData', 'getSingleInstanceData', 'mergeInstancesData']) - ->getMock(); + $dataProvider = $this->createMock(DataProviderInterface::class); $dataProvider->method('getParallelInstancesData')->willReturn($parallelData); $workflow = $this->workflowRepository->findById('ParallelUserTasks'); @@ -765,9 +757,7 @@ public function executeSequentialUserTasks() $participant->method('hasRole')->willReturn(true); $counter = 0; - $dataProvider = $this->getMockBuilder(DataProviderInterface::class) - ->setMethods(['getParallelInstancesData', 'getSequentialInstanceData', 'getSingleInstanceData', 'mergeInstancesData']) - ->getMock(); + $dataProvider = $this->createMock(DataProviderInterface::class); $dataProvider->method('getSequentialInstanceData')->willReturn(['test' => ++$counter]); $workflow = $this->workflowRepository->findById('SequentialUserTasks'); From 15a0444a6a5427c0fd7cb655165bb5c26888cdf3 Mon Sep 17 00:00:00 2001 From: 77web Date: Sun, 21 May 2023 17:49:35 +0900 Subject: [PATCH 6/6] phpunit: replaced contains() method usage to containsEqual() --- tests/Workflow/ProcessInstanceTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Workflow/ProcessInstanceTest.php b/tests/Workflow/ProcessInstanceTest.php index 415138c..0b5df00 100644 --- a/tests/Workflow/ProcessInstanceTest.php +++ b/tests/Workflow/ProcessInstanceTest.php @@ -489,7 +489,7 @@ public function parallelGateway() $this->assertThat(count($currentFlowObjects), $this->equalTo(count($concurrentFlowObjects))); foreach ($currentFlowObjects as $currentFlowObject) { - $this->assertThat($concurrentFlowObjects, $this->contains($currentFlowObject->getId())); + $this->assertThat($concurrentFlowObjects, $this->containsEqual($currentFlowObject->getId())); $this->assertThat(current($currentFlowObject->getToken())->getPreviousFlowObject()->getId(), $this->equalTo('ParallelGateway1')); unset($concurrentFlowObjects[array_search($currentFlowObject->getId(), $concurrentFlowObjects)]); @@ -518,11 +518,11 @@ public function parallelGateway() $concurrentFlowObjects = ['ReceivePayment', 'ShipOrder']; - $this->assertThat($concurrentFlowObjects, $this->contains($activityLog->get(0)->getActivity()->getId())); + $this->assertThat($concurrentFlowObjects, $this->containsEqual($activityLog->get(0)->getActivity()->getId())); unset($concurrentFlowObjects[array_search($activityLog->get(0)->getActivity()->getId(), $concurrentFlowObjects)]); - $this->assertThat($concurrentFlowObjects, $this->contains($activityLog->get(1)->getActivity()->getId())); + $this->assertThat($concurrentFlowObjects, $this->containsEqual($activityLog->get(1)->getActivity()->getId())); $this->assertThat($activityLog->get(2)->getActivity()->getId(), $this->equalTo('ArchiveOrder')); } @@ -918,11 +918,11 @@ public function inclusiveGateway() $concurrentFlowObjects = ['ReceiveOrder', 'ShipOrder']; - $this->assertThat($concurrentFlowObjects, $this->contains($activityLog->get(0)->getActivity()->getId())); + $this->assertThat($concurrentFlowObjects, $this->containsEqual($activityLog->get(0)->getActivity()->getId())); unset($concurrentFlowObjects[array_search($activityLog->get(0)->getActivity()->getId(), $concurrentFlowObjects)]); - $this->assertThat($concurrentFlowObjects, $this->contains($activityLog->get(1)->getActivity()->getId())); + $this->assertThat($concurrentFlowObjects, $this->containsEqual($activityLog->get(1)->getActivity()->getId())); $this->assertThat($activityLog->get(2)->getActivity()->getId(), $this->equalTo('ArchiveOrder')); } @@ -967,7 +967,7 @@ public function inclusiveGateway2() $concurrentFlowObjects = ['ShipOrder']; - $this->assertThat($concurrentFlowObjects, $this->contains($activityLog->get(0)->getActivity()->getId())); + $this->assertThat($concurrentFlowObjects, $this->containsEqual($activityLog->get(0)->getActivity()->getId())); $this->assertThat($activityLog->get(1)->getActivity()->getId(), $this->equalTo('ArchiveOrder')); }