ilTimerDetectorTest is part of the petri net based workflow engine.
More...
ilTimerDetectorTest is part of the petri net based workflow engine.
This class holds all tests for the class detectors/class.ilTimerDetector
- Author
- Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
- Version
- $Id$
/
Definition at line 15 of file ilTimerDetectorTest.php.
◆ setUp()
ilTimerDetectorTest::setUp |
( |
| ) |
|
Definition at line 17 of file ilTimerDetectorTest.php.
References ILIAS\GlobalScreen\Provider\__construct().
21 require_once
'./Services/WorkflowEngine/classes/utils/class.ilWorkflowUtils.php';
24 require_once
'./Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
28 require_once
'./Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
32 $this->workflow->addNode($this->node);
34 require_once
'./Services/WorkflowEngine/classes/detectors/class.ilTimerDetector.php';
__construct(Container $dic, ilPlugin $plugin)
◆ tearDown()
ilTimerDetectorTest::tearDown |
( |
| ) |
|
Definition at line 37 of file ilTimerDetectorTest.php.
References $DIC.
41 if (isset($DIC[
'ilSetting'])) {
42 $DIC[
'ilSetting']->delete(
'IL_PHPUNIT_TEST_TIME');
43 $DIC[
'ilSetting']->delete(
'IL_PHPUNIT_TEST_MICROTIME');
◆ testConstructorValidContext()
ilTimerDetectorTest::testConstructorValidContext |
( |
| ) |
|
◆ testGetContext()
ilTimerDetectorTest::testGetContext |
( |
| ) |
|
Definition at line 354 of file ilTimerDetectorTest.php.
360 $actual = $detector->getContext();
363 if ($actual === $this->node) {
364 $this->assertEquals($actual, $this->node);
366 $this->assertTrue(
false,
'Context not identical.');
◆ testGetEvent()
ilTimerDetectorTest::testGetEvent |
( |
| ) |
|
Definition at line 306 of file ilTimerDetectorTest.php.
310 $exp_type =
'time_passed';
311 $exp_content =
'time_passed';
316 $event = $detector->getEvent();
317 $act_type = $event[
'type'];
318 $act_content = $event[
'content'];
319 $this->assertEquals($exp_type . $exp_content, $act_type . $act_content);
◆ testGetEventContext()
ilTimerDetectorTest::testGetEventContext |
( |
| ) |
|
Definition at line 338 of file ilTimerDetectorTest.php.
348 $event = $detector->getEventContext();
349 $act_type = $event[
'type'];
350 $act_id = $event[
'identifier'];
351 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
◆ testGetEventSubject()
ilTimerDetectorTest::testGetEventSubject |
( |
| ) |
|
Definition at line 322 of file ilTimerDetectorTest.php.
332 $event = $detector->getEventSubject();
333 $act_type = $event[
'type'];
334 $act_id = $event[
'identifier'];
335 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
◆ testGetNonExistingDbId()
ilTimerDetectorTest::testGetNonExistingDbId |
( |
| ) |
|
Definition at line 279 of file ilTimerDetectorTest.php.
281 $this->expectException(ilWorkflowObjectStateException::class);
288 $actual = $detector->getDbId();
291 $this->assertEquals($expected, $actual);
◆ testHasDbIdSet()
ilTimerDetectorTest::testHasDbIdSet |
( |
| ) |
|
Definition at line 262 of file ilTimerDetectorTest.php.
269 $detector->setDbId($expected);
270 $actual = $detector->hasDbId();
273 $this->assertTrue($actual);
◆ testHasDbIdUnset()
ilTimerDetectorTest::testHasDbIdUnset |
( |
| ) |
|
◆ testIsListeningWithoutTimeFrame()
ilTimerDetectorTest::testIsListeningWithoutTimeFrame |
( |
| ) |
|
Definition at line 154 of file ilTimerDetectorTest.php.
158 $timer_start = ilWorkflowUtils::time() + 5 * 60; # +5 Minutes from here.
162 $actual = $detector->isListening();
165 $this->assertTrue($actual,
'Detector should be listening.');
◆ testIsListeningWithPastTimeFrame()
ilTimerDetectorTest::testIsListeningWithPastTimeFrame |
( |
| ) |
|
Definition at line 188 of file ilTimerDetectorTest.php.
192 $timer_start = ilWorkflowUtils::time() - 5 * 60; # -5 Minutes from now.
193 $timer_end = ilWorkflowUtils::time() - 1 * 60; # -1 Minute from now.
194 $detector->setListeningTimeframe($timer_start, $timer_end);
197 $actual = $detector->isListening();
200 $this->assertFalse($actual,
'Detector should not be listening.');
◆ testIsListeningWithTimeFrame()
ilTimerDetectorTest::testIsListeningWithTimeFrame |
( |
| ) |
|
Definition at line 139 of file ilTimerDetectorTest.php.
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.');
◆ testIsListeningWithWildcardBeginningTimeFrame()
ilTimerDetectorTest::testIsListeningWithWildcardBeginningTimeFrame |
( |
| ) |
|
Definition at line 218 of file ilTimerDetectorTest.php.
222 $timer_start = 0; # Wildcard.
223 $timer_end = ilWorkflowUtils::time() + 5 * 60; # +5 Minutes from now.
224 $detector->setListeningTimeframe($timer_start, $timer_end);
227 $actual = $detector->isListening();
230 $this->assertTrue($actual,
'Detector should not be listening.');
◆ testIsListeningWithWildcardEndingTimeFrame()
ilTimerDetectorTest::testIsListeningWithWildcardEndingTimeFrame |
( |
| ) |
|
Definition at line 203 of file ilTimerDetectorTest.php.
207 $timer_start = ilWorkflowUtils::time() - 5 * 60; # -5 Minutes from now.
208 $timer_end = 0; # Wildcard.
209 $detector->setListeningTimeframe($timer_start, $timer_end);
212 $actual = $detector->isListening();
215 $this->assertTrue($actual,
'Detector should not be listening.');
◆ testSetGetDbId()
ilTimerDetectorTest::testSetGetDbId |
( |
| ) |
|
Definition at line 248 of file ilTimerDetectorTest.php.
255 $detector->setDbId($expected);
256 $actual = $detector->getDbId();
259 $this->assertEquals($expected, $actual);
◆ testSetGetIllegalListeningTimeframe()
ilTimerDetectorTest::testSetGetIllegalListeningTimeframe |
( |
| ) |
|
Definition at line 171 of file ilTimerDetectorTest.php.
173 $this->expectException(ilWorkflowInvalidArgumentException::class);
181 $detector->setListeningTimeframe($exp_start, $exp_end);
182 $act = $detector->getListeningTimeframe();
185 $this->assertEquals($exp_start . $exp_end, $act[
'listening_start'] . $act[
'listening_end']);
◆ testSetGetListeningTimeframe()
ilTimerDetectorTest::testSetGetListeningTimeframe |
( |
| ) |
|
Definition at line 233 of file ilTimerDetectorTest.php.
237 $exp_start = 4711; # +5 Minutes from here.
241 $detector->setListeningTimeframe($exp_start, $exp_end);
242 $act = $detector->getListeningTimeframe();
245 $this->assertEquals($exp_start . $exp_end, $act[
'listening_start'] . $act[
'listening_end']);
◆ testSetGetTimerLimit()
ilTimerDetectorTest::testSetGetTimerLimit |
( |
| ) |
|
Definition at line 74 of file ilTimerDetectorTest.php.
78 $expected = 5 * 60 * 60;
81 $detector->setTimerLimit($expected);
82 $actual = $detector->getTimerLimit();
85 $this->assertEquals($actual, $expected);
◆ testSetGetTimerStart()
ilTimerDetectorTest::testSetGetTimerStart |
( |
| ) |
|
Definition at line 60 of file ilTimerDetectorTest.php.
64 $expected = ilWorkflowUtils::time();
67 $detector->setTimerStart($expected);
68 $actual = $detector->getTimerStart();
71 $this->assertEquals($actual, $expected);
◆ testTriggerEarly()
ilTimerDetectorTest::testTriggerEarly |
( |
| ) |
|
Definition at line 88 of file ilTimerDetectorTest.php.
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');
◆ testTriggerValid()
ilTimerDetectorTest::testTriggerValid |
( |
| ) |
|
Definition at line 105 of file ilTimerDetectorTest.php.
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');
◆ testTriggerValidTwice()
ilTimerDetectorTest::testTriggerValidTwice |
( |
| ) |
|
Definition at line 122 of file ilTimerDetectorTest.php.
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');
The documentation for this class was generated from the following file: