ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilWorkflowEngineBaseTest
 setGlobalVariable ($name, $value)
 
 setUp ()
 

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 ( )

Reimplemented from ilWorkflowEngineBaseTest.

Definition at line 17 of file ilCounterDetectorTest.php.

17 : void
18 {
20
21 // Empty workflow.
22 require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
23 $this->workflow = new ilEmptyWorkflow();
24
25 // Basic node
26 require_once './Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
27 $this->node = new ilBasicNode($this->workflow);
28
29 // Wiring up so the node is attached to the workflow.
30 $this->workflow->addNode($this->node);
31
32 require_once './Services/WorkflowEngine/classes/detectors/class.ilCounterDetector.php';
33 }
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ tearDown()

ilCounterDetectorTest::tearDown ( )

Definition at line 35 of file ilCounterDetectorTest.php.

35 : void
36 {
37 global $DIC;
38
39 if (isset($DIC['ilSetting'])) {
40 $DIC['ilSetting']->delete('IL_PHPUNIT_TEST_TIME');
41 $DIC['ilSetting']->delete('IL_PHPUNIT_TEST_MICROTIME');
42 }
43 }
$DIC
Definition: xapitoken.php:46

References $DIC.

◆ 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: