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.
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.ilEventDetector.php';
◆ tearDown()
ilEventDetectorTest::tearDown |
( |
| ) |
|
Definition at line 38 of file ilEventDetectorTest.php.
References $ilSetting.
41 if ($ilSetting != null) {
42 $ilSetting->delete(
'IL_PHPUNIT_TEST_TIME');
43 $ilSetting->delete(
'IL_PHPUNIT_TEST_MICROTIME');
◆ testConstructorValidContext()
ilEventDetectorTest::testConstructorValidContext |
( |
| ) |
|
◆ testDeleteDetectorFromDb()
ilEventDetectorTest::testDeleteDetectorFromDb |
( |
| ) |
|
Definition at line 264 of file ilEventDetectorTest.php.
References $GLOBALS, and array.
266 $this->markTestIncomplete(
267 '$ilDB throws notices during test.' 272 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
273 $ilDB_mock = $this->createMock(
'ilDBMySQL',
array(
'quote',
'manipulate'),
array(),
'',
false);
275 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnValue(234));
276 $ilDB_mock->expects($this->any())->method(
'manipulate')->with(
278 FROM wfe_det_listening 279 WHERE detector_id = 234' 280 )->will($this->returnValue(
true));
282 $stashed_real_object = @
$GLOBALS[
'ilDB'];
286 $detector->setDbId(234);
287 $detector->deleteDetectorFromDb();
288 $actual = $detector->hasDbId();
291 $this->assertFalse($actual);
292 $GLOBALS[
'ilDB'] = $stashed_real_object;
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
◆ testGetContext()
ilEventDetectorTest::testGetContext |
( |
| ) |
|
Definition at line 421 of file ilEventDetectorTest.php.
427 $actual = $detector->getContext();
430 if ($actual === $this->node) {
431 $this->assertEquals($actual, $this->node);
433 $this->assertTrue(
false,
'Context not identical.');
◆ testGetNonExistingDbId()
ilEventDetectorTest::testGetNonExistingDbId |
( |
| ) |
|
◆ testHasDbIdSet()
ilEventDetectorTest::testHasDbIdSet |
( |
| ) |
|
Definition at line 195 of file ilEventDetectorTest.php.
202 $detector->setDbId($expected);
203 $actual = $detector->hasDbId();
206 $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.
References time.
81 $detector->setListeningTimeframe($timer_start, $timer_end);
84 $actual = $detector->isListening();
87 $this->assertFalse($actual,
'Detector should not be listening.');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testIsListeningWithTimeFrame()
ilEventDetectorTest::testIsListeningWithTimeFrame |
( |
| ) |
|
Definition at line 60 of file ilEventDetectorTest.php.
References time.
66 $detector->setListeningTimeframe($timer_start, $timer_end);
69 $actual = $detector->isListening();
72 $this->assertFalse($actual,
'Detector should not be listening.');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testIsListeningWithWildcardBeginningTimeFrame()
ilEventDetectorTest::testIsListeningWithWildcardBeginningTimeFrame |
( |
| ) |
|
Definition at line 105 of file ilEventDetectorTest.php.
References time.
109 $timer_start = 0; # Wildcard.
111 $detector->setListeningTimeframe($timer_start, $timer_end);
114 $actual = $detector->isListening();
117 $this->assertTrue($actual,
'Detector should not be listening.');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testIsListeningWithWildcardEndingTimeFrame()
ilEventDetectorTest::testIsListeningWithWildcardEndingTimeFrame |
( |
| ) |
|
Definition at line 90 of file ilEventDetectorTest.php.
References time.
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.');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testOnActivate()
ilEventDetectorTest::testOnActivate |
( |
| ) |
|
Definition at line 295 of file ilEventDetectorTest.php.
References $GLOBALS, and array.
297 $this->markTestIncomplete(
298 '$ilDB throws notices during test.' 303 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
304 $ilDB_mock = $this->createMock(
'ilDBMySQL',
array(
'nextID',
'quote',
'insert'),
array(),
'',
false);
306 $ilDB_mock->expects($this->once())->method(
'nextID')->with($this->equalTo(
'wfe_det_listening'))->will($this->returnValue(234));
307 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnArgument(0));
308 $ilDB_mock->expects($this->any())->method(
'insert')->with(
311 'detector_id' =>
array(
'integer', 234),
312 'workflow_id' =>
array(
'integer', null),
313 'type' =>
array(
'text',
'' ),
314 'content' =>
array(
'text',
''),
315 'subject_type' =>
array(
'text',
''),
316 'subject_id' =>
array(
'integer',
''),
317 'context_type' =>
array(
'text',
''),
318 'context_id' =>
array(
'integer',
''),
319 'listening_start' =>
array(
'integer', 0),
320 'listening_end' =>
array(
'integer', 0)
322 )->will($this->returnValue(
true));
324 $stashed_real_object = @
$GLOBALS[
'ilDB'];
328 $detector->onActivate();
329 $actual = $detector->hasDbId();
332 $this->assertTrue($actual);
333 $this->assertEquals(234, $detector->getDbId());
334 $GLOBALS[
'ilDB'] = $stashed_real_object;
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
◆ testOnDeactivate()
ilEventDetectorTest::testOnDeactivate |
( |
| ) |
|
Definition at line 337 of file ilEventDetectorTest.php.
References $GLOBALS, and array.
339 $this->markTestIncomplete(
340 '$ilDB throws notices during test.' 346 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
347 $ilDB_mock = $this->createMock(
'ilDBMySQL',
array(
'quote',
'manipulate'),
array(),
'',
false);
349 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnValue(234));
350 $ilDB_mock->expects($this->any())->method(
'manipulate')->with(
352 FROM wfe_det_listening 353 WHERE detector_id = 234' 354 )->will($this->returnValue(
true));
356 $stashed_real_object = @
$GLOBALS[
'ilDB'];
360 $detector->setDbId(234);
361 $detector->onDeactivate();
362 $actual = $detector->hasDbId();
365 $this->assertFalse($actual);
367 $GLOBALS[
'ilDB'] = $stashed_real_object;
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
◆ testSetGetDbId()
ilEventDetectorTest::testSetGetDbId |
( |
| ) |
|
Definition at line 165 of file ilEventDetectorTest.php.
172 $detector->setDbId($expected);
173 $actual = $detector->getDbId();
176 $this->assertEquals($expected, $actual);
◆ testSetGetEvent()
ilEventDetectorTest::testSetGetEvent |
( |
| ) |
|
Definition at line 370 of file ilEventDetectorTest.php.
374 $exp_type =
'time_passed';
375 $exp_content =
'time_passed';
378 $detector->setEvent($exp_type, $exp_content);
381 $event = $detector->getEvent();
382 $act_type = $event[
'type'];
383 $act_content = $event[
'content'];
384 $this->assertEquals($exp_type . $exp_content, $act_type . $act_content);
◆ testSetGetEventContext()
ilEventDetectorTest::testSetGetEventContext |
( |
| ) |
|
Definition at line 404 of file ilEventDetectorTest.php.
412 $detector->setEventContext($exp_type, $exp_id);
415 $event = $detector->getEventContext();
416 $act_type = $event[
'type'];
417 $act_id = $event[
'identifier'];
418 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
◆ testSetGetEventSubject()
ilEventDetectorTest::testSetGetEventSubject |
( |
| ) |
|
Definition at line 387 of file ilEventDetectorTest.php.
395 $detector->setEventSubject($exp_type, $exp_id);
398 $event = $detector->getEventSubject();
399 $act_type = $event[
'type'];
400 $act_id = $event[
'identifier'];
401 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
◆ testSetGetIllegalListeningTimeframe()
ilEventDetectorTest::testSetGetIllegalListeningTimeframe |
( |
| ) |
|
ilWorkflowInvalidArgumentException
Definition at line 150 of file ilEventDetectorTest.php.
154 $exp_start = 4712; # +5 Minutes from here.
158 $detector->setListeningTimeframe($exp_start, $exp_end);
159 $act = $detector->getListeningTimeframe();
162 $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 494 of file ilEventDetectorTest.php.
References $params, and array.
498 $evt_type =
'testEvent';
499 $evt_content =
'content';
500 $detector->setEvent($evt_type, $evt_content);
503 $detector->setEventSubject($subj_type, $subj_id);
506 $detector->setEventContext($ctx_type, $ctx_id);
508 $evt_type, $evt_content .
'INVALIDATE',
509 $subj_type, $subj_id,
517 $actual = $detector->getDetectorState();
518 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidContextId()
ilEventDetectorTest::testTriggerInvalidContextId |
( |
| ) |
|
Definition at line 629 of file ilEventDetectorTest.php.
References $params, and array.
633 $evt_type =
'testEvent';
634 $evt_content =
'content';
635 $detector->setEvent($evt_type, $evt_content);
638 $detector->setEventSubject($subj_type, $subj_id);
641 $detector->setEventContext($ctx_type, $ctx_id);
643 $evt_type, $evt_content,
644 $subj_type, $subj_id,
645 $ctx_type, $ctx_id .
'INVALIDATE' 652 $actual = $detector->getDetectorState();
653 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidContextType()
ilEventDetectorTest::testTriggerInvalidContextType |
( |
| ) |
|
Definition at line 602 of file ilEventDetectorTest.php.
References $params, and array.
606 $evt_type =
'testEvent';
607 $evt_content =
'content';
608 $detector->setEvent($evt_type, $evt_content);
611 $detector->setEventSubject($subj_type, $subj_id);
614 $detector->setEventContext($ctx_type, $ctx_id);
616 $evt_type, $evt_content,
617 $subj_type, $subj_id,
618 $ctx_type .
'INVALIDATE', $ctx_id
625 $actual = $detector->getDetectorState();
626 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidSubjectId()
ilEventDetectorTest::testTriggerInvalidSubjectId |
( |
| ) |
|
Definition at line 575 of file ilEventDetectorTest.php.
References $params, and array.
579 $evt_type =
'testEvent';
580 $evt_content =
'content';
581 $detector->setEvent($evt_type, $evt_content);
584 $detector->setEventSubject($subj_type, $subj_id);
587 $detector->setEventContext($ctx_type, $ctx_id);
589 $evt_type, $evt_content,
590 $subj_type, $subj_id .
'INVALIDATE',
598 $actual = $detector->getDetectorState();
599 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidSubjectType()
ilEventDetectorTest::testTriggerInvalidSubjectType |
( |
| ) |
|
Definition at line 548 of file ilEventDetectorTest.php.
References $params, and array.
552 $evt_type =
'testEvent';
553 $evt_content =
'content';
554 $detector->setEvent($evt_type, $evt_content);
557 $detector->setEventSubject($subj_type, $subj_id);
560 $detector->setEventContext($ctx_type, $ctx_id);
562 $evt_type, $evt_content,
563 $subj_type .
'INVALIDATE', $subj_id,
571 $actual = $detector->getDetectorState();
572 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidType()
ilEventDetectorTest::testTriggerInvalidType |
( |
| ) |
|
Definition at line 521 of file ilEventDetectorTest.php.
References $params, and array.
525 $evt_type =
'testEvent';
526 $evt_content =
'content';
527 $detector->setEvent($evt_type, $evt_content);
530 $detector->setEventSubject($subj_type, $subj_id);
533 $detector->setEventContext($ctx_type, $ctx_id);
535 $evt_type .
'INVALIDATE', $evt_content,
536 $subj_type, $subj_id,
544 $actual = $detector->getDetectorState();
545 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerValid()
ilEventDetectorTest::testTriggerValid |
( |
| ) |
|
Definition at line 437 of file ilEventDetectorTest.php.
References $params, and array.
441 $evt_type =
'testEvent';
442 $evt_content =
'content';
443 $detector->setEvent($evt_type, $evt_content);
446 $detector->setEventSubject($subj_type, $subj_id);
449 $detector->setEventContext($ctx_type, $ctx_id);
451 $evt_type, $evt_content,
452 $subj_type, $subj_id,
460 $actual = $detector->getDetectorState();
461 $this->assertTrue($actual);
Create styles array
The data for the language used.
◆ testTriggerValidTwice()
ilEventDetectorTest::testTriggerValidTwice |
( |
| ) |
|
Definition at line 464 of file ilEventDetectorTest.php.
References $params, and array.
468 $evt_type =
'testEvent';
469 $evt_content =
'content';
470 $detector->setEvent($evt_type, $evt_content);
473 $detector->setEventSubject($subj_type, $subj_id);
476 $detector->setEventContext($ctx_type, $ctx_id);
478 $evt_type, $evt_content,
479 $subj_type, $subj_id,
484 $this->assertTrue($detector->trigger(
$params),
'First trigger should receive a true state.');
485 $this->assertFalse($detector->trigger(
$params),
'Second trigger should receive a false state.');
488 $actual = $detector->getDetectorState();
489 $this->assertTrue($actual,
'After satisfaction of the trigger, detectorstate should be true.');
Create styles array
The data for the language used.
◆ testWriteDetectorToDb()
ilEventDetectorTest::testWriteDetectorToDb |
( |
| ) |
|
Definition at line 221 of file ilEventDetectorTest.php.
References $GLOBALS, and array.
223 $this->markTestIncomplete(
224 '$ilDB throws notices during test.' 229 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
230 $ilDB_mock = $this->createMock(
'ilDBMySQL',
array(
'nextID',
'quote',
'insert'),
array(),
'',
false);
232 $ilDB_mock->expects($this->once())->method(
'nextID')->with($this->equalTo(
'wfe_det_listening'))->will($this->returnValue(234));
233 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnArgument(0));
234 $ilDB_mock->expects($this->any())->method(
'insert')->with(
237 'detector_id' =>
array(
'integer', 234),
238 'workflow_id' =>
array(
'integer', null),
239 'type' =>
array(
'text',
'' ),
240 'content' =>
array(
'text',
''),
241 'subject_type' =>
array(
'text',
''),
242 'subject_id' =>
array(
'integer',
''),
243 'context_type' =>
array(
'text',
''),
244 'context_id' =>
array(
'integer',
''),
245 'listening_start' =>
array(
'integer',
'0'),
246 'listening_end' =>
array(
'integer',
'0')
248 )->will($this->returnValue(
true));
251 $stashed_real_object = @
$GLOBALS[
'ilDB'];
255 $detector->writeDetectorToDb();
256 $actual = $detector->hasDbId();
259 $this->assertTrue($actual);
261 $GLOBALS[
'ilDB'] = $stashed_real_object;
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
The documentation for this class was generated from the following file: