Skip to content

Commit 6f3de94

Browse files
minor symfony#25458 [TwigBridge] Fix workflow test with deps=low (Simperfit)
This PR was merged into the 4.1-dev branch. Discussion ---------- [TwigBridge] Fix workflow test with deps=low | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | none In the original PR the tests were not failling but we should not use the new feature with deps=low until it fetch the branch with the new feature. So this fix the test for the WorkflowExtension in TwigBridge. Commits ------- e5c6b92 [TwigBridge] Fix workflow test with deps=low
2 parents 193b98a + e5c6b92 commit 6f3de94

File tree

1 file changed

+6
-35
lines changed

1 file changed

+6
-35
lines changed

src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bridge\Twig\Extension\WorkflowExtension;
1616
use Symfony\Component\Workflow\Definition;
1717
use Symfony\Component\Workflow\Registry;
18+
use Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy;
1819
use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy;
1920
use Symfony\Component\Workflow\Transition;
2021
use Symfony\Component\Workflow\Workflow;
@@ -24,25 +25,6 @@ class WorkflowExtensionTest extends TestCase
2425
private $extension;
2526

2627
protected function setUp()
27-
{
28-
$places = array('ordered', 'waiting_for_payment', 'processed');
29-
$transitions = array(
30-
new Transition('t1', 'ordered', 'waiting_for_payment'),
31-
new Transition('t2', 'waiting_for_payment', 'processed'),
32-
);
33-
$definition = new Definition($places, $transitions);
34-
$workflow = new Workflow($definition);
35-
36-
$registry = new Registry();
37-
$registry->addWorkflow($workflow, new InstanceOfSupportStrategy(\stdClass::class));
38-
39-
$this->extension = new WorkflowExtension($registry);
40-
}
41-
42-
/**
43-
* @group legacy
44-
*/
45-
protected function setUpLegacyAdd()
4628
{
4729
if (!class_exists(Workflow::class)) {
4830
$this->markTestSkipped('The Workflow component is needed to run tests for this extension.');
@@ -57,25 +39,14 @@ protected function setUpLegacyAdd()
5739
$workflow = new Workflow($definition);
5840

5941
$registry = new Registry();
60-
$registry->add($workflow, new InstanceOfSupportStrategy(\stdClass::class));
61-
42+
$addWorkflow = method_exists($registry, 'addWorkflow') ? 'addWorkflow' : 'add';
43+
$supportStrategy = class_exists(InstanceOfSupportStrategy::class)
44+
? new InstanceOfSupportStrategy(\stdClass::class)
45+
: new ClassInstanceSupportStrategy(\stdClass::class);
46+
$registry->$addWorkflow($workflow, $supportStrategy);
6247
$this->extension = new WorkflowExtension($registry);
6348
}
6449

65-
/**
66-
* @group legacy
67-
* @expectedDeprecation Symfony\Component\Workflow\Registry::add is deprecated since Symfony 4.1. Use addWorkflow() instead.
68-
*/
69-
public function testCanTransitionLegacy()
70-
{
71-
$this->setUpLegacyAdd();
72-
$subject = new \stdClass();
73-
$subject->marking = array();
74-
75-
$this->assertTrue($this->extension->canTransition($subject, 't1'));
76-
$this->assertFalse($this->extension->canTransition($subject, 't2'));
77-
}
78-
7950
public function testCanTransition()
8051
{
8152
$subject = new \stdClass();

0 commit comments

Comments
 (0)