Skip to content

Commit 492ec93

Browse files
committed
[Workflow] Add more tests
1 parent d7b0d33 commit 492ec93

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

Tests/Validator/WorkflowValidatorTest.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Workflow\Tests\Validator;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Workflow\Arc;
1516
use Symfony\Component\Workflow\Definition;
1617
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;
1718
use Symfony\Component\Workflow\Tests\WorkflowBuilderTrait;
@@ -24,8 +25,6 @@ class WorkflowValidatorTest extends TestCase
2425

2526
public function testWorkflowWithInvalidNames()
2627
{
27-
$this->expectException(InvalidDefinitionException::class);
28-
$this->expectExceptionMessage('All transitions for a place must have an unique name. Multiple transitions named "t1" where found for place "a" in workflow "foo".');
2928
$places = range('a', 'c');
3029

3130
$transitions = [];
@@ -35,6 +34,9 @@ public function testWorkflowWithInvalidNames()
3534

3635
$definition = new Definition($places, $transitions);
3736

37+
$this->expectException(InvalidDefinitionException::class);
38+
$this->expectExceptionMessage('All transitions for a place must have an unique name. Multiple transitions named "t1" where found for place "a" in workflow "foo".');
39+
3840
(new WorkflowValidator())->validate($definition, 'foo');
3941
}
4042

@@ -54,4 +56,32 @@ public function testSameTransitionNameButNotSamePlace()
5456
// the test ensures that the validation does not fail (i.e. it does not throw any exceptions)
5557
$this->addToAssertionCount(1);
5658
}
59+
60+
public function testWithTooManyOutput()
61+
{
62+
$places = ['a', 'b', 'c'];
63+
$transitions = [
64+
new Transition('t1', 'a', ['b', 'c']),
65+
];
66+
$definition = new Definition($places, $transitions);
67+
68+
$this->expectException(InvalidDefinitionException::class);
69+
$this->expectExceptionMessage('The marking store of workflow "foo" cannot store many places. But the transition "t1" has too many output (2). Only one is accepted.');
70+
71+
(new WorkflowValidator(true))->validate($definition, 'foo');
72+
}
73+
74+
public function testWithTooManyInitialPlaces()
75+
{
76+
$places = ['a', 'b', 'c'];
77+
$transitions = [
78+
new Transition('t1', 'a', 'b'),
79+
];
80+
$definition = new Definition($places, $transitions, ['a', 'b']);
81+
82+
$this->expectException(InvalidDefinitionException::class);
83+
$this->expectExceptionMessage('The marking store of workflow "foo" cannot store many places. But the definition has 2 initial places. Only one is supported.');
84+
85+
(new WorkflowValidator(true))->validate($definition, 'foo');
86+
}
5787
}

0 commit comments

Comments
 (0)