ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.test_005_ExclusiveGateway.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/WorkflowEngine/test/ilWorkflowEngineBaseTest.php';
5 
15 {
16  #region Helper
17  public $base_path = './Services/WorkflowEngine/test/parser/';
18  public $suite_path = '005_ExclusiveGateway/';
19 
20  public function getTestInputFilename($test_name)
21  {
22  return $this->base_path . $this->suite_path . $test_name . '.bpmn2';
23  }
24 
25  public function getTestOutputFilename($test_name)
26  {
27  return $this->base_path . $this->suite_path . $test_name . '_output.php';
28  }
29 
30  public function getTestGoldsampleFilename($test_name)
31  {
32  return $this->base_path . $this->suite_path . $test_name . '_goldsample.php';
33  }
34 
35  public function setUp()
36  {
37  chdir(dirname(__FILE__));
38  chdir('../../../../../');
39 
40  parent::setUp();
41 
42  require_once './Services/WorkflowEngine/classes/parser/class.ilBPMN2Parser.php';
43  }
44 
45  public function test_WorkflowWithExclusiveGatewayForkingShouldOutputAccordingly()
46  {
47  $test_name = 'ExclusiveGateway_Fork_Simple';
48  $xml = file_get_contents($this->getTestInputFilename($test_name));
49  $parser = new ilBPMN2Parser();
50  $parse_result = $parser->parseBPMN2XML($xml);
51 
52  file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
53  $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
54 
55  $this->assertTrue(substr($return, 0, 25) == 'No syntax errors detected', 'Lint of output code failed.');
56 
57  $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
58  $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
59 
60  require_once $this->getTestOutputFilename($test_name);
61  $process = new $test_name;
62  $this->assertFalse($process->isActive(), 'Process is not active.');
63 
64  $process->startWorkflow();
65  $all_triggered = true;
66  foreach ($process->getNodes() as $node) {
68  foreach ($node->getDetectors() as $detector) {
70  if (!$detector->getActivated()) {
71  $all_triggered = false;
72  }
73  }
74  foreach ($node->getEmitters() as $emitter) {
76  if (!$emitter->getActivated()) {
77  $all_triggered = false;
78  }
79  }
80  }
81  $this->assertFalse($all_triggered, 'All nodes were triggered.');
82 
83  $all_inactive = true;
84  foreach ($process->getNodes() as $node) {
85  if ($node->isActive()) {
86  $all_inactive = false;
87  }
88  }
89  $this->assertFalse($all_inactive, 'Not all nodes are inactive.');
93  unlink($this->getTestOutputFilename($test_name));
94  }
95 
96  public function test_WorkflowWithExclusiveGatewayJoiningShouldOutputAccordingly()
97  {
98  $test_name = 'ExclusiveGateway_Join_Simple';
99  $xml = file_get_contents($this->getTestInputFilename($test_name));
100  $parser = new ilBPMN2Parser();
101  $parse_result = $parser->parseBPMN2XML($xml);
102 
103  file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
104  $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
105 
106  $this->assertTrue(substr($return, 0, 25) == 'No syntax errors detected', 'Lint of output code failed.');
107 
108  $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
109  $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
110 
111  require_once $this->getTestOutputFilename($test_name);
112  $process = new $test_name;
113  $this->assertFalse($process->isActive(), 'Process is inactive.');
114 
115  $process->startWorkflow();
116  $all_triggered = true;
117  foreach ($process->getNodes() as $node) {
119  foreach ($node->getDetectors() as $detector) {
121  if (!$detector->getActivated()) {
122  $all_triggered = false;
123  }
124  }
125  foreach ($node->getEmitters() as $emitter) {
127  if (!$emitter->getActivated()) {
128  $all_triggered = false;
129  }
130  }
131  }
132  $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
133 
134  $all_inactive = true;
135  foreach ($process->getNodes() as $node) {
136  if ($node->isActive()) {
137  $all_inactive = false;
138  }
139  }
140  $this->assertTrue($all_inactive, 'Not all nodes are inactive.');
141 
142  unlink($this->getTestOutputFilename($test_name));
143  }
144 }
Class ilWorkflowEngineBaseTest.
$parse_result
Definition: BPMN2Parser.php:25
$xml
Definition: metadata.php:240
$parser
Definition: BPMN2Parser.php:23
Class ilBPMN2Parser.