[FrameworkBundle][Workflow] Remove BC layers and deprecated codes
This commit is contained in:
parent
08dc494294
commit
cbb8b22753
@ -256,15 +256,6 @@ class Configuration implements ConfigurationInterface
|
||||
->arrayNode('workflows')
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('array')
|
||||
->beforeNormalization()
|
||||
->always(function ($v) {
|
||||
if (isset($v['initial_place'])) {
|
||||
$v['initial_marking'] = [$v['initial_place']];
|
||||
}
|
||||
|
||||
return $v;
|
||||
})
|
||||
->end()
|
||||
->fixXmlConfig('support')
|
||||
->fixXmlConfig('place')
|
||||
->fixXmlConfig('transition')
|
||||
@ -277,28 +268,9 @@ class Configuration implements ConfigurationInterface
|
||||
->defaultValue('state_machine')
|
||||
->end()
|
||||
->arrayNode('marking_store')
|
||||
->fixXmlConfig('argument')
|
||||
->children()
|
||||
->enumNode('type')
|
||||
->values(['multiple_state', 'single_state', 'method'])
|
||||
->validate()
|
||||
->ifTrue(function ($v) { return 'method' !== $v; })
|
||||
->then(function ($v) {
|
||||
@trigger_error('Passing something else than "method" has been deprecated in Symfony 4.3.', E_USER_DEPRECATED);
|
||||
|
||||
return $v;
|
||||
})
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('arguments')
|
||||
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3. Use "property" instead.')
|
||||
->beforeNormalization()
|
||||
->ifString()
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->requiresAtLeastOneElement()
|
||||
->prototype('scalar')
|
||||
->end()
|
||||
->values(['method'])
|
||||
->end()
|
||||
->scalarNode('property')
|
||||
->defaultValue('marking')
|
||||
@ -307,14 +279,6 @@ class Configuration implements ConfigurationInterface
|
||||
->cannotBeEmpty()
|
||||
->end()
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function ($v) { return isset($v['type']) && isset($v['service']); })
|
||||
->thenInvalid('"type" and "service" cannot be used together.')
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function ($v) { return !empty($v['arguments']) && isset($v['service']); })
|
||||
->thenInvalid('"arguments" and "service" cannot be used together.')
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('supports')
|
||||
->beforeNormalization()
|
||||
@ -332,10 +296,6 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('support_strategy')
|
||||
->cannotBeEmpty()
|
||||
->end()
|
||||
->scalarNode('initial_place')
|
||||
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_marking" configuration key instead.')
|
||||
->defaultNull()
|
||||
->end()
|
||||
->arrayNode('initial_marking')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !\is_array($v); })
|
||||
@ -472,16 +432,6 @@ class Configuration implements ConfigurationInterface
|
||||
})
|
||||
->thenInvalid('"supports" or "support_strategy" should be configured.')
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function ($v) {
|
||||
return 'workflow' === $v['type'] && 'single_state' === ($v['marking_store']['type'] ?? false);
|
||||
})
|
||||
->then(function ($v) {
|
||||
@trigger_error('Using a workflow with type=workflow and a marking_store=single_state is deprecated since Symfony 4.3. Use type=state_machine instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $v;
|
||||
})
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -627,7 +627,7 @@ class FrameworkExtension extends Extension
|
||||
|
||||
// Create places
|
||||
$places = array_column($workflow['places'], 'name');
|
||||
$initialMarking = $workflow['initial_marking'] ?? $workflow['initial_place'] ?? [];
|
||||
$initialMarking = $workflow['initial_marking'] ?? [];
|
||||
|
||||
// Create a Definition
|
||||
$definitionDefinition = new Definition(Workflow\Definition::class);
|
||||
@ -639,17 +639,11 @@ class FrameworkExtension extends Extension
|
||||
|
||||
// Create MarkingStore
|
||||
if (isset($workflow['marking_store']['type'])) {
|
||||
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.'.$workflow['marking_store']['type']);
|
||||
if ('method' === $workflow['marking_store']['type']) {
|
||||
$markingStoreDefinition->setArguments([
|
||||
'state_machine' === $type, //single state
|
||||
$workflow['marking_store']['property'],
|
||||
]);
|
||||
} else {
|
||||
foreach ($workflow['marking_store']['arguments'] as $argument) {
|
||||
$markingStoreDefinition->addArgument($argument);
|
||||
}
|
||||
}
|
||||
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.method');
|
||||
$markingStoreDefinition->setArguments([
|
||||
'state_machine' === $type, //single state
|
||||
$workflow['marking_store']['property'],
|
||||
]);
|
||||
} elseif (isset($workflow['marking_store']['service'])) {
|
||||
$markingStoreDefinition = new Reference($workflow['marking_store']['service']);
|
||||
}
|
||||
@ -668,29 +662,19 @@ class FrameworkExtension extends Extension
|
||||
$container->registerAliasForArgument($workflowId, WorkflowInterface::class, $name.'.'.$type);
|
||||
|
||||
// Validate Workflow
|
||||
$validator = null;
|
||||
switch (true) {
|
||||
case 'state_machine' === $workflow['type']:
|
||||
$validator = new Workflow\Validator\StateMachineValidator();
|
||||
break;
|
||||
case 'single_state' === ($workflow['marking_store']['type'] ?? null):
|
||||
$validator = new Workflow\Validator\WorkflowValidator(true);
|
||||
break;
|
||||
case 'multiple_state' === ($workflow['marking_store']['type'] ?? false):
|
||||
$validator = new Workflow\Validator\WorkflowValidator(false);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($validator) {
|
||||
$realDefinition = (new Workflow\DefinitionBuilder($places))
|
||||
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
|
||||
return $container->get((string) $ref);
|
||||
}, $transitions))
|
||||
->setInitialPlace($initialMarking)
|
||||
->build()
|
||||
;
|
||||
$validator->validate($realDefinition, $name);
|
||||
$realDefinition = (new Workflow\DefinitionBuilder($places))
|
||||
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
|
||||
return $container->get((string) $ref);
|
||||
}, $transitions))
|
||||
->setInitialPlace($initialMarking)
|
||||
->build()
|
||||
;
|
||||
if ('state_machine' === $workflow['type']) {
|
||||
$validator = new Workflow\Validator\StateMachineValidator();
|
||||
} else {
|
||||
$validator = new Workflow\Validator\WorkflowValidator();
|
||||
}
|
||||
$validator->validate($realDefinition, $name);
|
||||
|
||||
// Add workflow to Registry
|
||||
if ($workflow['supports']) {
|
||||
|
@ -20,8 +20,6 @@
|
||||
<argument /> <!-- name -->
|
||||
</service>
|
||||
|
||||
<service id="workflow.marking_store.multiple_state" class="Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore" abstract="true" />
|
||||
<service id="workflow.marking_store.single_state" class="Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore" abstract="true" />
|
||||
<service id="workflow.marking_store.method" class="Symfony\Component\Workflow\MarkingStore\MethodMarkingStore" abstract="true" />
|
||||
|
||||
<service id="workflow.registry" class="Symfony\Component\Workflow\Registry" />
|
||||
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'legacy' => [
|
||||
'type' => 'state_machine',
|
||||
'marking_store' => [
|
||||
'type' => 'single_state',
|
||||
'arguments' => [
|
||||
'state',
|
||||
],
|
||||
],
|
||||
'supports' => [
|
||||
stdClass::class,
|
||||
],
|
||||
'initial_place' => 'draft',
|
||||
'places' => [
|
||||
'draft',
|
||||
'published',
|
||||
],
|
||||
'transitions' => [
|
||||
'publish' => [
|
||||
'from' => 'draft',
|
||||
'to' => 'published',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'my_workflow' => [
|
||||
'marking_store' => [
|
||||
'arguments' => ['a', 'b'],
|
||||
'service' => 'workflow_service',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'places' => [
|
||||
'first',
|
||||
'last',
|
||||
],
|
||||
'transitions' => [
|
||||
'go' => [
|
||||
'from' => [
|
||||
'first',
|
||||
],
|
||||
'to' => [
|
||||
'last',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'my_workflow' => [
|
||||
'marking_store' => [
|
||||
'type' => 'method',
|
||||
'service' => 'workflow_service',
|
||||
],
|
||||
'supports' => [
|
||||
FrameworkExtensionTest::class,
|
||||
],
|
||||
'places' => [
|
||||
'first',
|
||||
'last',
|
||||
],
|
||||
'transitions' => [
|
||||
'go' => [
|
||||
'from' => [
|
||||
'first',
|
||||
],
|
||||
'to' => [
|
||||
'last',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
@ -10,8 +10,8 @@ $container->loadFromExtension('framework', [
|
||||
'places' => ['bar', 'baz'],
|
||||
'transitions' => [
|
||||
'bar_baz' => [
|
||||
'from' => ['foo'],
|
||||
'to' => ['bar'],
|
||||
'from' => ['bar'],
|
||||
'to' => ['baz'],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@ -10,8 +10,8 @@ $container->loadFromExtension('framework', [
|
||||
'places' => ['bar', 'baz'],
|
||||
'transitions' => [
|
||||
'bar_baz' => [
|
||||
'from' => ['foo'],
|
||||
'to' => ['bar'],
|
||||
'from' => ['bar'],
|
||||
'to' => ['baz'],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:workflow name="legacy" type="state_machine" initial-place="draft">
|
||||
<framework:marking-store type="single_state">
|
||||
<framework:argument>state</framework:argument>
|
||||
</framework:marking-store>
|
||||
<framework:support>stdClass</framework:support>
|
||||
<framework:place name="draft" />
|
||||
<framework:place name="published" />
|
||||
<framework:transition name="publish">
|
||||
<framework:from>draft</framework:from>
|
||||
<framework:to>published</framework:to>
|
||||
</framework:transition>
|
||||
</framework:workflow>
|
||||
</framework:config>
|
||||
</container>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:workflow name="my_workflow">
|
||||
<framework:marking-store service="workflow_service">
|
||||
<framework:argument>a</framework:argument>
|
||||
<framework:argument>a</framework:argument>
|
||||
</framework:marking-store>
|
||||
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
|
||||
<framework:place name="first" />
|
||||
<framework:place name="last" />
|
||||
<framework:transition name="foobar">
|
||||
<framework:from>a</framework:from>
|
||||
<framework:to>a</framework:to>
|
||||
</framework:transition>
|
||||
</framework:workflow>
|
||||
</framework:config>
|
||||
</container>
|
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:workflow name="my_workflow">
|
||||
<framework:marking-store type="method" service="workflow_service" />
|
||||
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
|
||||
<framework:place name="first" />
|
||||
<framework:place name="last" />
|
||||
<framework:transition name="foobar">
|
||||
<framework:from>a</framework:from>
|
||||
<framework:to>a</framework:to>
|
||||
</framework:transition>
|
||||
</framework:workflow>
|
||||
</framework:config>
|
||||
</container>
|
@ -6,7 +6,7 @@
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:workflow enabled="true" name="foo" type="workflow" initial-marking="start">
|
||||
<framework:workflow enabled="true" name="foo" type="workflow" initial-marking="bar">
|
||||
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
|
||||
<framework:place>bar</framework:place>
|
||||
<framework:place>baz</framework:place>
|
||||
|
@ -1,18 +0,0 @@
|
||||
framework:
|
||||
workflows:
|
||||
legacy:
|
||||
type: state_machine
|
||||
marking_store:
|
||||
type: single_state
|
||||
arguments:
|
||||
- state
|
||||
initial_place: draft
|
||||
supports:
|
||||
- stdClass
|
||||
places:
|
||||
- draft
|
||||
- published
|
||||
transitions:
|
||||
publish:
|
||||
from: draft
|
||||
to: published
|
@ -1,19 +0,0 @@
|
||||
framework:
|
||||
workflows:
|
||||
my_workflow:
|
||||
marking_store:
|
||||
arguments:
|
||||
- a
|
||||
- b
|
||||
service: workflow_service
|
||||
supports:
|
||||
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
|
||||
places:
|
||||
- first
|
||||
- last
|
||||
transitions:
|
||||
go:
|
||||
from:
|
||||
- first
|
||||
to:
|
||||
- last
|
@ -1,17 +0,0 @@
|
||||
framework:
|
||||
workflows:
|
||||
my_workflow:
|
||||
marking_store:
|
||||
type: method
|
||||
service: workflow_service
|
||||
supports:
|
||||
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
|
||||
places:
|
||||
- first
|
||||
- last
|
||||
transitions:
|
||||
go:
|
||||
from:
|
||||
- first
|
||||
to:
|
||||
- last
|
@ -12,5 +12,5 @@ framework:
|
||||
- baz
|
||||
transitions:
|
||||
bar_baz:
|
||||
from: [foo]
|
||||
from: [bar]
|
||||
to: [bar]
|
||||
|
@ -11,5 +11,5 @@ framework:
|
||||
- baz
|
||||
transitions:
|
||||
bar_baz:
|
||||
from: [foo]
|
||||
to: [bar]
|
||||
from: [bar]
|
||||
to: [baz]
|
||||
|
@ -278,31 +278,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertGreaterThan(0, \count($registryDefinition->getMethodCalls()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testWorkflowLegacy()
|
||||
{
|
||||
$container = $this->createContainerFromFile('workflow-legacy');
|
||||
|
||||
$this->assertTrue($container->hasDefinition('state_machine.legacy'), 'Workflow is registered as a service');
|
||||
$this->assertSame('state_machine.abstract', $container->getDefinition('state_machine.legacy')->getParent());
|
||||
$this->assertTrue($container->hasDefinition('state_machine.legacy.definition'), 'Workflow definition is registered as a service');
|
||||
|
||||
$workflowDefinition = $container->getDefinition('state_machine.legacy.definition');
|
||||
|
||||
$this->assertSame(['draft'], $workflowDefinition->getArgument(2));
|
||||
|
||||
$this->assertSame(
|
||||
[
|
||||
'draft',
|
||||
'published',
|
||||
],
|
||||
$workflowDefinition->getArgument(0),
|
||||
'Places are passed to the workflow definition'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
|
||||
* @expectedExceptionMessage A transition from a place/state must have an unique name. Multiple transitions named "go" from place/state "first" where found on StateMachine "my_workflow".
|
||||
@ -312,15 +287,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->createContainerFromFile('workflow_not_valid');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
* @expectedExceptionMessage "type" and "service" cannot be used together.
|
||||
*/
|
||||
public function testWorkflowCannotHaveBothTypeAndService()
|
||||
{
|
||||
$this->createContainerFromFile('workflow_legacy_with_type_and_service');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
* @expectedExceptionMessage "supports" and "support_strategy" cannot be used together.
|
||||
@ -339,16 +305,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->createContainerFromFile('workflow_without_support_and_support_strategy');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
* @expectedExceptionMessage "arguments" and "service" cannot be used together.
|
||||
* @group legacy
|
||||
*/
|
||||
public function testWorkflowCannotHaveBothArgumentsAndService()
|
||||
{
|
||||
$this->createContainerFromFile('workflow_legacy_with_arguments_and_service');
|
||||
}
|
||||
|
||||
public function testWorkflowMultipleTransitionsWithSameName()
|
||||
{
|
||||
$container = $this->createContainerFromFile('workflow_with_multiple_transitions_with_same_name');
|
||||
@ -450,14 +406,14 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertTrue($container->hasDefinition('console.command.workflow_dump'));
|
||||
}
|
||||
|
||||
public function testExplicitlyEnabledWorkflows()
|
||||
public function testWorkflowsExplicitlyEnabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('workflows_explicitly_enabled');
|
||||
|
||||
$this->assertTrue($container->hasDefinition('workflow.foo.definition'));
|
||||
}
|
||||
|
||||
public function testExplicitlyEnabledWorkflowNamedWorkflows()
|
||||
public function testWorkflowsNamedExplicitlyEnabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('workflows_explicitly_enabled_named_workflows');
|
||||
|
||||
|
@ -87,112 +87,4 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Using a workflow with type=workflow and a marking_store=single_state is deprecated since Symfony 4.3. Use type=state_machine instead.
|
||||
*/
|
||||
public function testWorkflowDeprecateWorkflowSingleState()
|
||||
{
|
||||
$this->createContainerFromClosure(function ($container) {
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'article' => [
|
||||
'type' => 'workflow',
|
||||
'marking_store' => [
|
||||
'type' => 'single_state',
|
||||
],
|
||||
'supports' => [
|
||||
__CLASS__,
|
||||
],
|
||||
'places' => [
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
],
|
||||
'transitions' => [
|
||||
'a_to_b' => [
|
||||
'from' => ['a'],
|
||||
'to' => ['b'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testWorkflowValidationMultipleState()
|
||||
{
|
||||
$this->createContainerFromClosure(function ($container) {
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'article' => [
|
||||
'type' => 'workflow',
|
||||
'marking_store' => [
|
||||
'type' => 'multiple_state',
|
||||
],
|
||||
'supports' => [
|
||||
__CLASS__,
|
||||
],
|
||||
'places' => [
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
],
|
||||
'transitions' => [
|
||||
'a_to_b' => [
|
||||
'from' => ['a'],
|
||||
'to' => ['b', 'c'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
// the test ensures that the validation does not fail (i.e. it does not throw any exceptions)
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
|
||||
* @expectedExceptionMessage The marking store of workflow "article" can not store many places. But the transition "a_to_b" has too many output (2). Only one is accepted.
|
||||
* @group legacy
|
||||
*/
|
||||
public function testWorkflowValidationSingleState()
|
||||
{
|
||||
$this->createContainerFromClosure(function ($container) {
|
||||
$container->loadFromExtension('framework', [
|
||||
'workflows' => [
|
||||
'article' => [
|
||||
'type' => 'workflow',
|
||||
'marking_store' => [
|
||||
'type' => 'single_state',
|
||||
],
|
||||
'supports' => [
|
||||
__CLASS__,
|
||||
],
|
||||
'places' => [
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
],
|
||||
'transitions' => [
|
||||
'a_to_b' => [
|
||||
'from' => ['a'],
|
||||
'to' => ['b', 'c'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
// the test ensures that the validation does not fail (i.e. it does not throw any exceptions)
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Workflow;
|
||||
|
||||
use Symfony\Component\Workflow\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Workflow\SupportStrategy\SupportStrategyInterface;
|
||||
use Symfony\Component\Workflow\SupportStrategy\WorkflowSupportStrategyInterface;
|
||||
|
||||
/**
|
||||
|
@ -12,27 +12,6 @@ class WorkflowValidatorTest extends TestCase
|
||||
{
|
||||
use WorkflowBuilderTrait;
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
|
||||
* @expectedExceptionMessage The marking store of workflow "foo" can not store many places.
|
||||
*/
|
||||
public function testSinglePlaceWorkflowValidatorAndComplexWorkflow()
|
||||
{
|
||||
$definition = $this->createComplexWorkflowDefinition();
|
||||
|
||||
(new WorkflowValidator(true))->validate($definition, 'foo');
|
||||
}
|
||||
|
||||
public function testSinglePlaceWorkflowValidatorAndSimpleWorkflow()
|
||||
{
|
||||
$definition = $this->createSimpleWorkflowDefinition();
|
||||
|
||||
(new WorkflowValidator(true))->validate($definition, 'foo');
|
||||
|
||||
// the test ensures that the validation does not fail (i.e. it does not throw any exceptions)
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
|
||||
* @expectedExceptionMessage All transitions for a place must have an unique name. Multiple transitions named "t1" where found for place "a" in workflow "foo".
|
||||
@ -51,20 +30,6 @@ class WorkflowValidatorTest extends TestCase
|
||||
(new WorkflowValidator())->validate($definition, 'foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
|
||||
* @expectedExceptionMessage The marking store of workflow "foo" can not store many places. But the definition has 2 initial places. Only one is supported.
|
||||
*/
|
||||
public function testWithTooManyInitialPlaces()
|
||||
{
|
||||
$places = range('a', 'c');
|
||||
$transitions = [];
|
||||
|
||||
$definition = new Definition($places, $transitions, ['a', 'b']);
|
||||
|
||||
(new WorkflowValidator(true))->validate($definition, 'foo');
|
||||
}
|
||||
|
||||
public function testSameTransitionNameButNotSamePlace()
|
||||
{
|
||||
$places = range('a', 'd');
|
||||
|
Reference in New Issue
Block a user