ilEventDetectorTest is part of the petri net based workflow engine.
More...
ilEventDetectorTest is part of the petri net based workflow engine.
This class holds all tests for the class detectors/class.ilEventDetector
- Author
- Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
- Version
- $Id$
/
Definition at line 15 of file ilEventDetectorTest.php.
◆ setUp()
ilEventDetectorTest::setUp |
( |
| ) |
|
Definition at line 17 of file ilEventDetectorTest.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.ilEventDetector.php';
__construct(Container $dic, ilPlugin $plugin)
◆ tearDown()
ilEventDetectorTest::tearDown |
( |
| ) |
|
Definition at line 37 of file ilEventDetectorTest.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()
ilEventDetectorTest::testConstructorValidContext |
( |
| ) |
|
◆ testGetContext()
ilEventDetectorTest::testGetContext |
( |
| ) |
|
Definition at line 276 of file ilEventDetectorTest.php.
282 $actual = $detector->getContext();
285 if ($actual === $this->node) {
286 $this->assertEquals($actual, $this->node);
288 $this->assertTrue(
false,
'Context not identical.');
◆ testGetNonExistingDbId()
ilEventDetectorTest::testGetNonExistingDbId |
( |
| ) |
|
Definition at line 184 of file ilEventDetectorTest.php.
186 $this->expectException(ilWorkflowObjectStateException::class);
193 $actual = $detector->getDbId();
196 $this->assertEquals($expected, $actual);
◆ testHasDbIdSet()
ilEventDetectorTest::testHasDbIdSet |
( |
| ) |
|
Definition at line 199 of file ilEventDetectorTest.php.
206 $detector->setDbId($expected);
207 $actual = $detector->hasDbId();
210 $this->assertTrue($actual);
◆ testHasDbIdUnset()
ilEventDetectorTest::testHasDbIdUnset |
( |
| ) |
|
◆ testIsListeningWithoutTimeFrame()
ilEventDetectorTest::testIsListeningWithoutTimeFrame |
( |
| ) |
|
Definition at line 120 of file ilEventDetectorTest.php.
126 $actual = $detector->isListening();
129 $this->assertTrue($actual,
'Detector should be listening.');
◆ testIsListeningWithPastTimeFrame()
ilEventDetectorTest::testIsListeningWithPastTimeFrame |
( |
| ) |
|
Definition at line 75 of file ilEventDetectorTest.php.
79 $timer_start = ilWorkflowUtils::time() - 5 * 60; # -5 Minutes from now.
80 $timer_end = ilWorkflowUtils::time() - 1 * 60; # -1 Minute from now.
81 $detector->setListeningTimeframe($timer_start, $timer_end);
84 $actual = $detector->isListening();
87 $this->assertFalse($actual,
'Detector should not be listening.');
◆ testIsListeningWithTimeFrame()
ilEventDetectorTest::testIsListeningWithTimeFrame |
( |
| ) |
|
Definition at line 60 of file ilEventDetectorTest.php.
64 $timer_start = ilWorkflowUtils::time() + 5 * 60; # +5 Minutes from here.
66 $detector->setListeningTimeframe($timer_start, $timer_end);
69 $actual = $detector->isListening();
72 $this->assertFalse($actual,
'Detector should not be listening.');
◆ testIsListeningWithWildcardBeginningTimeFrame()
ilEventDetectorTest::testIsListeningWithWildcardBeginningTimeFrame |
( |
| ) |
|
Definition at line 105 of file ilEventDetectorTest.php.
109 $timer_start = 0; # Wildcard.
110 $timer_end = ilWorkflowUtils::time() + 5 * 60; # +5 Minutes from now.
111 $detector->setListeningTimeframe($timer_start, $timer_end);
114 $actual = $detector->isListening();
117 $this->assertTrue($actual,
'Detector should not be listening.');
◆ testIsListeningWithWildcardEndingTimeFrame()
ilEventDetectorTest::testIsListeningWithWildcardEndingTimeFrame |
( |
| ) |
|
Definition at line 90 of file ilEventDetectorTest.php.
94 $timer_start = ilWorkflowUtils::time() - 5 * 60; # -5 Minutes from now.
95 $timer_end = 0; # Wildcard.
96 $detector->setListeningTimeframe($timer_start, $timer_end);
99 $actual = $detector->isListening();
102 $this->assertTrue($actual,
'Detector should not be listening.');
◆ testSetGetDbId()
ilEventDetectorTest::testSetGetDbId |
( |
| ) |
|
Definition at line 167 of file ilEventDetectorTest.php.
174 $detector->setDbId($expected);
175 $actual = $detector->getDbId();
178 $this->assertEquals($expected, $actual);
◆ testSetGetEvent()
ilEventDetectorTest::testSetGetEvent |
( |
| ) |
|
Definition at line 225 of file ilEventDetectorTest.php.
229 $exp_type =
'time_passed';
230 $exp_content =
'time_passed';
233 $detector->setEvent($exp_type, $exp_content);
236 $event = $detector->getEvent();
237 $act_type = $event[
'type'];
238 $act_content = $event[
'content'];
239 $this->assertEquals($exp_type . $exp_content, $act_type . $act_content);
◆ testSetGetEventContext()
ilEventDetectorTest::testSetGetEventContext |
( |
| ) |
|
Definition at line 259 of file ilEventDetectorTest.php.
267 $detector->setEventContext($exp_type, $exp_id);
270 $event = $detector->getEventContext();
271 $act_type = $event[
'type'];
272 $act_id = $event[
'identifier'];
273 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
◆ testSetGetEventSubject()
ilEventDetectorTest::testSetGetEventSubject |
( |
| ) |
|
Definition at line 242 of file ilEventDetectorTest.php.
250 $detector->setEventSubject($exp_type, $exp_id);
253 $event = $detector->getEventSubject();
254 $act_type = $event[
'type'];
255 $act_id = $event[
'identifier'];
256 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
◆ testSetGetIllegalListeningTimeframe()
ilEventDetectorTest::testSetGetIllegalListeningTimeframe |
( |
| ) |
|
Definition at line 150 of file ilEventDetectorTest.php.
152 $this->expectException(ilWorkflowInvalidArgumentException::class);
156 $exp_start = 4712; # +5 Minutes from here.
160 $detector->setListeningTimeframe($exp_start, $exp_end);
161 $act = $detector->getListeningTimeframe();
164 $this->assertEquals($exp_start . $exp_end, $act[
'listening_start'] . $act[
'listening_end']);
◆ testSetGetListeningTimeframe()
ilEventDetectorTest::testSetGetListeningTimeframe |
( |
| ) |
|
Definition at line 132 of file ilEventDetectorTest.php.
140 $detector->setListeningTimeframe($exp_start, $exp_end);
141 $act = $detector->getListeningTimeframe();
144 $this->assertEquals($exp_start . $exp_end, $act[
'listening_start'] . $act[
'listening_end']);
◆ testTriggerInvalidContent()
ilEventDetectorTest::testTriggerInvalidContent |
( |
| ) |
|
Definition at line 349 of file ilEventDetectorTest.php.
353 $evt_type =
'testEvent';
354 $evt_content =
'content';
355 $detector->setEvent($evt_type, $evt_content);
358 $detector->setEventSubject($subj_type, $subj_id);
361 $detector->setEventContext($ctx_type, $ctx_id);
363 $evt_type, $evt_content .
'INVALIDATE',
364 $subj_type, $subj_id,
369 $detector->trigger($params);
372 $actual = $detector->getDetectorState();
373 $this->assertFalse($actual);
◆ testTriggerInvalidContextId()
ilEventDetectorTest::testTriggerInvalidContextId |
( |
| ) |
|
Definition at line 484 of file ilEventDetectorTest.php.
488 $evt_type =
'testEvent';
489 $evt_content =
'content';
490 $detector->setEvent($evt_type, $evt_content);
493 $detector->setEventSubject($subj_type, $subj_id);
496 $detector->setEventContext($ctx_type, $ctx_id);
498 $evt_type, $evt_content,
499 $subj_type, $subj_id,
500 $ctx_type, $ctx_id .
'INVALIDATE' 504 $detector->trigger($params);
507 $actual = $detector->getDetectorState();
508 $this->assertFalse($actual);
◆ testTriggerInvalidContextType()
ilEventDetectorTest::testTriggerInvalidContextType |
( |
| ) |
|
Definition at line 457 of file ilEventDetectorTest.php.
461 $evt_type =
'testEvent';
462 $evt_content =
'content';
463 $detector->setEvent($evt_type, $evt_content);
466 $detector->setEventSubject($subj_type, $subj_id);
469 $detector->setEventContext($ctx_type, $ctx_id);
471 $evt_type, $evt_content,
472 $subj_type, $subj_id,
473 $ctx_type .
'INVALIDATE', $ctx_id
477 $detector->trigger($params);
480 $actual = $detector->getDetectorState();
481 $this->assertFalse($actual);
◆ testTriggerInvalidSubjectId()
ilEventDetectorTest::testTriggerInvalidSubjectId |
( |
| ) |
|
Definition at line 430 of file ilEventDetectorTest.php.
434 $evt_type =
'testEvent';
435 $evt_content =
'content';
436 $detector->setEvent($evt_type, $evt_content);
439 $detector->setEventSubject($subj_type, $subj_id);
442 $detector->setEventContext($ctx_type, $ctx_id);
444 $evt_type, $evt_content,
445 $subj_type, $subj_id .
'INVALIDATE',
450 $detector->trigger($params);
453 $actual = $detector->getDetectorState();
454 $this->assertFalse($actual);
◆ testTriggerInvalidSubjectType()
ilEventDetectorTest::testTriggerInvalidSubjectType |
( |
| ) |
|
Definition at line 403 of file ilEventDetectorTest.php.
407 $evt_type =
'testEvent';
408 $evt_content =
'content';
409 $detector->setEvent($evt_type, $evt_content);
412 $detector->setEventSubject($subj_type, $subj_id);
415 $detector->setEventContext($ctx_type, $ctx_id);
417 $evt_type, $evt_content,
418 $subj_type .
'INVALIDATE', $subj_id,
423 $detector->trigger($params);
426 $actual = $detector->getDetectorState();
427 $this->assertFalse($actual);
◆ testTriggerInvalidType()
ilEventDetectorTest::testTriggerInvalidType |
( |
| ) |
|
Definition at line 376 of file ilEventDetectorTest.php.
380 $evt_type =
'testEvent';
381 $evt_content =
'content';
382 $detector->setEvent($evt_type, $evt_content);
385 $detector->setEventSubject($subj_type, $subj_id);
388 $detector->setEventContext($ctx_type, $ctx_id);
390 $evt_type .
'INVALIDATE', $evt_content,
391 $subj_type, $subj_id,
396 $detector->trigger($params);
399 $actual = $detector->getDetectorState();
400 $this->assertFalse($actual);
◆ testTriggerValid()
ilEventDetectorTest::testTriggerValid |
( |
| ) |
|
Definition at line 292 of file ilEventDetectorTest.php.
296 $evt_type =
'testEvent';
297 $evt_content =
'content';
298 $detector->setEvent($evt_type, $evt_content);
301 $detector->setEventSubject($subj_type, $subj_id);
304 $detector->setEventContext($ctx_type, $ctx_id);
306 $evt_type, $evt_content,
307 $subj_type, $subj_id,
312 $detector->trigger($params);
315 $actual = $detector->getDetectorState();
316 $this->assertTrue($actual);
◆ testTriggerValidTwice()
ilEventDetectorTest::testTriggerValidTwice |
( |
| ) |
|
Definition at line 319 of file ilEventDetectorTest.php.
323 $evt_type =
'testEvent';
324 $evt_content =
'content';
325 $detector->setEvent($evt_type, $evt_content);
328 $detector->setEventSubject($subj_type, $subj_id);
331 $detector->setEventContext($ctx_type, $ctx_id);
333 $evt_type, $evt_content,
334 $subj_type, $subj_id,
339 $this->assertTrue($detector->trigger($params),
'First trigger should receive a true state.');
340 $this->assertFalse($detector->trigger($params),
'Second trigger should receive a false state.');
343 $actual = $detector->getDetectorState();
344 $this->assertTrue($actual,
'After satisfaction of the trigger, detectorstate should be true.');
The documentation for this class was generated from the following file: