Skip to content

Commit b5fee44

Browse files
committed
do not mock the container builder in tests
1 parent 9e9330b commit b5fee44

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Tests/DependencyInjection/ValidateWorkflowsPassTest.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,29 @@
44

55
use PHPUnit\Framework\TestCase;
66
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;
89
use Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass;
910
use Symfony\Component\Workflow\Transition;
1011

1112
class ValidateWorkflowsPassTest extends TestCase
1213
{
1314
public function testProcess()
1415
{
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'));
2724

2825
(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());
2931
}
3032
}

0 commit comments

Comments
 (0)