From 9e154e7728bfd26a726bfd7f94b894f34e3edc58 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 26 Aug 2019 10:55:16 +0200 Subject: [PATCH] fix merge --- .../Fixture/TestAppKernel.php | 7 +++ .../LegacyEventDispatcherProxy.php | 2 + .../Form/Tests/ResolvedFormTypeTest.php | 1 + .../Handler/MigratingSessionHandler.php | 2 +- .../Storage/Handler/Fixtures/common.inc | 22 +++---- .../Tests/HttpKernelBrowserTest.php | 2 +- .../Component/HttpKernel/Tests/Logger.php | 5 +- .../Token/Storage/TokenStorage.php | 2 +- .../TraceableAccessDecisionManagerTest.php | 2 +- .../AbstractObjectNormalizerTest.php | 42 +++++++------ .../Serializer/Tests/SerializerTest.php | 43 +++++++------ .../Extractor/AbstractFileExtractor.php | 2 +- .../Tests/ConstraintViolationTest.php | 62 +++++++++++++++++++ .../Tests/Fixtures/CustomArrayObject.php | 8 +-- .../Validator/Tests/Fixtures/ToString.php | 2 +- .../Component/Workflow/Tests/WorkflowTest.php | 52 ++++++++-------- 16 files changed, 167 insertions(+), 89 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php index cf9ca2f7e5aa..a9bcd97613ab 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php @@ -36,6 +36,13 @@ public function registerContainerConfiguration(LoaderInterface $loader) $loader->load(__DIR__.\DIRECTORY_SEPARATOR.'config.yml'); } + public function setAnnotatedClassCache(array $annotatedClasses) + { + $annotatedClasses = array_diff($annotatedClasses, ['Symfony\Bundle\WebProfilerBundle\Controller\ExceptionController', 'Symfony\Bundle\TwigBundle\Controller\ExceptionController']); + + parent::setAnnotatedClassCache($annotatedClasses); + } + protected function build(ContainerBuilder $container) { $container->register('logger', NullLogger::class); diff --git a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php index afa3e988d005..be0d381a29be 100644 --- a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php +++ b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php @@ -50,6 +50,8 @@ public static function decorate(?ContractsEventDispatcherInterface $dispatcher): * {@inheritdoc} * * @param string|null $eventName + * + * @return object */ public function dispatch($event/*, string $eventName = null*/) { diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 210b6657aa14..7a238478bdcf 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Form; use Symfony\Component\Form\FormConfigInterface; use Symfony\Component\Form\FormTypeExtensionInterface; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php index 5293d2448a29..253d8cb68509 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php @@ -61,7 +61,7 @@ public function destroy($sessionId) } /** - * {@inheritdoc} + * @return bool */ public function gc($maxlifetime) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc index 7a064c7f3f06..a887f607e899 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/Fixtures/common.inc @@ -60,14 +60,14 @@ class TestSessionHandler extends AbstractSessionHandler $this->data = $data; } - public function open($path, $name) + public function open($path, $name): bool { echo __FUNCTION__, "\n"; return parent::open($path, $name); } - public function validateId($sessionId) + public function validateId($sessionId): bool { echo __FUNCTION__, "\n"; @@ -77,7 +77,7 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function read($sessionId) + public function read($sessionId): string { echo __FUNCTION__, "\n"; @@ -87,7 +87,7 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function updateTimestamp($sessionId, $data) + public function updateTimestamp($sessionId, $data): bool { echo __FUNCTION__, "\n"; @@ -97,7 +97,7 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function write($sessionId, $data) + public function write($sessionId, $data): bool { echo __FUNCTION__, "\n"; @@ -107,42 +107,42 @@ class TestSessionHandler extends AbstractSessionHandler /** * {@inheritdoc} */ - public function destroy($sessionId) + public function destroy($sessionId): bool { echo __FUNCTION__, "\n"; return parent::destroy($sessionId); } - public function close() + public function close(): bool { echo __FUNCTION__, "\n"; return true; } - public function gc($maxLifetime) + public function gc($maxLifetime): bool { echo __FUNCTION__, "\n"; return true; } - protected function doRead($sessionId) + protected function doRead($sessionId): string { echo __FUNCTION__.': ', $this->data, "\n"; return $this->data; } - protected function doWrite($sessionId, $data) + protected function doWrite($sessionId, $data): bool { echo __FUNCTION__.': ', $data, "\n"; return true; } - protected function doDestroy($sessionId) + protected function doDestroy($sessionId): bool { echo __FUNCTION__, "\n"; diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php index 37d471e81535..5a2faf4243df 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelBrowserTest.php @@ -160,7 +160,7 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() ; $file->expects($this->any()) ->method('getClientSize') - ->willReturn(INF) + ->willReturn(PHP_INT_MAX) ; $client->request('POST', '/', [], [$file]); diff --git a/src/Symfony/Component/HttpKernel/Tests/Logger.php b/src/Symfony/Component/HttpKernel/Tests/Logger.php index 47529a2d3485..8453cfbd5722 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Logger.php +++ b/src/Symfony/Component/HttpKernel/Tests/Logger.php @@ -22,10 +22,7 @@ public function __construct() $this->clear(); } - /** - * @return array - */ - public function getLogs($level = false) + public function getLogs($level = false): array { return false === $level ? $this->logs : $this->logs[$level]; } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php b/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php index 1b10bc219eb6..8a02802d9c98 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php @@ -39,7 +39,7 @@ public function getToken() */ public function setToken(TokenInterface $token = null) { - if (null !== $token && !method_exists($token, 'getRoleNames')) { + if (null !== $token && !method_exists($token, 'getRoleNames') && !$token instanceof \PHPUnit\Framework\MockObject\MockObject && !$token instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { @trigger_error(sprintf('Not implementing the "%s::getRoleNames()" method in "%s" is deprecated since Symfony 4.3.', TokenInterface::class, \get_class($token)), E_USER_DEPRECATED); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php index 5df07a22487b..f9e157c6978e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php @@ -233,7 +233,7 @@ public function testAccessDecisionManagerCalledByVoter() ->method('vote') ->willReturnCallback(function (TokenInterface $token, $subject, array $attributes) use ($sut, $voter3) { if (\in_array('attr2', $attributes) && $subject) { - $vote = $sut->decide($token, $attributes); + $vote = $sut->decide($token, $attributes) ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED; } else { $vote = VoterInterface::ACCESS_ABSTAIN; } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php index 9d15cac3b4cc..5070daa5550f 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -15,10 +15,12 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Exception\NotNormalizableValueException; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping; use Symfony\Component\Serializer\Mapping\ClassMetadata; +use Symfony\Component\Serializer\Mapping\ClassMetadataInterface; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; @@ -155,26 +157,28 @@ private function getDenormalizerForDummyCollection() public function testDenormalizeWithDiscriminatorMapUsesCorrectClassname() { $factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); - $loaderMock = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); - $loaderMock->method('hasMetadataFor')->willReturnMap([ - [ - AbstractDummy::class, - true, - ], - ]); - $loaderMock->method('getMetadataFor')->willReturnMap([ - [ - AbstractDummy::class, - new ClassMetadata( - AbstractDummy::class, - new ClassDiscriminatorMapping('type', [ - 'first' => AbstractDummyFirstChild::class, - 'second' => AbstractDummySecondChild::class, - ]) - ), - ], - ]); + $loaderMock = new class() implements ClassMetadataFactoryInterface { + public function getMetadataFor($value): ClassMetadataInterface + { + if (AbstractDummy::class === $value) { + return new ClassMetadata( + AbstractDummy::class, + new ClassDiscriminatorMapping('type', [ + 'first' => AbstractDummyFirstChild::class, + 'second' => AbstractDummySecondChild::class, + ]) + ); + } + + throw new InvalidArgumentException; + } + + public function hasMetadataFor($value): bool + { + return $value === AbstractDummy::class; + } + }; $discriminatorResolver = new ClassDiscriminatorFromClassMetadata($loaderMock); $normalizer = new AbstractObjectNormalizerDummy($factory, null, new PhpDocExtractor(), $discriminatorResolver); diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index 27e89e1f340b..2aa784bb8907 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -16,9 +16,11 @@ use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping; use Symfony\Component\Serializer\Mapping\ClassMetadata; +use Symfony\Component\Serializer\Mapping\ClassMetadataInterface; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; @@ -368,26 +370,27 @@ public function testDeserializeAndSerializeAbstractObjectsWithTheClassMetadataDi $example = new AbstractDummyFirstChild('foo-value', 'bar-value'); $example->setQuux(new DummyFirstChildQuux('quux')); - $loaderMock = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); - $loaderMock->method('hasMetadataFor')->willReturnMap([ - [ - AbstractDummy::class, - true, - ], - ]); - - $loaderMock->method('getMetadataFor')->willReturnMap([ - [ - AbstractDummy::class, - new ClassMetadata( - AbstractDummy::class, - new ClassDiscriminatorMapping('type', [ - 'first' => AbstractDummyFirstChild::class, - 'second' => AbstractDummySecondChild::class, - ]) - ), - ], - ]); + $loaderMock = new class() implements ClassMetadataFactoryInterface { + public function getMetadataFor($value): ClassMetadataInterface + { + if (AbstractDummy::class === $value) { + return new ClassMetadata( + AbstractDummy::class, + new ClassDiscriminatorMapping('type', [ + 'first' => AbstractDummyFirstChild::class, + 'second' => AbstractDummySecondChild::class, + ]) + ); + } + + throw new InvalidArgumentException(); + } + + public function hasMetadataFor($value): bool + { + return $value === AbstractDummy::class; + } + }; $discriminatorResolver = new ClassDiscriminatorFromClassMetadata($loaderMock); $serializer = new Serializer([new ObjectNormalizer(null, null, null, new PhpDocExtractor(), $discriminatorResolver)], ['json' => new JsonEncoder()]); diff --git a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php index d14ab1c99c40..c18b7b2e4fcd 100644 --- a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php @@ -27,7 +27,7 @@ abstract class AbstractFileExtractor */ protected function extractFiles($resource) { - if (\is_array($resource) || $resource instanceof \Traversable) { + if (\is_iterable($resource)) { $files = []; foreach ($resource as $file) { if ($this->canBeExtracted($file)) { diff --git a/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php b/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php index b43e51f27336..e3b57016ea3a 100644 --- a/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php +++ b/src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php @@ -108,4 +108,66 @@ public function testToStringOmitsEmptyCodes() $this->assertSame($expected, (string) $violation); } + + public function testMessageCanBeStringableObject() + { + $message = new ToString(); + $violation = new ConstraintViolation( + $message, + (string) $message, + [], + 'Root', + 'property.path', + null + ); + + $expected = <<<'EOF' +Root.property.path: + toString +EOF; + $this->assertSame($expected, (string) $violation); + $this->assertSame((string) $message, $violation->getMessage()); + } + + public function testMessageCannotBeArray() + { + $this->expectException(\TypeError::class); + $violation = new ConstraintViolation( + ['cannot be an array'], + '', + [], + 'Root', + 'property.path', + null + ); + } + + public function testMessageObjectMustBeStringable() + { + $this->expectException(\TypeError::class); + $violation = new ConstraintViolation( + new CustomArrayObject(), + '', + [], + 'Root', + 'property.path', + null + ); + } + + public function testNonStringCode() + { + $violation = new ConstraintViolation( + '42 cannot be used here', + 'this is the message template', + [], + ['some_value' => 42], + 'some_value', + null, + null, + 42 + ); + + self::assertSame(42, $violation->getCode()); + } } diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php b/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php index 9b5303c167c0..34b208b2bea0 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php @@ -24,7 +24,7 @@ public function __construct(array $array = null) $this->array = $array ?: []; } - public function offsetExists($offset) + public function offsetExists($offset): bool { return \array_key_exists($offset, $this->array); } @@ -48,12 +48,12 @@ public function offsetUnset($offset) unset($this->array[$offset]); } - public function getIterator() + public function getIterator(): \Traversable { return new \ArrayIterator($this->array); } - public function count() + public function count(): int { return \count($this->array); } @@ -63,7 +63,7 @@ public function __serialize(): array return $this->array; } - public function serialize() + public function serialize(): string { return serialize($this->__serialize()); } diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/ToString.php b/src/Symfony/Component/Validator/Tests/Fixtures/ToString.php index 714fdb9e98f5..2512066bafc8 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/ToString.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/ToString.php @@ -15,7 +15,7 @@ class ToString { public $data; - public function __toString() + public function __toString(): string { return 'toString'; } diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index 1cfb5fc5eb49..8514eea830e8 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -12,7 +12,6 @@ use Symfony\Component\Workflow\Marking; use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface; use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore; -use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore; use Symfony\Component\Workflow\Transition; use Symfony\Component\Workflow\TransitionBlocker; use Symfony\Component\Workflow\Workflow; @@ -21,6 +20,9 @@ class WorkflowTest extends TestCase { use WorkflowBuilderTrait; + /** + * @group legacy + */ public function testGetMarkingWithInvalidStoreReturn() { $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); @@ -36,7 +38,7 @@ public function testGetMarkingWithEmptyDefinition() $this->expectException('Symfony\Component\Workflow\Exception\LogicException'); $this->expectExceptionMessage('The Marking is empty and there is no initial place for workflow "unnamed".'); $subject = new Subject(); - $workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore()); + $workflow = new Workflow(new Definition([], []), new MethodMarkingStore()); $workflow->getMarking($subject); } @@ -47,7 +49,7 @@ public function testGetMarkingWithImpossiblePlace() $this->expectExceptionMessage('Place "nope" is not valid for workflow "unnamed".'); $subject = new Subject(); $subject->setMarking(['nope' => 1]); - $workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore()); + $workflow = new Workflow(new Definition([], []), new MethodMarkingStore()); $workflow->getMarking($subject); } @@ -56,7 +58,7 @@ public function testGetMarkingWithEmptyInitialMarking() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->getMarking($subject); @@ -70,7 +72,7 @@ public function testGetMarkingWithExistingMarking() $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); $subject->setMarking(['b' => 1, 'c' => 1]); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->getMarking($subject); @@ -83,7 +85,7 @@ public function testCanWithUnexistingTransition() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $this->assertFalse($workflow->can($subject, 'foobar')); } @@ -92,7 +94,7 @@ public function testCan() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $this->assertTrue($workflow->can($subject, 't1')); $this->assertFalse($workflow->can($subject, 't2')); @@ -123,7 +125,7 @@ public function testCanWithGuard() $eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) { $event->setBlocked(true); }); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $this->assertFalse($workflow->can($subject, 't1')); } @@ -136,7 +138,7 @@ public function testCanDoesNotTriggerGuardEventsForNotEnabledTransitions() $dispatchedEvents = []; $eventDispatcher = new EventDispatcher(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $workflow->apply($subject, 't1'); $workflow->apply($subject, 't2'); @@ -155,7 +157,7 @@ public function testCanDoesNotTriggerGuardEventsForNotEnabledTransitions() public function testCanWithSameNameTransition() { $definition = $this->createWorkflowWithSameNameTransition(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $subject = new Subject(); $this->assertTrue($workflow->can($subject, 'a_to_bc')); @@ -183,7 +185,7 @@ public function testBuildTransitionBlockerList() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $this->assertTrue($workflow->buildTransitionBlockerList($subject, 't1')->isEmpty()); $this->assertFalse($workflow->buildTransitionBlockerList($subject, 't2')->isEmpty()); @@ -208,7 +210,7 @@ public function testBuildTransitionBlockerListReturnsReasonsProvidedByMarking() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $transitionBlockerList = $workflow->buildTransitionBlockerList($subject, 't2'); $this->assertCount(1, $transitionBlockerList); @@ -222,7 +224,7 @@ public function testBuildTransitionBlockerListReturnsReasonsProvidedInGuards() $definition = $this->createSimpleWorkflowDefinition(); $subject = new Subject(); $dispatcher = new EventDispatcher(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher); + $workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher); $dispatcher->addListener('workflow.guard', function (GuardEvent $event) { $event->addTransitionBlocker(new TransitionBlocker('Transition blocker 1', 'blocker_1')); @@ -254,7 +256,7 @@ public function testApplyWithNotExisingTransition() $this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".'); $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $workflow->apply($subject, '404 Not Found'); } @@ -263,7 +265,7 @@ public function testApplyWithNotEnabledTransition() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); try { $workflow->apply($subject, 't2'); @@ -284,7 +286,7 @@ public function testApply() { $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->apply($subject, 't1'); @@ -298,7 +300,7 @@ public function testApplyWithSameNameTransition() { $subject = new Subject(); $definition = $this->createWorkflowWithSameNameTransition(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->apply($subject, 'a_to_bc'); @@ -336,7 +338,7 @@ public function testApplyWithSameNameTransition2() $transitions[] = new Transition('t', 'a', 'c'); $transitions[] = new Transition('t', 'b', 'd'); $definition = new Definition($places, $transitions); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->apply($subject, 't'); @@ -357,7 +359,7 @@ public function testApplyWithSameNameTransition3() $transitions[] = new Transition('t', 'b', 'c'); $transitions[] = new Transition('t', 'c', 'd'); $definition = new Definition($places, $transitions); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $marking = $workflow->apply($subject, 't'); // We want to make sure we do not end up in "d" @@ -370,7 +372,7 @@ public function testApplyWithEventDispatcher() $definition = $this->createComplexWorkflowDefinition(); $subject = new Subject(); $eventDispatcher = new EventDispatcherMock(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $eventNameExpected = [ 'workflow.entered', @@ -417,7 +419,7 @@ public function testApplyDoesNotTriggerExtraGuardWithEventDispatcher() $subject = new Subject(); $eventDispatcher = new EventDispatcherMock(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $eventNameExpected = [ 'workflow.entered', @@ -470,7 +472,7 @@ public function testEventName() $subject = new Subject(); $dispatcher = new EventDispatcher(); $name = 'workflow_name'; - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher, $name); + $workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher, $name); $assertWorkflowName = function (Event $event) use ($name) { $this->assertEquals($name, $event->getWorkflowName()); @@ -501,7 +503,7 @@ public function testMarkingStateOnApplyWithEventDispatcher() $dispatcher = new EventDispatcher(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher, 'test'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher, 'test'); $assertInitialState = function (Event $event) { $this->assertEquals(new Marking(['a' => 1, 'b' => 1, 'c' => 1]), $event->getMarking()); @@ -535,7 +537,7 @@ public function testGetEnabledTransitions() $eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) { $event->setBlocked(true); }); - $workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name'); + $workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name'); $this->assertEmpty($workflow->getEnabledTransitions($subject)); @@ -555,7 +557,7 @@ public function testGetEnabledTransitionsWithSameNameTransition() { $definition = $this->createWorkflowWithSameNameTransition(); $subject = new Subject(); - $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + $workflow = new Workflow($definition, new MethodMarkingStore()); $transitions = $workflow->getEnabledTransitions($subject); $this->assertCount(1, $transitions);