Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 77f820e

Browse filesBrowse files
committed
[TwigBridge][Workflow] Added more tests on WorkflowExtension
1 parent efe500d commit 77f820e
Copy full SHA for 77f820e

File tree

1 file changed

+38
-8
lines changed
Filter options

1 file changed

+38
-8
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php
+38-8Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,62 @@
1515
use Symfony\Component\Workflow\Definition;
1616
use Symfony\Component\Workflow\Marking;
1717
use Symfony\Component\Workflow\Registry;
18+
use Symfony\Component\Workflow\Transition;
1819
use Symfony\Component\Workflow\Workflow;
1920

2021
class WorkflowExtensionTest extends \PHPUnit_Framework_TestCase
2122
{
23+
private $extension;
24+
2225
protected function setUp()
2326
{
2427
if (!class_exists(Workflow::class)) {
2528
$this->markTestSkipped('The Workflow component is needed to run tests for this extension.');
2629
}
27-
}
2830

29-
public function testHasMarkedPlace()
30-
{
31-
$definition = new Definition(['ordered', 'waiting_for_payment', 'processed'], []);
31+
$places = array('ordered', 'waiting_for_payment', 'processed');
32+
$transitions = array(
33+
new Transition('t1', 'ordered', 'waiting_for_payment'),
34+
new Transition('t2', 'waiting_for_payment', 'processed'),
35+
);
36+
$definition = new Definition($places, $transitions);
3237
$workflow = new Workflow($definition);
3338

3439
$registry = new Registry();
3540
$registry->add($workflow, \stdClass::class);
3641

37-
$extension = new WorkflowExtension($registry);
42+
$this->extension = new WorkflowExtension($registry);
43+
}
44+
45+
public function testCanTransition()
46+
{
47+
$subject = new \stdClass();
48+
$subject->marking = array();
49+
50+
$this->assertTrue($this->extension->canTransition($subject, 't1'));
51+
$this->assertFalse($this->extension->canTransition($subject, 't2'));
52+
}
53+
54+
public function testGetEnabledTransitions()
55+
{
56+
$subject = new \stdClass();
57+
$subject->marking = array();
58+
59+
$transitions = $this->extension->getEnabledTransitions($subject);
3860

61+
$this->assertCount(1, $transitions);
62+
$this->assertInstanceOf(Transition::class, $transitions[0]);
63+
$this->assertSame('t1', $transitions[0]->getName());
64+
}
65+
66+
public function testHasMarkedPlace()
67+
{
3968
$subject = new \stdClass();
69+
$subject->marking = array();
4070
$subject->marking = array('ordered' => 1, 'waiting_for_payment' => 1);
4171

42-
$this->assertTrue($extension->hasMarkedPlace($subject, 'ordered'));
43-
$this->assertTrue($extension->hasMarkedPlace($subject, 'waiting_for_payment'));
44-
$this->assertFalse($extension->hasMarkedPlace($subject, 'processed'));
72+
$this->assertTrue($this->extension->hasMarkedPlace($subject, 'ordered'));
73+
$this->assertTrue($this->extension->hasMarkedPlace($subject, 'waiting_for_payment'));
74+
$this->assertFalse($this->extension->hasMarkedPlace($subject, 'processed'));
4575
}
4676
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.