|
4 | 4 |
|
5 | 5 | use PHPUnit\Framework\TestCase; |
6 | 6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
7 | | -use Symfony\Component\Workflow\Definition; |
| 7 | +use Symfony\Component\DependencyInjection\Definition; |
| 8 | +use Symfony\Component\Workflow\Definition as WorkflowDefinition; |
8 | 9 | use Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass; |
9 | 10 | use Symfony\Component\Workflow\Transition; |
10 | 11 |
|
11 | 12 | class ValidateWorkflowsPassTest extends TestCase |
12 | 13 | { |
13 | 14 | public function testProcess() |
14 | 15 | { |
15 | | - $container = $this->getMockBuilder(ContainerBuilder::class)->getMock(); |
16 | | - $container |
17 | | - ->expects($this->once()) |
18 | | - ->method('findTaggedServiceIds') |
19 | | - ->with('workflow.definition') |
20 | | - ->willReturn(array('definition1' => array('workflow.definition' => array('name' => 'wf1', 'type' => 'state_machine', 'marking_store' => 'foo')))); |
21 | | - |
22 | | - $container |
23 | | - ->expects($this->once()) |
24 | | - ->method('get') |
25 | | - ->with('definition1') |
26 | | - ->willReturn(new Definition(array('a', 'b', 'c'), array(new Transition('t1', 'a', 'b'), new Transition('t2', 'a', 'c')))); |
| 16 | + $container = new ContainerBuilder(); |
| 17 | + $container->register('definition1', WorkflowDefinition::class) |
| 18 | + ->addArgument(array('a', 'b', 'c')) |
| 19 | + ->addArgument(array( |
| 20 | + new Definition(Transition::class, array('t1', 'a', 'b')), |
| 21 | + new Definition(Transition::class, array('t2', 'a', 'c')), |
| 22 | + )) |
| 23 | + ->addTag('workflow.definition', array('name' => 'wf1', 'type' => 'state_machine', 'marking_store' => 'foo')); |
27 | 24 |
|
28 | 25 | (new ValidateWorkflowsPass())->process($container); |
| 26 | + |
| 27 | + $workflowDefinition = $container->get('definition1'); |
| 28 | + |
| 29 | + $this->assertSame(array('a' => 'a', 'b' => 'b', 'c' => 'c'), $workflowDefinition->getPlaces()); |
| 30 | + $this->assertEquals(array(new Transition('t1', 'a', 'b'), new Transition('t2', 'a', 'c')), $workflowDefinition->getTransitions()); |
29 | 31 | } |
30 | 32 | } |
0 commit comments