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)
43 $ilSetting->delete(
'IL_PHPUNIT_TEST_TIME');
44 $ilSetting->delete(
'IL_PHPUNIT_TEST_MICROTIME');
◆ testConstructorValidContext()
ilEventDetectorTest::testConstructorValidContext |
( |
| ) |
|
◆ testDeleteDetectorFromDb()
ilEventDetectorTest::testDeleteDetectorFromDb |
( |
| ) |
|
Definition at line 265 of file ilEventDetectorTest.php.
References $GLOBALS, and array.
267 $this->markTestIncomplete(
268 '$ilDB throws notices during test.' 273 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
274 $ilDB_mock = $this->getMock(
'ilDBMySQL',
array(
'quote',
'manipulate'),
array(),
'', FALSE);
276 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnValue(234));
277 $ilDB_mock->expects($this->any())->method(
'manipulate')->with(
279 FROM wfe_det_listening 280 WHERE detector_id = 234' 281 )->will($this->returnValue(
true));
283 $stashed_real_object = @
$GLOBALS[
'ilDB'];
287 $detector->setDbId(234);
288 $detector->deleteDetectorFromDb();
289 $actual = $detector->hasDbId();
292 $this->assertFalse($actual);
293 $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 422 of file ilEventDetectorTest.php.
428 $actual = $detector->getContext();
431 if ($actual === $this->node)
433 $this->assertEquals($actual, $this->node);
435 $this->assertTrue(
false,
'Context not identical.');
◆ testGetNonExistingDbId()
ilEventDetectorTest::testGetNonExistingDbId |
( |
| ) |
|
◆ testHasDbIdSet()
ilEventDetectorTest::testHasDbIdSet |
( |
| ) |
|
Definition at line 196 of file ilEventDetectorTest.php.
203 $detector->setDbId($expected);
204 $actual = $detector->hasDbId();
207 $this->assertTrue($actual);
◆ testHasDbIdUnset()
ilEventDetectorTest::testHasDbIdUnset |
( |
| ) |
|
◆ testIsListeningWithoutTimeFrame()
ilEventDetectorTest::testIsListeningWithoutTimeFrame |
( |
| ) |
|
Definition at line 121 of file ilEventDetectorTest.php.
127 $actual = $detector->isListening();
130 $this->assertTrue($actual,
'Detector should be listening.');
◆ testIsListeningWithPastTimeFrame()
ilEventDetectorTest::testIsListeningWithPastTimeFrame |
( |
| ) |
|
Definition at line 76 of file ilEventDetectorTest.php.
References time.
82 $detector->setListeningTimeframe($timer_start, $timer_end);
85 $actual = $detector->isListening();
88 $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 61 of file ilEventDetectorTest.php.
References time.
67 $detector->setListeningTimeframe($timer_start, $timer_end);
70 $actual = $detector->isListening();
73 $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 106 of file ilEventDetectorTest.php.
References time.
110 $timer_start = 0; # Wildcard.
112 $detector->setListeningTimeframe($timer_start, $timer_end);
115 $actual = $detector->isListening();
118 $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 91 of file ilEventDetectorTest.php.
References time.
96 $timer_end = 0; # Wildcard.
97 $detector->setListeningTimeframe($timer_start, $timer_end);
100 $actual = $detector->isListening();
103 $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 296 of file ilEventDetectorTest.php.
References $GLOBALS, and array.
298 $this->markTestIncomplete(
299 '$ilDB throws notices during test.' 304 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
305 $ilDB_mock = $this->getMock(
'ilDBMySQL',
array(
'nextID',
'quote',
'insert'),
array(),
'', FALSE);
307 $ilDB_mock->expects($this->once())->method(
'nextID')->with($this->equalTo(
'wfe_det_listening'))->will($this->returnValue(234));
308 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnArgument(0));
309 $ilDB_mock->expects($this->any())->method(
'insert')->with(
312 'detector_id' =>
array (
'integer', 234),
313 'workflow_id' =>
array (
'integer', null),
314 'type' =>
array (
'text',
'' ),
315 'content' =>
array (
'text',
''),
316 'subject_type' =>
array (
'text',
''),
317 'subject_id' =>
array (
'integer',
''),
318 'context_type' =>
array (
'text',
''),
319 'context_id' =>
array (
'integer',
''),
320 'listening_start' =>
array (
'integer', 0),
321 'listening_end' =>
array (
'integer', 0)
323 )->will($this->returnValue(
true));
325 $stashed_real_object = @
$GLOBALS[
'ilDB'];
329 $detector->onActivate();
330 $actual = $detector->hasDbId();
333 $this->assertTrue($actual);
334 $this->assertEquals(234, $detector->getDbId());
335 $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 338 of file ilEventDetectorTest.php.
References $GLOBALS, and array.
340 $this->markTestIncomplete(
341 '$ilDB throws notices during test.' 347 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
348 $ilDB_mock = $this->getMock(
'ilDBMySQL',
array(
'quote',
'manipulate'),
array(),
'', FALSE);
350 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnValue(234));
351 $ilDB_mock->expects($this->any())->method(
'manipulate')->with(
353 FROM wfe_det_listening 354 WHERE detector_id = 234' 355 )->will($this->returnValue(
true));
357 $stashed_real_object = @
$GLOBALS[
'ilDB'];
361 $detector->setDbId(234);
362 $detector->onDeactivate();
363 $actual = $detector->hasDbId();
366 $this->assertFalse($actual);
368 $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 166 of file ilEventDetectorTest.php.
173 $detector->setDbId($expected);
174 $actual = $detector->getDbId();
177 $this->assertEquals($expected, $actual);
◆ testSetGetEvent()
ilEventDetectorTest::testSetGetEvent |
( |
| ) |
|
Definition at line 371 of file ilEventDetectorTest.php.
375 $exp_type =
'time_passed';
376 $exp_content =
'time_passed';
379 $detector->setEvent($exp_type, $exp_content);
382 $event = $detector->getEvent();
383 $act_type = $event[
'type'];
384 $act_content = $event[
'content'];
385 $this->assertEquals($exp_type.$exp_content, $act_type.$act_content);
◆ testSetGetEventContext()
ilEventDetectorTest::testSetGetEventContext |
( |
| ) |
|
Definition at line 405 of file ilEventDetectorTest.php.
413 $detector->setEventContext($exp_type, $exp_id);
416 $event = $detector->getEventContext();
417 $act_type = $event[
'type'];
418 $act_id = $event[
'identifier'];
419 $this->assertEquals($exp_type.$exp_id, $act_type.$act_id);
◆ testSetGetEventSubject()
ilEventDetectorTest::testSetGetEventSubject |
( |
| ) |
|
Definition at line 388 of file ilEventDetectorTest.php.
396 $detector->setEventSubject($exp_type, $exp_id);
399 $event = $detector->getEventSubject();
400 $act_type = $event[
'type'];
401 $act_id = $event[
'identifier'];
402 $this->assertEquals($exp_type.$exp_id, $act_type.$act_id);
◆ testSetGetIllegalListeningTimeframe()
ilEventDetectorTest::testSetGetIllegalListeningTimeframe |
( |
| ) |
|
ilWorkflowInvalidArgumentException
Definition at line 151 of file ilEventDetectorTest.php.
155 $exp_start = 4712; # +5 Minutes from here.
159 $detector->setListeningTimeframe($exp_start, $exp_end);
160 $act = $detector->getListeningTimeframe();
163 $this->assertEquals($exp_start.$exp_end, $act[
'listening_start'].$act[
'listening_end']);
◆ testSetGetListeningTimeframe()
ilEventDetectorTest::testSetGetListeningTimeframe |
( |
| ) |
|
Definition at line 133 of file ilEventDetectorTest.php.
141 $detector->setListeningTimeframe($exp_start, $exp_end);
142 $act = $detector->getListeningTimeframe();
145 $this->assertEquals($exp_start.$exp_end, $act[
'listening_start'].$act[
'listening_end']);
◆ testTriggerInvalidContent()
ilEventDetectorTest::testTriggerInvalidContent |
( |
| ) |
|
Definition at line 496 of file ilEventDetectorTest.php.
References $params, and array.
500 $evt_type =
'testEvent';
501 $evt_content =
'content';
502 $detector->setEvent($evt_type, $evt_content);
505 $detector->setEventSubject($subj_type, $subj_id);
508 $detector->setEventContext($ctx_type, $ctx_id);
510 $evt_type, $evt_content.
'INVALIDATE',
511 $subj_type, $subj_id,
519 $actual = $detector->getDetectorState();
520 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidContextId()
ilEventDetectorTest::testTriggerInvalidContextId |
( |
| ) |
|
Definition at line 631 of file ilEventDetectorTest.php.
References $params, and array.
635 $evt_type =
'testEvent';
636 $evt_content =
'content';
637 $detector->setEvent($evt_type, $evt_content);
640 $detector->setEventSubject($subj_type, $subj_id);
643 $detector->setEventContext($ctx_type, $ctx_id);
645 $evt_type, $evt_content,
646 $subj_type, $subj_id,
647 $ctx_type, $ctx_id.
'INVALIDATE' 654 $actual = $detector->getDetectorState();
655 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidContextType()
ilEventDetectorTest::testTriggerInvalidContextType |
( |
| ) |
|
Definition at line 604 of file ilEventDetectorTest.php.
References $params, and array.
608 $evt_type =
'testEvent';
609 $evt_content =
'content';
610 $detector->setEvent($evt_type, $evt_content);
613 $detector->setEventSubject($subj_type, $subj_id);
616 $detector->setEventContext($ctx_type, $ctx_id);
618 $evt_type, $evt_content,
619 $subj_type, $subj_id,
620 $ctx_type.
'INVALIDATE', $ctx_id
627 $actual = $detector->getDetectorState();
628 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidSubjectId()
ilEventDetectorTest::testTriggerInvalidSubjectId |
( |
| ) |
|
Definition at line 577 of file ilEventDetectorTest.php.
References $params, and array.
581 $evt_type =
'testEvent';
582 $evt_content =
'content';
583 $detector->setEvent($evt_type, $evt_content);
586 $detector->setEventSubject($subj_type, $subj_id);
589 $detector->setEventContext($ctx_type, $ctx_id);
591 $evt_type, $evt_content,
592 $subj_type, $subj_id.
'INVALIDATE',
600 $actual = $detector->getDetectorState();
601 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidSubjectType()
ilEventDetectorTest::testTriggerInvalidSubjectType |
( |
| ) |
|
Definition at line 550 of file ilEventDetectorTest.php.
References $params, and array.
554 $evt_type =
'testEvent';
555 $evt_content =
'content';
556 $detector->setEvent($evt_type, $evt_content);
559 $detector->setEventSubject($subj_type, $subj_id);
562 $detector->setEventContext($ctx_type, $ctx_id);
564 $evt_type, $evt_content,
565 $subj_type.
'INVALIDATE', $subj_id,
573 $actual = $detector->getDetectorState();
574 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerInvalidType()
ilEventDetectorTest::testTriggerInvalidType |
( |
| ) |
|
Definition at line 523 of file ilEventDetectorTest.php.
References $params, and array.
527 $evt_type =
'testEvent';
528 $evt_content =
'content';
529 $detector->setEvent($evt_type, $evt_content);
532 $detector->setEventSubject($subj_type, $subj_id);
535 $detector->setEventContext($ctx_type, $ctx_id);
537 $evt_type.
'INVALIDATE', $evt_content,
538 $subj_type, $subj_id,
546 $actual = $detector->getDetectorState();
547 $this->assertFalse($actual);
Create styles array
The data for the language used.
◆ testTriggerValid()
ilEventDetectorTest::testTriggerValid |
( |
| ) |
|
Definition at line 439 of file ilEventDetectorTest.php.
References $params, and array.
443 $evt_type =
'testEvent';
444 $evt_content =
'content';
445 $detector->setEvent($evt_type, $evt_content);
448 $detector->setEventSubject($subj_type, $subj_id);
451 $detector->setEventContext($ctx_type, $ctx_id);
453 $evt_type, $evt_content,
454 $subj_type, $subj_id,
462 $actual = $detector->getDetectorState();
463 $this->assertTrue($actual);
Create styles array
The data for the language used.
◆ testTriggerValidTwice()
ilEventDetectorTest::testTriggerValidTwice |
( |
| ) |
|
Definition at line 466 of file ilEventDetectorTest.php.
References $params, and array.
470 $evt_type =
'testEvent';
471 $evt_content =
'content';
472 $detector->setEvent($evt_type, $evt_content);
475 $detector->setEventSubject($subj_type, $subj_id);
478 $detector->setEventContext($ctx_type, $ctx_id);
480 $evt_type, $evt_content,
481 $subj_type, $subj_id,
486 $this->assertTrue($detector->trigger(
$params),
'First trigger should receive a true state.');
487 $this->assertFalse($detector->trigger(
$params),
'Second trigger should receive a false state.');
490 $actual = $detector->getDetectorState();
491 $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 222 of file ilEventDetectorTest.php.
References $GLOBALS, and array.
224 $this->markTestIncomplete(
225 '$ilDB throws notices during test.' 230 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
231 $ilDB_mock = $this->getMock(
'ilDBMySQL',
array(
'nextID',
'quote',
'insert'),
array(),
'', FALSE);
233 $ilDB_mock->expects($this->once())->method(
'nextID')->with($this->equalTo(
'wfe_det_listening'))->will($this->returnValue(234));
234 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnArgument(0));
235 $ilDB_mock->expects($this->any())->method(
'insert')->with(
238 'detector_id' =>
array (
'integer', 234),
239 'workflow_id' =>
array (
'integer', null),
240 'type' =>
array (
'text',
'' ),
241 'content' =>
array (
'text',
''),
242 'subject_type' =>
array (
'text',
''),
243 'subject_id' =>
array (
'integer',
''),
244 'context_type' =>
array (
'text',
''),
245 'context_id' =>
array (
'integer',
''),
246 'listening_start' =>
array (
'integer',
'0'),
247 'listening_end' =>
array (
'integer',
'0')
249 )->will($this->returnValue(
true));
252 $stashed_real_object = @
$GLOBALS[
'ilDB'];
256 $detector->writeDetectorToDb();
257 $actual = $detector->hasDbId();
260 $this->assertTrue($actual);
262 $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: