ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCounterDetectorTest Class Reference

ilCounterDetectorTest is part of the petri net based workflow engine. More...

+ Inheritance diagram for ilCounterDetectorTest:
+ Collaboration diagram for ilCounterDetectorTest:

Public Member Functions

 setUp ()
 
 tearDown ()
 
 testConstructorValidContext ()
 
 testSetGetExpectedTriggerEvents ()
 
 testSetGetActualTriggerEvents ()
 
 testTriggerUnsatisfy ()
 
 testTriggerSatisfy ()
 
 testTriggerOversatisfy ()
 
 testGetContext ()
 

Detailed Description

ilCounterDetectorTest is part of the petri net based workflow engine.

This class holds all tests for the class detectors/class.ilCounterDetector

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

/

Definition at line 15 of file ilCounterDetectorTest.php.

Member Function Documentation

◆ setUp()

ilCounterDetectorTest::setUp ( )

Definition at line 17 of file ilCounterDetectorTest.php.

18 {
19 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20 //ilUnitUtil::performInitialisation();
21
22 // Empty workflow.
23 require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
24 $this->workflow = new ilEmptyWorkflow();
25
26 // Basic node
27 require_once './Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
28 $this->node = new ilBasicNode($this->workflow);
29
30 // Wiring up so the node is attached to the workflow.
31 $this->workflow->addNode($this->node);
32
33 require_once './Services/WorkflowEngine/classes/detectors/class.ilCounterDetector.php';
34 }
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection

◆ tearDown()

ilCounterDetectorTest::tearDown ( )

Definition at line 36 of file ilCounterDetectorTest.php.

37 {
38 global $ilSetting;
39 if ($ilSetting != null) {
40 $ilSetting->delete('IL_PHPUNIT_TEST_TIME');
41 $ilSetting->delete('IL_PHPUNIT_TEST_MICROTIME');
42 }
43 }
global $ilSetting
Definition: privfeed.php:17

References $ilSetting.

◆ testConstructorValidContext()

ilCounterDetectorTest::testConstructorValidContext ( )

Definition at line 45 of file ilCounterDetectorTest.php.

46 {
47 // Act
48 $detector = new ilCounterDetector($this->node);
49
50 // Assert
51 // No exception - good
52 $this->assertTrue(
53 true,
54 'Construction failed with valid context passed to constructor.'
55 );
56 }
@noinspection PhpIncludeInspection

◆ testGetContext()

ilCounterDetectorTest::testGetContext ( )

Definition at line 155 of file ilCounterDetectorTest.php.

156 {
157 // Arrange
158 $detector = new ilCounterDetector($this->node);
159
160 // Act
161 $actual = $detector->getContext();
162
163 // Assert
164 if ($actual === $this->node) {
165 $this->assertEquals($actual, $this->node);
166 } else {
167 $this->assertTrue(false, 'Context not identical.');
168 }
169 }

◆ testSetGetActualTriggerEvents()

ilCounterDetectorTest::testSetGetActualTriggerEvents ( )

Definition at line 72 of file ilCounterDetectorTest.php.

73 {
74 // Arrange
75 $detector = new ilCounterDetector($this->node);
76 $expected = 4711;
77
78 // Act
79 $detector->setActualTriggerEvents($expected);
80 $actual = $detector->getActualTriggerEvents();
81
82 // Assert
83 $this->assertEquals($actual, $expected);
84 }

◆ testSetGetExpectedTriggerEvents()

ilCounterDetectorTest::testSetGetExpectedTriggerEvents ( )

Definition at line 58 of file ilCounterDetectorTest.php.

59 {
60 // Arrange
61 $detector = new ilCounterDetector($this->node);
62 $expected = 4711;
63
64 // Act
65 $detector->setExpectedTriggerEvents($expected);
66 $actual = $detector->getExpectedTriggerEvents();
67
68 // Assert
69 $this->assertEquals($actual, $expected);
70 }

◆ testTriggerOversatisfy()

ilCounterDetectorTest::testTriggerOversatisfy ( )

Definition at line 142 of file ilCounterDetectorTest.php.

143 {
144 // Arrange
145 $detector = new ilCounterDetector($this->node);
146 $expected = 2;
147 $detector->setExpectedTriggerEvents($expected);
148
149 // Act & Assert
150 $this->assertTrue($detector->trigger(null));
151 $this->assertTrue($detector->trigger(null));
152 $this->assertFalse($detector->trigger(null));
153 }

◆ testTriggerSatisfy()

ilCounterDetectorTest::testTriggerSatisfy ( )

Definition at line 113 of file ilCounterDetectorTest.php.

114 {
115 // Arrange
116 $detector = new ilCounterDetector($this->node);
117 $expected = 2;
118 $detector->setExpectedTriggerEvents($expected);
119
120 // Act
121 $detector->trigger(null);
122 $detector->trigger(null);
123
124 // Assert
125 $valid_state = true;
126
127 if ($detector->getActualTriggerEvents() != 2) {
128 $valid_state = false;
129 }
130
131 if ($detector->getExpectedTriggerEvents() != $expected) {
132 $valid_state = false;
133 }
134
135 if (!$detector->getDetectorState()) {
136 $valid_state = false;
137 }
138
139 $this->assertTrue($valid_state, 'Detector state invalid.');
140 }

◆ testTriggerUnsatisfy()

ilCounterDetectorTest::testTriggerUnsatisfy ( )

Definition at line 86 of file ilCounterDetectorTest.php.

87 {
88 // Arrange
89 $detector = new ilCounterDetector($this->node);
90 $expected = 2;
91 $detector->setExpectedTriggerEvents($expected);
92
93 // Act
94 $detector->trigger(null);
95
96 // Assert
97 $valid_state = true;
98 if ($detector->getActualTriggerEvents() != 1) {
99 $valid_state = false;
100 }
101
102 if ($detector->getExpectedTriggerEvents() != $expected) {
103 $valid_state = false;
104 }
105
106 if ($detector->getDetectorState()) {
107 $valid_state = false;
108 }
109
110 $this->assertTrue($valid_state, 'Detector state invalid.');
111 }

The documentation for this class was generated from the following file: