ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.test_009_EndEvent.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 
13 {
14  #region Helper
15  public $base_path = './Services/WorkflowEngine/test/parser/';
16  public $suite_path = '009_EndEvent/';
17 
18  public function getTestInputFilename($test_name)
19  {
20  return $this->base_path . $this->suite_path . $test_name . '.bpmn2';
21  }
22 
23  public function getTestOutputFilename($test_name)
24  {
25  return $this->base_path . $this->suite_path . $test_name . '_output.php';
26  }
27 
28  public function getTestGoldsampleFilename($test_name)
29  {
30  return $this->base_path . $this->suite_path . $test_name . '_goldsample.php';
31  }
32 
33  public function setUp()
34  {
35  chdir(dirname(__FILE__));
36  chdir('../../../../../');
37 
38  parent::setUp();
39 
40  require_once './Services/WorkflowEngine/classes/parser/class.ilBPMN2Parser.php';
41  }
42 
43  public function test_WorkflowWithSimpleEndEventShouldOutputAccordingly()
44  {
45  $test_name = 'EndEvent_Blanko_Simple';
46  $xml = file_get_contents($this->getTestInputFilename($test_name));
47  $parser = new ilBPMN2Parser();
48  $parse_result = $parser->parseBPMN2XML($xml);
49 
50  file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
51  $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
52 
53  $this->assertTrue(substr($return, 0, 25) == 'No syntax errors detected', 'Lint of output code failed.');
54 
55  $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
56  $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
57 
58  require_once $this->getTestOutputFilename($test_name);
59  $process = new $test_name;
60  $process->startWorkflow();
61  $all_triggered = true;
62  foreach ($process->getNodes() as $node) {
64  foreach ($node->getDetectors() as $detector) {
66  if (!$detector->getActivated()) {
67  $all_triggered = false;
68  }
69  }
70  foreach ($node->getEmitters() as $emitter) {
72  if (!$emitter->getActivated()) {
73  $all_triggered = false;
74  }
75  }
76  }
77  $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
78 
79  unlink($this->getTestOutputFilename($test_name));
80  }
81 
82  public function test_WorkflowWithSignalEndEventShouldOutputAccordingly()
83  {
84  $test_name = 'EndEvent_Signal_Simple';
85  $xml = file_get_contents($this->getTestInputFilename($test_name));
86  $parser = new ilBPMN2Parser();
87  $parse_result = $parser->parseBPMN2XML($xml);
88 
89  file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
90  $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
91 
92  $this->assertTrue(substr($return, 0, 25) == 'No syntax errors detected', 'Lint of output code failed.');
93 
94  $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
95  $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
96 
97  $ilappeventhandler_mock = $this->createMock('ilAppEventHandler', array('raise'), array(), '', false, false);
98  $ilappeventhandler_mock
99  ->expects($this->once())
100  ->method('raise')
101  ->will($this->returnValue(true));
102 
103 
104  global $ilAppEventHandler;
105  $ilAppEventHandler = $ilappeventhandler_mock;
106  $GLOBALS['ilAppEventHandler'] = $ilappeventhandler_mock;
107 
108  require_once $this->getTestOutputFilename($test_name);
109  $process = new $test_name;
110  $process->startWorkflow();
111  $all_triggered = true;
112  foreach ($process->getNodes() as $node) {
114  foreach ($node->getDetectors() as $detector) {
116  if (!$detector->getActivated()) {
117  $all_triggered = false;
118  }
119  }
120  foreach ($node->getEmitters() as $emitter) {
122  if (!$emitter->getActivated()) {
123  $all_triggered = false;
124  }
125  }
126  }
127  $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
128 
129  unlink($this->getTestOutputFilename($test_name));
130  }
131 
132  public function test_WorkflowWithMessageEndEventShouldOutputAccordingly()
133  {
134  $test_name = 'EndEvent_Message_Simple';
135  $xml = file_get_contents($this->getTestInputFilename($test_name));
136  $parser = new ilBPMN2Parser();
137  $parse_result = $parser->parseBPMN2XML($xml);
138 
139  file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
140  $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
141 
142  $this->assertTrue(substr($return, 0, 25) == 'No syntax errors detected', 'Lint of output code failed.');
143 
144  $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
145  $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
146 
147  $ilappeventhandler_mock = $this->createMock('ilAppEventHandler', array('raise'), array(), '', false, false);
148  $ilappeventhandler_mock
149  ->expects($this->once())
150  ->method('raise')
151  ->will($this->returnValue(true));
152 
153 
154  global $ilAppEventHandler;
155  $ilAppEventHandler = $ilappeventhandler_mock;
156  $GLOBALS['ilAppEventHandler'] = $ilappeventhandler_mock;
157 
158  require_once $this->getTestOutputFilename($test_name);
159  $process = new $test_name;
160  $process->startWorkflow();
161  $all_triggered = true;
162  foreach ($process->getNodes() as $node) {
164  foreach ($node->getDetectors() as $detector) {
166  if (!$detector->getActivated()) {
167  $all_triggered = false;
168  }
169  }
170  foreach ($node->getEmitters() as $emitter) {
172  if (!$emitter->getActivated()) {
173  $all_triggered = false;
174  }
175  }
176  }
177  $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
178 
179  unlink($this->getTestOutputFilename($test_name));
180  }
181 
182  public function test_WorkflowWithTerminateEndEventShouldOutputAccordingly()
183  {
184  $test_name = 'EndEvent_Terminate_Simple';
185  $xml = file_get_contents($this->getTestInputFilename($test_name));
186  $parser = new ilBPMN2Parser();
187  $parse_result = $parser->parseBPMN2XML($xml);
188 
189  file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
190  $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
191 
192  $this->assertTrue(substr($return, 0, 25) == 'No syntax errors detected', 'Lint of output code failed.');
193 
194  $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
195  $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
196 
197  require_once $this->getTestOutputFilename($test_name);
198  $process = new $test_name;
199  $process->startWorkflow();
200  $all_triggered = true;
201  foreach ($process->getNodes() as $node) {
203  foreach ($node->getDetectors() as $detector) {
205  if (!$detector->getActivated()) {
206  $all_triggered = false;
207  }
208  }
209  foreach ($node->getEmitters() as $emitter) {
211  if (!$emitter->getActivated()) {
212  $all_triggered = false;
213  }
214  }
215  }
216  $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
217 
218  unlink($this->getTestOutputFilename($test_name));
219  }
220 }
Class ilWorkflowEngineBaseTest.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$parse_result
Definition: BPMN2Parser.php:25
$xml
Definition: metadata.php:240
Create styles array
The data for the language used.
$parser
Definition: BPMN2Parser.php:23
getTestGoldsampleFilename($test_name)
Class ilBPMN2Parser.