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