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) {
42 $ilSetting->delete(
'IL_PHPUNIT_TEST_TIME');
43 $ilSetting->delete(
'IL_PHPUNIT_TEST_MICROTIME');
◆ testConstructorValidContext()
ilTimerDetectorTest::testConstructorValidContext |
( |
| ) |
|
◆ testDeleteDetectorFromDb()
ilTimerDetectorTest::testDeleteDetectorFromDb |
( |
| ) |
|
Definition at line 345 of file ilTimerDetectorTest.php.
References $GLOBALS, and array.
347 $this->markTestIncomplete(
348 '$ilDB throws notices during test.' 354 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
355 $ilDB_mock = $this->createMock(
'ilDBMySQL',
array(
'quote',
'manipulate'),
array(),
'',
false);
357 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnValue(234));
358 $ilDB_mock->expects($this->any())->method(
'manipulate')->with(
360 FROM wfe_det_listening 361 WHERE detector_id = 234' 362 )->will($this->returnValue(
true));
364 $stashed_real_object = @
$GLOBALS[
'ilDB'];
368 $detector->setDbId(234);
369 $detector->deleteDetectorFromDb();
370 $actual = $detector->hasDbId();
373 $this->assertFalse($actual);
374 $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 502 of file ilTimerDetectorTest.php.
508 $actual = $detector->getContext();
511 if ($actual === $this->node) {
512 $this->assertEquals($actual, $this->node);
514 $this->assertTrue(
false,
'Context not identical.');
◆ testGetEvent()
ilTimerDetectorTest::testGetEvent |
( |
| ) |
|
Definition at line 454 of file ilTimerDetectorTest.php.
458 $exp_type =
'time_passed';
459 $exp_content =
'time_passed';
464 $event = $detector->getEvent();
465 $act_type = $event[
'type'];
466 $act_content = $event[
'content'];
467 $this->assertEquals($exp_type . $exp_content, $act_type . $act_content);
◆ testGetEventContext()
ilTimerDetectorTest::testGetEventContext |
( |
| ) |
|
Definition at line 486 of file ilTimerDetectorTest.php.
496 $event = $detector->getEventContext();
497 $act_type = $event[
'type'];
498 $act_id = $event[
'identifier'];
499 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
◆ testGetEventSubject()
ilTimerDetectorTest::testGetEventSubject |
( |
| ) |
|
Definition at line 470 of file ilTimerDetectorTest.php.
480 $event = $detector->getEventSubject();
481 $act_type = $event[
'type'];
482 $act_id = $event[
'identifier'];
483 $this->assertEquals($exp_type . $exp_id, $act_type . $act_id);
◆ testGetNonExistingDbId()
ilTimerDetectorTest::testGetNonExistingDbId |
( |
| ) |
|
◆ testHasDbIdSet()
ilTimerDetectorTest::testHasDbIdSet |
( |
| ) |
|
Definition at line 260 of file ilTimerDetectorTest.php.
267 $detector->setDbId($expected);
268 $actual = $detector->hasDbId();
271 $this->assertTrue($actual);
◆ testHasDbIdUnset()
ilTimerDetectorTest::testHasDbIdUnset |
( |
| ) |
|
◆ testIsListeningWithoutTimeFrame()
ilTimerDetectorTest::testIsListeningWithoutTimeFrame |
( |
| ) |
|
Definition at line 154 of file ilTimerDetectorTest.php.
References time.
162 $actual = $detector->isListening();
165 $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 186 of file ilTimerDetectorTest.php.
References time.
192 $detector->setListeningTimeframe($timer_start, $timer_end);
195 $actual = $detector->isListening();
198 $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 139 of file ilTimerDetectorTest.php.
References time.
145 $detector->setListeningTimeframe($timer_start, $timer_end);
148 $actual = $detector->isListening();
151 $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 216 of file ilTimerDetectorTest.php.
References time.
220 $timer_start = 0; # Wildcard.
222 $detector->setListeningTimeframe($timer_start, $timer_end);
225 $actual = $detector->isListening();
228 $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 201 of file ilTimerDetectorTest.php.
References time.
206 $timer_end = 0; # Wildcard.
207 $detector->setListeningTimeframe($timer_start, $timer_end);
210 $actual = $detector->isListening();
213 $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 377 of file ilTimerDetectorTest.php.
References $GLOBALS, and array.
379 $this->markTestIncomplete(
380 '$ilDB throws notices during test.' 386 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
387 $ilDB_mock = $this->createMock(
'ilDBMySQL',
array(
'nextID',
'quote',
'insert'),
array(),
'',
false);
389 $ilDB_mock->expects($this->once())->method(
'nextID')->with($this->equalTo(
'wfe_det_listening'))->will($this->returnValue(234));
390 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnArgument(0));
391 $ilDB_mock->expects($this->any())->method(
'insert')->with(
394 'detector_id' =>
array(
'integer', 234),
395 'workflow_id' =>
array(
'integer', null),
396 'type' =>
array(
'text',
'time_passed' ),
397 'content' =>
array(
'text',
'time_passed'),
398 'subject_type' =>
array(
'text',
'none'),
399 'subject_id' =>
array(
'integer', 0),
400 'context_type' =>
array(
'text',
'none'),
401 'context_id' =>
array(
'integer', 0),
402 'listening_start' =>
array(
'integer', 0),
403 'listening_end' =>
array(
'integer', 0)
405 )->will($this->returnValue(
true));
407 $stashed_real_object = @
$GLOBALS[
'ilDB'];
411 $detector->onActivate();
412 $actual = $detector->hasDbId();
416 $this->assertTrue($actual);
417 $this->assertEquals(234, $detector->getDbId());
418 $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 421 of file ilTimerDetectorTest.php.
References $GLOBALS, and array.
423 $this->markTestIncomplete(
424 '$ilDB throws notices during test.' 430 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
431 $ilDB_mock = $this->createMock(
'ilDBMySQL',
array(
'quote',
'manipulate'),
array(),
'',
false);
433 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnValue(234));
434 $ilDB_mock->expects($this->any())->method(
'manipulate')->with(
436 FROM wfe_det_listening 437 WHERE detector_id = 234' 438 )->will($this->returnValue(
true));
440 $stashed_real_object = @
$GLOBALS[
'ilDB'];
444 $detector->setDbId(234);
445 $detector->onDeactivate();
446 $actual = $detector->hasDbId();
449 $this->assertFalse($actual);
451 $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 246 of file ilTimerDetectorTest.php.
253 $detector->setDbId($expected);
254 $actual = $detector->getDbId();
257 $this->assertEquals($expected, $actual);
◆ testSetGetIllegalListeningTimeframe()
ilTimerDetectorTest::testSetGetIllegalListeningTimeframe |
( |
| ) |
|
◆ testSetGetListeningTimeframe()
ilTimerDetectorTest::testSetGetListeningTimeframe |
( |
| ) |
|
Definition at line 231 of file ilTimerDetectorTest.php.
235 $exp_start = 4711; # +5 Minutes from here.
239 $detector->setListeningTimeframe($exp_start, $exp_end);
240 $act = $detector->getListeningTimeframe();
243 $this->assertEquals($exp_start . $exp_end, $act[
'listening_start'] . $act[
'listening_end']);
◆ testSetGetTimerLimit()
ilTimerDetectorTest::testSetGetTimerLimit |
( |
| ) |
|
Definition at line 74 of file ilTimerDetectorTest.php.
81 $detector->setTimerLimit($expected);
82 $actual = $detector->getTimerLimit();
85 $this->assertEquals($actual, $expected);
◆ testSetGetTimerStart()
ilTimerDetectorTest::testSetGetTimerStart |
( |
| ) |
|
Definition at line 60 of file ilTimerDetectorTest.php.
References time.
67 $detector->setTimerStart($expected);
68 $actual = $detector->getTimerStart();
71 $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 88 of file ilTimerDetectorTest.php.
References time.
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');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testTriggerValid()
ilTimerDetectorTest::testTriggerValid |
( |
| ) |
|
Definition at line 105 of file ilTimerDetectorTest.php.
References time.
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');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testTriggerValidTwice()
ilTimerDetectorTest::testTriggerValidTwice |
( |
| ) |
|
Definition at line 122 of file ilTimerDetectorTest.php.
References time.
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');
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ testWriteDetectorToDb()
ilTimerDetectorTest::testWriteDetectorToDb |
( |
| ) |
|
Definition at line 302 of file ilTimerDetectorTest.php.
References $GLOBALS, and array.
304 $this->markTestIncomplete(
305 '$ilDB throws notices during test.' 311 require_once
'./Services/Database/classes/class.ilDBMySQL.php';
312 $ilDB_mock = $this->createMock(
'ilDBMySQL',
array(
'nextID',
'quote',
'insert'),
array(),
'',
false);
314 $ilDB_mock->expects($this->once())->method(
'nextID')->with($this->equalTo(
'wfe_det_listening'))->will($this->returnValue(234));
315 $ilDB_mock->expects($this->any())->method(
'quote')->will($this->returnArgument(0));
316 $ilDB_mock->expects($this->any())->method(
'insert')->with(
319 'detector_id' =>
array(
'integer', 234),
320 'workflow_id' =>
array(
'integer', null),
321 'type' =>
array(
'text',
'time_passed' ),
322 'content' =>
array(
'text',
'time_passed'),
323 'subject_type' =>
array(
'text',
'none'),
324 'subject_id' =>
array(
'integer', 0),
325 'context_type' =>
array(
'text',
'none'),
326 'context_id' =>
array(
'integer', 0),
327 'listening_start' =>
array(
'integer', 0),
328 'listening_end' =>
array(
'integer', 0)
330 )->will($this->returnValue(
true));
333 $stashed_real_object = @
$GLOBALS[
'ilDB'];
335 $detector->writeDetectorToDb();
337 $actual = $detector->hasDbId();
340 $this->assertTrue($actual);
342 $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: