15
15
use Symfony \Bridge \Twig \Extension \WorkflowExtension ;
16
16
use Symfony \Component \Workflow \Definition ;
17
17
use Symfony \Component \Workflow \Registry ;
18
+ use Symfony \Component \Workflow \SupportStrategy \ClassInstanceSupportStrategy ;
18
19
use Symfony \Component \Workflow \SupportStrategy \InstanceOfSupportStrategy ;
19
20
use Symfony \Component \Workflow \Transition ;
20
21
use Symfony \Component \Workflow \Workflow ;
@@ -24,25 +25,6 @@ class WorkflowExtensionTest extends TestCase
24
25
private $ extension ;
25
26
26
27
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 ()
46
28
{
47
29
if (!class_exists (Workflow::class)) {
48
30
$ this ->markTestSkipped ('The Workflow component is needed to run tests for this extension. ' );
@@ -57,25 +39,14 @@ protected function setUpLegacyAdd()
57
39
$ workflow = new Workflow ($ definition );
58
40
59
41
$ 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 );
62
47
$ this ->extension = new WorkflowExtension ($ registry );
63
48
}
64
49
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
-
79
50
public function testCanTransition ()
80
51
{
81
52
$ subject = new \stdClass ();
0 commit comments