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.
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';
◆ tearDown()
ilTimerDetectorTest::tearDown |
( |
| ) |
|
Definition at line 38 of file ilTimerDetectorTest.php.
References $ilSetting.
41 if ($ilSetting != NULL)
43 $ilSetting->delete(
'IL_PHPUNIT_TEST_TIME');
44 $ilSetting->delete(
'IL_PHPUNIT_TEST_MICROTIME');
◆ testConstructorValidContext()
ilTimerDetectorTest::testConstructorValidContext |
( |
| ) |
|
◆ testDeleteDetectorFromDb()
ilTimerDetectorTest::testDeleteDetectorFromDb |
( |
| ) |
|
Definition at line 346 of file ilTimerDetectorTest.php.
References $GLOBALS, and array.
348 $this->markTestIncomplete(
349 '$ilDB throws notices during test.' 355 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
356 $ilDB_mock = $this->getMock(
'ilDBMySQL',
array(
'quote',
'manipulate'),
array(),
'', FALSE);
358 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnValue(234));
359 $ilDB_mock->expects($this->any())->method(
'manipulate')->with(
361 FROM wfe_det_listening 362 WHERE detector_id = 234' 363 )->will($this->returnValue(
true));
365 $stashed_real_object = @
$GLOBALS[
'ilDB'];
369 $detector->setDbId(234);
370 $detector->deleteDetectorFromDb();
371 $actual = $detector->hasDbId();
374 $this->assertFalse($actual);
375 $GLOBALS[
'ilDB'] = $stashed_real_object;
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
◆ testGetContext()
ilTimerDetectorTest::testGetContext |
( |
| ) |
|
Definition at line 503 of file ilTimerDetectorTest.php.
509 $actual = $detector->getContext();
512 if ($actual === $this->node)
514 $this->assertEquals($actual, $this->node);
516 $this->assertTrue(
false,
'Context not identical.');
◆ testGetEvent()
ilTimerDetectorTest::testGetEvent |
( |
| ) |
|
Definition at line 455 of file ilTimerDetectorTest.php.
459 $exp_type =
'time_passed';
460 $exp_content =
'time_passed';
465 $event = $detector->getEvent();
466 $act_type = $event[
'type'];
467 $act_content = $event[
'content'];
468 $this->assertEquals($exp_type.$exp_content, $act_type.$act_content);
◆ testGetEventContext()
ilTimerDetectorTest::testGetEventContext |
( |
| ) |
|
Definition at line 487 of file ilTimerDetectorTest.php.
497 $event = $detector->getEventContext();
498 $act_type = $event[
'type'];
499 $act_id = $event[
'identifier'];
500 $this->assertEquals($exp_type.$exp_id, $act_type.$act_id);
◆ testGetEventSubject()
ilTimerDetectorTest::testGetEventSubject |
( |
| ) |
|
Definition at line 471 of file ilTimerDetectorTest.php.
481 $event = $detector->getEventSubject();
482 $act_type = $event[
'type'];
483 $act_id = $event[
'identifier'];
484 $this->assertEquals($exp_type.$exp_id, $act_type.$act_id);
◆ testGetNonExistingDbId()
ilTimerDetectorTest::testGetNonExistingDbId |
( |
| ) |
|
◆ testHasDbIdSet()
ilTimerDetectorTest::testHasDbIdSet |
( |
| ) |
|
Definition at line 261 of file ilTimerDetectorTest.php.
268 $detector->setDbId($expected);
269 $actual = $detector->hasDbId();
272 $this->assertTrue($actual);
◆ testHasDbIdUnset()
ilTimerDetectorTest::testHasDbIdUnset |
( |
| ) |
|
◆ testIsListeningWithoutTimeFrame()
ilTimerDetectorTest::testIsListeningWithoutTimeFrame |
( |
| ) |
|
Definition at line 155 of file ilTimerDetectorTest.php.
References time.
163 $actual = $detector->isListening();
166 $this->assertTrue($actual,
'Detector should be listening.');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testIsListeningWithPastTimeFrame()
ilTimerDetectorTest::testIsListeningWithPastTimeFrame |
( |
| ) |
|
Definition at line 187 of file ilTimerDetectorTest.php.
References time.
193 $detector->setListeningTimeframe($timer_start, $timer_end);
196 $actual = $detector->isListening();
199 $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()
ilTimerDetectorTest::testIsListeningWithTimeFrame |
( |
| ) |
|
Definition at line 140 of file ilTimerDetectorTest.php.
References time.
146 $detector->setListeningTimeframe($timer_start, $timer_end);
149 $actual = $detector->isListening();
152 $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()
ilTimerDetectorTest::testIsListeningWithWildcardBeginningTimeFrame |
( |
| ) |
|
Definition at line 217 of file ilTimerDetectorTest.php.
References time.
221 $timer_start = 0; # Wildcard.
223 $detector->setListeningTimeframe($timer_start, $timer_end);
226 $actual = $detector->isListening();
229 $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()
ilTimerDetectorTest::testIsListeningWithWildcardEndingTimeFrame |
( |
| ) |
|
Definition at line 202 of file ilTimerDetectorTest.php.
References time.
207 $timer_end = 0; # Wildcard.
208 $detector->setListeningTimeframe($timer_start, $timer_end);
211 $actual = $detector->isListening();
214 $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()
ilTimerDetectorTest::testOnActivate |
( |
| ) |
|
Definition at line 378 of file ilTimerDetectorTest.php.
References $GLOBALS, and array.
380 $this->markTestIncomplete(
381 '$ilDB throws notices during test.' 387 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
388 $ilDB_mock = $this->getMock(
'ilDBMySQL',
array(
'nextID',
'quote',
'insert'),
array(),
'', FALSE);
390 $ilDB_mock->expects($this->once())->method(
'nextID')->with($this->equalTo(
'wfe_det_listening'))->will($this->returnValue(234));
391 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnArgument(0));
392 $ilDB_mock->expects($this->any())->method(
'insert')->with(
395 'detector_id' =>
array (
'integer', 234),
396 'workflow_id' =>
array (
'integer', null),
397 'type' =>
array (
'text',
'time_passed' ),
398 'content' =>
array (
'text',
'time_passed'),
399 'subject_type' =>
array (
'text',
'none'),
400 'subject_id' =>
array (
'integer', 0),
401 'context_type' =>
array (
'text',
'none'),
402 'context_id' =>
array (
'integer', 0),
403 'listening_start' =>
array (
'integer', 0),
404 'listening_end' =>
array (
'integer', 0)
406 )->will($this->returnValue(
true));
408 $stashed_real_object = @
$GLOBALS[
'ilDB'];
412 $detector->onActivate();
413 $actual = $detector->hasDbId();
417 $this->assertTrue($actual);
418 $this->assertEquals(234, $detector->getDbId());
419 $GLOBALS[
'ilDB'] = $stashed_real_object;
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
◆ testOnDeactivate()
ilTimerDetectorTest::testOnDeactivate |
( |
| ) |
|
Definition at line 422 of file ilTimerDetectorTest.php.
References $GLOBALS, and array.
424 $this->markTestIncomplete(
425 '$ilDB throws notices during test.' 431 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
432 $ilDB_mock = $this->getMock(
'ilDBMySQL',
array(
'quote',
'manipulate'),
array(),
'', FALSE);
434 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnValue(234));
435 $ilDB_mock->expects($this->any())->method(
'manipulate')->with(
437 FROM wfe_det_listening 438 WHERE detector_id = 234' 439 )->will($this->returnValue(
true));
441 $stashed_real_object = @
$GLOBALS[
'ilDB'];
445 $detector->setDbId(234);
446 $detector->onDeactivate();
447 $actual = $detector->hasDbId();
450 $this->assertFalse($actual);
452 $GLOBALS[
'ilDB'] = $stashed_real_object;
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
◆ testSetGetDbId()
ilTimerDetectorTest::testSetGetDbId |
( |
| ) |
|
Definition at line 247 of file ilTimerDetectorTest.php.
254 $detector->setDbId($expected);
255 $actual = $detector->getDbId();
258 $this->assertEquals($expected, $actual);
◆ testSetGetIllegalListeningTimeframe()
ilTimerDetectorTest::testSetGetIllegalListeningTimeframe |
( |
| ) |
|
◆ testSetGetListeningTimeframe()
ilTimerDetectorTest::testSetGetListeningTimeframe |
( |
| ) |
|
Definition at line 232 of file ilTimerDetectorTest.php.
236 $exp_start = 4711; # +5 Minutes from here.
240 $detector->setListeningTimeframe($exp_start, $exp_end);
241 $act = $detector->getListeningTimeframe();
244 $this->assertEquals($exp_start.$exp_end, $act[
'listening_start'].$act[
'listening_end']);
◆ testSetGetTimerLimit()
ilTimerDetectorTest::testSetGetTimerLimit |
( |
| ) |
|
Definition at line 75 of file ilTimerDetectorTest.php.
82 $detector->setTimerLimit($expected);
83 $actual = $detector->getTimerLimit();
86 $this->assertEquals($actual, $expected);
◆ testSetGetTimerStart()
ilTimerDetectorTest::testSetGetTimerStart |
( |
| ) |
|
Definition at line 61 of file ilTimerDetectorTest.php.
References time.
68 $detector->setTimerStart($expected);
69 $actual = $detector->getTimerStart();
72 $this->assertEquals($actual, $expected);
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testTriggerEarly()
ilTimerDetectorTest::testTriggerEarly |
( |
| ) |
|
Definition at line 89 of file ilTimerDetectorTest.php.
References time.
95 $detector->setTimerStart($timer_start);
96 $detector->setTimerLimit($timer_limit);
99 $detector->trigger(null);
102 $actual = $detector->getDetectorState();
103 $this->assertFalse($actual,
'Early trigger should not satisfy detector');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testTriggerValid()
ilTimerDetectorTest::testTriggerValid |
( |
| ) |
|
Definition at line 106 of file ilTimerDetectorTest.php.
References time.
112 $detector->setTimerStart($timer_start);
113 $detector->setTimerLimit($timer_limit);
116 $detector->trigger(null);
119 $actual = $detector->getDetectorState();
120 $this->assertTrue($actual,
'Trigger should not satisfy detector');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testTriggerValidTwice()
ilTimerDetectorTest::testTriggerValidTwice |
( |
| ) |
|
Definition at line 123 of file ilTimerDetectorTest.php.
References time.
129 $detector->setTimerStart($timer_start);
130 $detector->setTimerLimit($timer_limit);
133 $detector->trigger(null);
134 $actual = $detector->trigger(null);
137 $this->assertFalse($actual,
'Detector should be satisfied after single trigger');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testWriteDetectorToDb()
ilTimerDetectorTest::testWriteDetectorToDb |
( |
| ) |
|
Definition at line 303 of file ilTimerDetectorTest.php.
References $GLOBALS, and array.
305 $this->markTestIncomplete(
306 '$ilDB throws notices during test.' 312 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
313 $ilDB_mock = $this->getMock(
'ilDBMySQL',
array(
'nextID',
'quote',
'insert'),
array(),
'', FALSE);
315 $ilDB_mock->expects($this->once())->method(
'nextID')->with($this->equalTo(
'wfe_det_listening'))->will($this->returnValue(234));
316 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnArgument(0));
317 $ilDB_mock->expects($this->any())->method(
'insert')->with(
320 'detector_id' =>
array (
'integer', 234),
321 'workflow_id' =>
array (
'integer', null),
322 'type' =>
array (
'text',
'time_passed' ),
323 'content' =>
array (
'text',
'time_passed'),
324 'subject_type' =>
array (
'text',
'none'),
325 'subject_id' =>
array (
'integer', 0),
326 'context_type' =>
array (
'text',
'none'),
327 'context_id' =>
array (
'integer', 0),
328 'listening_start' =>
array (
'integer', 0),
329 'listening_end' =>
array (
'integer', 0)
331 )->will($this->returnValue(
true));
334 $stashed_real_object = @
$GLOBALS[
'ilDB'];
336 $detector->writeDetectorToDb();
338 $actual = $detector->hasDbId();
341 $this->assertTrue($actual);
343 $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: