fix merge
This commit is contained in:
parent
74b2802197
commit
9e154e7728
|
@ -36,6 +36,13 @@ class TestAppKernel extends Kernel
|
|||
$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);
|
||||
|
|
|
@ -50,6 +50,8 @@ final class LegacyEventDispatcherProxy implements EventDispatcherInterface
|
|||
* {@inheritdoc}
|
||||
*
|
||||
* @param string|null $eventName
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function dispatch($event/*, string $eventName = null*/)
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Form\Tests;
|
|||
|
||||
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;
|
||||
|
|
|
@ -61,7 +61,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return bool
|
||||
*/
|
||||
public function gc($maxlifetime)
|
||||
{
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ class HttpKernelBrowserTest extends TestCase
|
|||
;
|
||||
$file->expects($this->any())
|
||||
->method('getClientSize')
|
||||
->willReturn(INF)
|
||||
->willReturn(PHP_INT_MAX)
|
||||
;
|
||||
|
||||
$client->request('POST', '/', [], [$file]);
|
||||
|
|
|
@ -22,10 +22,7 @@ class Logger implements LoggerInterface
|
|||
$this->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLogs($level = false)
|
||||
public function getLogs($level = false): array
|
||||
{
|
||||
return false === $level ? $this->logs : $this->logs[$level];
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class TokenStorage implements TokenStorageInterface, ResetInterface
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ class TraceableAccessDecisionManagerTest extends TestCase
|
|||
->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;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,12 @@ use Doctrine\Common\Annotations\AnnotationReader;
|
|||
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 @@ class AbstractObjectNormalizerTest extends TestCase
|
|||
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);
|
||||
|
|
|
@ -16,9 +16,11 @@ use PHPUnit\Framework\TestCase;
|
|||
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 @@ class SerializerTest extends TestCase
|
|||
$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 = 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,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
$loaderMock->method('getMetadataFor')->willReturnMap([
|
||||
[
|
||||
AbstractDummy::class,
|
||||
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()]);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -108,4 +108,66 @@ EOF;
|
|||
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
|
|||
$this->array = $array ?: [];
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return \array_key_exists($offset, $this->array);
|
||||
}
|
||||
|
@ -48,12 +48,12 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
|
|||
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 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
|
|||
return $this->array;
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
public function serialize(): string
|
||||
{
|
||||
return serialize($this->__serialize());
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class ToString
|
|||
{
|
||||
public $data;
|
||||
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'toString';
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ use Symfony\Component\Workflow\Exception\NotEnabledTransitionException;
|
|||
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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
{
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
{
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
{
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
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 @@ class WorkflowTest extends TestCase
|
|||
{
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
{
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
{
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
{
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
{
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
|
||||
$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 @@ class WorkflowTest extends TestCase
|
|||
$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 @@ class WorkflowTest extends TestCase
|
|||
{
|
||||
$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);
|
||||
|
|
Reference in New Issue