19 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
22 require_once
'./Services/WorkflowEngine/classes/utils/class.ilWorkflowUtils.php';
25 require_once
'./Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
29 require_once
'./Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
33 $this->workflow->addNode($this->node);
35 require_once
'./Services/WorkflowEngine/classes/detectors/class.ilTimerDetector.php';
41 if ($ilSetting != null) {
42 $ilSetting->delete(
'IL_PHPUNIT_TEST_TIME');
43 $ilSetting->delete(
'IL_PHPUNIT_TEST_MICROTIME');
56 'Construction failed with valid context passed to constructor.' 64 $expected = ilWorkflowUtils::time();
67 $detector->setTimerStart($expected);
68 $actual = $detector->getTimerStart();
71 $this->assertEquals($actual, $expected);
78 $expected = 5 * 60 * 60;
81 $detector->setTimerLimit($expected);
82 $actual = $detector->getTimerLimit();
85 $this->assertEquals($actual, $expected);
92 $timer_start = ilWorkflowUtils::time(); # +5 Minutes from here.
93 $timer_limit = 5 * 60;
94 $detector->setTimerStart($timer_start);
95 $detector->setTimerLimit($timer_limit);
98 $detector->trigger(null);
101 $actual = $detector->getDetectorState();
102 $this->assertFalse($actual,
'Early trigger should not satisfy detector');
109 $timer_start = ilWorkflowUtils::time(); # +5 Minutes from now.
111 $detector->setTimerStart($timer_start);
112 $detector->setTimerLimit($timer_limit);
115 $detector->trigger(null);
118 $actual = $detector->getDetectorState();
119 $this->assertTrue($actual,
'Trigger should not satisfy detector');
126 $timer_start = ilWorkflowUtils::time(); # +5 Minutes from now.
128 $detector->setTimerStart($timer_start);
129 $detector->setTimerLimit($timer_limit);
132 $detector->trigger(null);
133 $actual = $detector->trigger(null);
136 $this->assertFalse($actual,
'Detector should be satisfied after single trigger');
143 $timer_start = ilWorkflowUtils::time() + 5 * 60; # +5 Minutes from here.
145 $detector->setListeningTimeframe($timer_start, $timer_end);
148 $actual = $detector->isListening();
151 $this->assertFalse($actual,
'Detector should not be listening.');
158 $timer_start = ilWorkflowUtils::time() + 5 * 60; # +5 Minutes from here.
162 $actual = $detector->isListening();
165 $this->assertTrue($actual,
'Detector should be listening.');
179 $detector->setListeningTimeframe($exp_start, $exp_end);
180 $act = $detector->getListeningTimeframe();
183 $this->assertEquals($exp_start . $exp_end, $act[
'listening_start'] . $act[
'listening_end']);
190 $timer_start = ilWorkflowUtils::time() - 5 * 60; # -5 Minutes from now.
191 $timer_end = ilWorkflowUtils::time() - 1 * 60; # -1 Minute from now.
192 $detector->setListeningTimeframe($timer_start, $timer_end);
195 $actual = $detector->isListening();
198 $this->assertFalse($actual,
'Detector should not be listening.');
205 $timer_start = ilWorkflowUtils::time() - 5 * 60; # -5 Minutes from now.
206 $timer_end = 0; # Wildcard.
207 $detector->setListeningTimeframe($timer_start, $timer_end);
210 $actual = $detector->isListening();
213 $this->assertTrue($actual,
'Detector should not be listening.');
220 $timer_start = 0; # Wildcard.
221 $timer_end = ilWorkflowUtils::time() + 5 * 60; # +5 Minutes from now.
222 $detector->setListeningTimeframe($timer_start, $timer_end);
225 $actual = $detector->isListening();
228 $this->assertTrue($actual,
'Detector should not be listening.');
235 $exp_start = 4711; # +5 Minutes from here.
239 $detector->setListeningTimeframe($exp_start, $exp_end);
240 $act = $detector->getListeningTimeframe();
243 $this->assertEquals($exp_start . $exp_end, $act[
'listening_start'] . $act[
'listening_end']);
253 $detector->setDbId($expected);
254 $actual = $detector->getDbId();
257 $this->assertEquals($expected, $actual);
267 $detector->setDbId($expected);
268 $actual = $detector->hasDbId();
271 $this->assertTrue($actual);
284 $actual = $detector->getDbId();
287 $this->assertEquals($expected, $actual);
296 $actual = $detector->hasDbId();
299 $this->assertFalse($actual);
306 $exp_type =
'time_passed';
307 $exp_content =
'time_passed';
312 $event = $detector->getEvent();
313 $act_type = $event[
'type'];
314 $act_content = $event[
'content'];
315 $this->assertEquals($exp_type . $exp_content, $act_type . $act_content);
328 $event = $detector->getEventSubject();
329 $act_type = $event[
'type'];
330 $act_id = $event[
'identifier'];
331 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
344 $event = $detector->getEventContext();
345 $act_type = $event[
'type'];
346 $act_id = $event[
'identifier'];
347 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
356 $actual = $detector->getContext();
359 if ($actual === $this->node) {
360 $this->assertEquals($actual, $this->node);
362 $this->assertTrue(
false,
'Context not identical.');
testIsListeningWithWildcardBeginningTimeFrame()
testSetGetListeningTimeframe()
testIsListeningWithWildcardEndingTimeFrame()
testIsListeningWithoutTimeFrame()
testIsListeningWithPastTimeFrame()
ilTimerDetectorTest is part of the petri net based workflow engine.
testSetGetIllegalListeningTimeframe()
ilWorkflowInvalidArgumentException
testIsListeningWithTimeFrame()
testConstructorValidContext()
testGetNonExistingDbId()
ilWorkflowObjectStateException