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');
|
$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)
|
protected function build(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$container->register('logger', NullLogger::class);
|
$container->register('logger', NullLogger::class);
|
||||||
|
|
|
@ -50,6 +50,8 @@ final class LegacyEventDispatcherProxy implements EventDispatcherInterface
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @param string|null $eventName
|
* @param string|null $eventName
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function dispatch($event/*, string $eventName = null*/)
|
public function dispatch($event/*, string $eventName = null*/)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Form\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
use Symfony\Component\Form\Form;
|
use Symfony\Component\Form\Form;
|
||||||
use Symfony\Component\Form\FormConfigInterface;
|
use Symfony\Component\Form\FormConfigInterface;
|
||||||
use Symfony\Component\Form\FormTypeExtensionInterface;
|
use Symfony\Component\Form\FormTypeExtensionInterface;
|
||||||
|
|
|
@ -61,7 +61,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function gc($maxlifetime)
|
public function gc($maxlifetime)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,14 +60,14 @@ class TestSessionHandler extends AbstractSessionHandler
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function open($path, $name)
|
public function open($path, $name): bool
|
||||||
{
|
{
|
||||||
echo __FUNCTION__, "\n";
|
echo __FUNCTION__, "\n";
|
||||||
|
|
||||||
return parent::open($path, $name);
|
return parent::open($path, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateId($sessionId)
|
public function validateId($sessionId): bool
|
||||||
{
|
{
|
||||||
echo __FUNCTION__, "\n";
|
echo __FUNCTION__, "\n";
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class TestSessionHandler extends AbstractSessionHandler
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function read($sessionId)
|
public function read($sessionId): string
|
||||||
{
|
{
|
||||||
echo __FUNCTION__, "\n";
|
echo __FUNCTION__, "\n";
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class TestSessionHandler extends AbstractSessionHandler
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function updateTimestamp($sessionId, $data)
|
public function updateTimestamp($sessionId, $data): bool
|
||||||
{
|
{
|
||||||
echo __FUNCTION__, "\n";
|
echo __FUNCTION__, "\n";
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class TestSessionHandler extends AbstractSessionHandler
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function write($sessionId, $data)
|
public function write($sessionId, $data): bool
|
||||||
{
|
{
|
||||||
echo __FUNCTION__, "\n";
|
echo __FUNCTION__, "\n";
|
||||||
|
|
||||||
|
@ -107,42 +107,42 @@ class TestSessionHandler extends AbstractSessionHandler
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function destroy($sessionId)
|
public function destroy($sessionId): bool
|
||||||
{
|
{
|
||||||
echo __FUNCTION__, "\n";
|
echo __FUNCTION__, "\n";
|
||||||
|
|
||||||
return parent::destroy($sessionId);
|
return parent::destroy($sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close()
|
public function close(): bool
|
||||||
{
|
{
|
||||||
echo __FUNCTION__, "\n";
|
echo __FUNCTION__, "\n";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function gc($maxLifetime)
|
public function gc($maxLifetime): bool
|
||||||
{
|
{
|
||||||
echo __FUNCTION__, "\n";
|
echo __FUNCTION__, "\n";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doRead($sessionId)
|
protected function doRead($sessionId): string
|
||||||
{
|
{
|
||||||
echo __FUNCTION__.': ', $this->data, "\n";
|
echo __FUNCTION__.': ', $this->data, "\n";
|
||||||
|
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doWrite($sessionId, $data)
|
protected function doWrite($sessionId, $data): bool
|
||||||
{
|
{
|
||||||
echo __FUNCTION__.': ', $data, "\n";
|
echo __FUNCTION__.': ', $data, "\n";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doDestroy($sessionId)
|
protected function doDestroy($sessionId): bool
|
||||||
{
|
{
|
||||||
echo __FUNCTION__, "\n";
|
echo __FUNCTION__, "\n";
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ class HttpKernelBrowserTest extends TestCase
|
||||||
;
|
;
|
||||||
$file->expects($this->any())
|
$file->expects($this->any())
|
||||||
->method('getClientSize')
|
->method('getClientSize')
|
||||||
->willReturn(INF)
|
->willReturn(PHP_INT_MAX)
|
||||||
;
|
;
|
||||||
|
|
||||||
$client->request('POST', '/', [], [$file]);
|
$client->request('POST', '/', [], [$file]);
|
||||||
|
|
|
@ -22,10 +22,7 @@ class Logger implements LoggerInterface
|
||||||
$this->clear();
|
$this->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getLogs($level = false): array
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getLogs($level = false)
|
|
||||||
{
|
{
|
||||||
return false === $level ? $this->logs : $this->logs[$level];
|
return false === $level ? $this->logs : $this->logs[$level];
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class TokenStorage implements TokenStorageInterface, ResetInterface
|
||||||
*/
|
*/
|
||||||
public function setToken(TokenInterface $token = null)
|
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);
|
@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')
|
->method('vote')
|
||||||
->willReturnCallback(function (TokenInterface $token, $subject, array $attributes) use ($sut, $voter3) {
|
->willReturnCallback(function (TokenInterface $token, $subject, array $attributes) use ($sut, $voter3) {
|
||||||
if (\in_array('attr2', $attributes) && $subject) {
|
if (\in_array('attr2', $attributes) && $subject) {
|
||||||
$vote = $sut->decide($token, $attributes);
|
$vote = $sut->decide($token, $attributes) ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
|
||||||
} else {
|
} else {
|
||||||
$vote = VoterInterface::ACCESS_ABSTAIN;
|
$vote = VoterInterface::ACCESS_ABSTAIN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,12 @@ use Doctrine\Common\Annotations\AnnotationReader;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
|
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
|
||||||
use Symfony\Component\PropertyInfo\Type;
|
use Symfony\Component\PropertyInfo\Type;
|
||||||
|
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
|
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
|
||||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
|
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
|
||||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
|
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
|
||||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
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\ClassMetadataFactory;
|
||||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||||
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
||||||
|
@ -155,26 +157,28 @@ class AbstractObjectNormalizerTest extends TestCase
|
||||||
public function testDenormalizeWithDiscriminatorMapUsesCorrectClassname()
|
public function testDenormalizeWithDiscriminatorMapUsesCorrectClassname()
|
||||||
{
|
{
|
||||||
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
|
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
|
||||||
$loaderMock = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
|
|
||||||
$loaderMock->method('hasMetadataFor')->willReturnMap([
|
|
||||||
[
|
|
||||||
AbstractDummy::class,
|
|
||||||
true,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$loaderMock->method('getMetadataFor')->willReturnMap([
|
$loaderMock = new class() implements ClassMetadataFactoryInterface {
|
||||||
[
|
public function getMetadataFor($value): ClassMetadataInterface
|
||||||
AbstractDummy::class,
|
{
|
||||||
new ClassMetadata(
|
if (AbstractDummy::class === $value) {
|
||||||
AbstractDummy::class,
|
return new ClassMetadata(
|
||||||
new ClassDiscriminatorMapping('type', [
|
AbstractDummy::class,
|
||||||
'first' => AbstractDummyFirstChild::class,
|
new ClassDiscriminatorMapping('type', [
|
||||||
'second' => AbstractDummySecondChild::class,
|
'first' => AbstractDummyFirstChild::class,
|
||||||
])
|
'second' => AbstractDummySecondChild::class,
|
||||||
),
|
])
|
||||||
],
|
);
|
||||||
]);
|
}
|
||||||
|
|
||||||
|
throw new InvalidArgumentException;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasMetadataFor($value): bool
|
||||||
|
{
|
||||||
|
return $value === AbstractDummy::class;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$discriminatorResolver = new ClassDiscriminatorFromClassMetadata($loaderMock);
|
$discriminatorResolver = new ClassDiscriminatorFromClassMetadata($loaderMock);
|
||||||
$normalizer = new AbstractObjectNormalizerDummy($factory, null, new PhpDocExtractor(), $discriminatorResolver);
|
$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\PhpDocExtractor;
|
||||||
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
|
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
|
||||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||||
|
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
|
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
|
||||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
|
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
|
||||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
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\ClassMetadataFactory;
|
||||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||||
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
||||||
|
@ -368,26 +370,27 @@ class SerializerTest extends TestCase
|
||||||
$example = new AbstractDummyFirstChild('foo-value', 'bar-value');
|
$example = new AbstractDummyFirstChild('foo-value', 'bar-value');
|
||||||
$example->setQuux(new DummyFirstChildQuux('quux'));
|
$example->setQuux(new DummyFirstChildQuux('quux'));
|
||||||
|
|
||||||
$loaderMock = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
|
$loaderMock = new class() implements ClassMetadataFactoryInterface {
|
||||||
$loaderMock->method('hasMetadataFor')->willReturnMap([
|
public function getMetadataFor($value): ClassMetadataInterface
|
||||||
[
|
{
|
||||||
AbstractDummy::class,
|
if (AbstractDummy::class === $value) {
|
||||||
true,
|
return new ClassMetadata(
|
||||||
],
|
AbstractDummy::class,
|
||||||
]);
|
new ClassDiscriminatorMapping('type', [
|
||||||
|
'first' => AbstractDummyFirstChild::class,
|
||||||
|
'second' => AbstractDummySecondChild::class,
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$loaderMock->method('getMetadataFor')->willReturnMap([
|
throw new InvalidArgumentException();
|
||||||
[
|
}
|
||||||
AbstractDummy::class,
|
|
||||||
new ClassMetadata(
|
public function hasMetadataFor($value): bool
|
||||||
AbstractDummy::class,
|
{
|
||||||
new ClassDiscriminatorMapping('type', [
|
return $value === AbstractDummy::class;
|
||||||
'first' => AbstractDummyFirstChild::class,
|
}
|
||||||
'second' => AbstractDummySecondChild::class,
|
};
|
||||||
])
|
|
||||||
),
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$discriminatorResolver = new ClassDiscriminatorFromClassMetadata($loaderMock);
|
$discriminatorResolver = new ClassDiscriminatorFromClassMetadata($loaderMock);
|
||||||
$serializer = new Serializer([new ObjectNormalizer(null, null, null, new PhpDocExtractor(), $discriminatorResolver)], ['json' => new JsonEncoder()]);
|
$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)
|
protected function extractFiles($resource)
|
||||||
{
|
{
|
||||||
if (\is_array($resource) || $resource instanceof \Traversable) {
|
if (\is_iterable($resource)) {
|
||||||
$files = [];
|
$files = [];
|
||||||
foreach ($resource as $file) {
|
foreach ($resource as $file) {
|
||||||
if ($this->canBeExtracted($file)) {
|
if ($this->canBeExtracted($file)) {
|
||||||
|
|
|
@ -108,4 +108,66 @@ EOF;
|
||||||
|
|
||||||
$this->assertSame($expected, (string) $violation);
|
$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 ?: [];
|
$this->array = $array ?: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function offsetExists($offset)
|
public function offsetExists($offset): bool
|
||||||
{
|
{
|
||||||
return \array_key_exists($offset, $this->array);
|
return \array_key_exists($offset, $this->array);
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
|
||||||
unset($this->array[$offset]);
|
unset($this->array[$offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIterator()
|
public function getIterator(): \Traversable
|
||||||
{
|
{
|
||||||
return new \ArrayIterator($this->array);
|
return new \ArrayIterator($this->array);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function count()
|
public function count(): int
|
||||||
{
|
{
|
||||||
return \count($this->array);
|
return \count($this->array);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
|
||||||
return $this->array;
|
return $this->array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serialize()
|
public function serialize(): string
|
||||||
{
|
{
|
||||||
return serialize($this->__serialize());
|
return serialize($this->__serialize());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ class ToString
|
||||||
{
|
{
|
||||||
public $data;
|
public $data;
|
||||||
|
|
||||||
public function __toString()
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return 'toString';
|
return 'toString';
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ use Symfony\Component\Workflow\Exception\NotEnabledTransitionException;
|
||||||
use Symfony\Component\Workflow\Marking;
|
use Symfony\Component\Workflow\Marking;
|
||||||
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;
|
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;
|
||||||
use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore;
|
use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore;
|
||||||
use Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore;
|
|
||||||
use Symfony\Component\Workflow\Transition;
|
use Symfony\Component\Workflow\Transition;
|
||||||
use Symfony\Component\Workflow\TransitionBlocker;
|
use Symfony\Component\Workflow\TransitionBlocker;
|
||||||
use Symfony\Component\Workflow\Workflow;
|
use Symfony\Component\Workflow\Workflow;
|
||||||
|
@ -21,6 +20,9 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
use WorkflowBuilderTrait;
|
use WorkflowBuilderTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testGetMarkingWithInvalidStoreReturn()
|
public function testGetMarkingWithInvalidStoreReturn()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\Workflow\Exception\LogicException');
|
$this->expectException('Symfony\Component\Workflow\Exception\LogicException');
|
||||||
|
@ -36,7 +38,7 @@ class WorkflowTest extends TestCase
|
||||||
$this->expectException('Symfony\Component\Workflow\Exception\LogicException');
|
$this->expectException('Symfony\Component\Workflow\Exception\LogicException');
|
||||||
$this->expectExceptionMessage('The Marking is empty and there is no initial place for workflow "unnamed".');
|
$this->expectExceptionMessage('The Marking is empty and there is no initial place for workflow "unnamed".');
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore());
|
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
|
||||||
|
|
||||||
$workflow->getMarking($subject);
|
$workflow->getMarking($subject);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +49,7 @@ class WorkflowTest extends TestCase
|
||||||
$this->expectExceptionMessage('Place "nope" is not valid for workflow "unnamed".');
|
$this->expectExceptionMessage('Place "nope" is not valid for workflow "unnamed".');
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$subject->setMarking(['nope' => 1]);
|
$subject->setMarking(['nope' => 1]);
|
||||||
$workflow = new Workflow(new Definition([], []), new MultipleStateMarkingStore());
|
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
|
||||||
|
|
||||||
$workflow->getMarking($subject);
|
$workflow->getMarking($subject);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +58,7 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$marking = $workflow->getMarking($subject);
|
$marking = $workflow->getMarking($subject);
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ class WorkflowTest extends TestCase
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$subject->setMarking(['b' => 1, 'c' => 1]);
|
$subject->setMarking(['b' => 1, 'c' => 1]);
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$marking = $workflow->getMarking($subject);
|
$marking = $workflow->getMarking($subject);
|
||||||
|
|
||||||
|
@ -83,7 +85,7 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$this->assertFalse($workflow->can($subject, 'foobar'));
|
$this->assertFalse($workflow->can($subject, 'foobar'));
|
||||||
}
|
}
|
||||||
|
@ -92,7 +94,7 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$this->assertTrue($workflow->can($subject, 't1'));
|
$this->assertTrue($workflow->can($subject, 't1'));
|
||||||
$this->assertFalse($workflow->can($subject, 't2'));
|
$this->assertFalse($workflow->can($subject, 't2'));
|
||||||
|
@ -123,7 +125,7 @@ class WorkflowTest extends TestCase
|
||||||
$eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) {
|
$eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) {
|
||||||
$event->setBlocked(true);
|
$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'));
|
$this->assertFalse($workflow->can($subject, 't1'));
|
||||||
}
|
}
|
||||||
|
@ -136,7 +138,7 @@ class WorkflowTest extends TestCase
|
||||||
$dispatchedEvents = [];
|
$dispatchedEvents = [];
|
||||||
$eventDispatcher = new EventDispatcher();
|
$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, 't1');
|
||||||
$workflow->apply($subject, 't2');
|
$workflow->apply($subject, 't2');
|
||||||
|
|
||||||
|
@ -155,7 +157,7 @@ class WorkflowTest extends TestCase
|
||||||
public function testCanWithSameNameTransition()
|
public function testCanWithSameNameTransition()
|
||||||
{
|
{
|
||||||
$definition = $this->createWorkflowWithSameNameTransition();
|
$definition = $this->createWorkflowWithSameNameTransition();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$this->assertTrue($workflow->can($subject, 'a_to_bc'));
|
$this->assertTrue($workflow->can($subject, 'a_to_bc'));
|
||||||
|
@ -183,7 +185,7 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$this->assertTrue($workflow->buildTransitionBlockerList($subject, 't1')->isEmpty());
|
$this->assertTrue($workflow->buildTransitionBlockerList($subject, 't1')->isEmpty());
|
||||||
$this->assertFalse($workflow->buildTransitionBlockerList($subject, 't2')->isEmpty());
|
$this->assertFalse($workflow->buildTransitionBlockerList($subject, 't2')->isEmpty());
|
||||||
|
@ -208,7 +210,7 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$transitionBlockerList = $workflow->buildTransitionBlockerList($subject, 't2');
|
$transitionBlockerList = $workflow->buildTransitionBlockerList($subject, 't2');
|
||||||
$this->assertCount(1, $transitionBlockerList);
|
$this->assertCount(1, $transitionBlockerList);
|
||||||
|
@ -222,7 +224,7 @@ class WorkflowTest extends TestCase
|
||||||
$definition = $this->createSimpleWorkflowDefinition();
|
$definition = $this->createSimpleWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$dispatcher = new EventDispatcher();
|
$dispatcher = new EventDispatcher();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher);
|
$workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher);
|
||||||
|
|
||||||
$dispatcher->addListener('workflow.guard', function (GuardEvent $event) {
|
$dispatcher->addListener('workflow.guard', function (GuardEvent $event) {
|
||||||
$event->addTransitionBlocker(new TransitionBlocker('Transition blocker 1', 'blocker_1'));
|
$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".');
|
$this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".');
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$workflow->apply($subject, '404 Not Found');
|
$workflow->apply($subject, '404 Not Found');
|
||||||
}
|
}
|
||||||
|
@ -263,7 +265,7 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$workflow->apply($subject, 't2');
|
$workflow->apply($subject, 't2');
|
||||||
|
@ -284,7 +286,7 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$marking = $workflow->apply($subject, 't1');
|
$marking = $workflow->apply($subject, 't1');
|
||||||
|
|
||||||
|
@ -298,7 +300,7 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$definition = $this->createWorkflowWithSameNameTransition();
|
$definition = $this->createWorkflowWithSameNameTransition();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$marking = $workflow->apply($subject, 'a_to_bc');
|
$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', 'a', 'c');
|
||||||
$transitions[] = new Transition('t', 'b', 'd');
|
$transitions[] = new Transition('t', 'b', 'd');
|
||||||
$definition = new Definition($places, $transitions);
|
$definition = new Definition($places, $transitions);
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$marking = $workflow->apply($subject, 't');
|
$marking = $workflow->apply($subject, 't');
|
||||||
|
|
||||||
|
@ -357,7 +359,7 @@ class WorkflowTest extends TestCase
|
||||||
$transitions[] = new Transition('t', 'b', 'c');
|
$transitions[] = new Transition('t', 'b', 'c');
|
||||||
$transitions[] = new Transition('t', 'c', 'd');
|
$transitions[] = new Transition('t', 'c', 'd');
|
||||||
$definition = new Definition($places, $transitions);
|
$definition = new Definition($places, $transitions);
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$marking = $workflow->apply($subject, 't');
|
$marking = $workflow->apply($subject, 't');
|
||||||
// We want to make sure we do not end up in "d"
|
// We want to make sure we do not end up in "d"
|
||||||
|
@ -370,7 +372,7 @@ class WorkflowTest extends TestCase
|
||||||
$definition = $this->createComplexWorkflowDefinition();
|
$definition = $this->createComplexWorkflowDefinition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$eventDispatcher = new EventDispatcherMock();
|
$eventDispatcher = new EventDispatcherMock();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
|
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
|
||||||
|
|
||||||
$eventNameExpected = [
|
$eventNameExpected = [
|
||||||
'workflow.entered',
|
'workflow.entered',
|
||||||
|
@ -417,7 +419,7 @@ class WorkflowTest extends TestCase
|
||||||
|
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$eventDispatcher = new EventDispatcherMock();
|
$eventDispatcher = new EventDispatcherMock();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $eventDispatcher, 'workflow_name');
|
$workflow = new Workflow($definition, new MethodMarkingStore(), $eventDispatcher, 'workflow_name');
|
||||||
|
|
||||||
$eventNameExpected = [
|
$eventNameExpected = [
|
||||||
'workflow.entered',
|
'workflow.entered',
|
||||||
|
@ -470,7 +472,7 @@ class WorkflowTest extends TestCase
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$dispatcher = new EventDispatcher();
|
$dispatcher = new EventDispatcher();
|
||||||
$name = 'workflow_name';
|
$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) {
|
$assertWorkflowName = function (Event $event) use ($name) {
|
||||||
$this->assertEquals($name, $event->getWorkflowName());
|
$this->assertEquals($name, $event->getWorkflowName());
|
||||||
|
@ -501,7 +503,7 @@ class WorkflowTest extends TestCase
|
||||||
|
|
||||||
$dispatcher = new EventDispatcher();
|
$dispatcher = new EventDispatcher();
|
||||||
|
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore(), $dispatcher, 'test');
|
$workflow = new Workflow($definition, new MethodMarkingStore(), $dispatcher, 'test');
|
||||||
|
|
||||||
$assertInitialState = function (Event $event) {
|
$assertInitialState = function (Event $event) {
|
||||||
$this->assertEquals(new Marking(['a' => 1, 'b' => 1, 'c' => 1]), $event->getMarking());
|
$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) {
|
$eventDispatcher->addListener('workflow.workflow_name.guard.t1', function (GuardEvent $event) {
|
||||||
$event->setBlocked(true);
|
$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));
|
$this->assertEmpty($workflow->getEnabledTransitions($subject));
|
||||||
|
|
||||||
|
@ -555,7 +557,7 @@ class WorkflowTest extends TestCase
|
||||||
{
|
{
|
||||||
$definition = $this->createWorkflowWithSameNameTransition();
|
$definition = $this->createWorkflowWithSameNameTransition();
|
||||||
$subject = new Subject();
|
$subject = new Subject();
|
||||||
$workflow = new Workflow($definition, new MultipleStateMarkingStore());
|
$workflow = new Workflow($definition, new MethodMarkingStore());
|
||||||
|
|
||||||
$transitions = $workflow->getEnabledTransitions($subject);
|
$transitions = $workflow->getEnabledTransitions($subject);
|
||||||
$this->assertCount(1, $transitions);
|
$this->assertCount(1, $transitions);
|
||||||
|
|
Reference in New Issue