ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  }
PhpIncludeInspection
PhpIncludeInspection

◆ tearDown()

ilCounterDetectorTest::tearDown ( )

Definition at line 36 of file ilCounterDetectorTest.php.

References $ilSetting.

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

◆ testConstructorValidContext()

ilCounterDetectorTest::testConstructorValidContext ( )

Definition at line 46 of file ilCounterDetectorTest.php.

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

◆ testGetContext()

ilCounterDetectorTest::testGetContext ( )

Definition at line 162 of file ilCounterDetectorTest.php.

163  {
164  // Arrange
165  $detector = new ilCounterDetector($this->node);
166 
167  // Act
168  $actual = $detector->getContext();
169 
170  // Assert
171  if ($actual === $this->node)
172  {
173  $this->assertEquals($actual, $this->node);
174  } else {
175  $this->assertTrue(false, 'Context not identical.');
176  }
177  }
PhpIncludeInspection

◆ testSetGetActualTriggerEvents()

ilCounterDetectorTest::testSetGetActualTriggerEvents ( )

Definition at line 73 of file ilCounterDetectorTest.php.

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

◆ testSetGetExpectedTriggerEvents()

ilCounterDetectorTest::testSetGetExpectedTriggerEvents ( )

Definition at line 59 of file ilCounterDetectorTest.php.

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

◆ testTriggerOversatisfy()

ilCounterDetectorTest::testTriggerOversatisfy ( )

Definition at line 149 of file ilCounterDetectorTest.php.

150  {
151  // Arrange
152  $detector = new ilCounterDetector($this->node);
153  $expected = 2;
154  $detector->setExpectedTriggerEvents($expected);
155 
156  // Act & Assert
157  $this->assertTrue($detector->trigger(null));
158  $this->assertTrue($detector->trigger(null));
159  $this->assertFalse($detector->trigger(null));
160  }
PhpIncludeInspection

◆ testTriggerSatisfy()

ilCounterDetectorTest::testTriggerSatisfy ( )

Definition at line 117 of file ilCounterDetectorTest.php.

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

◆ testTriggerUnsatisfy()

ilCounterDetectorTest::testTriggerUnsatisfy ( )

Definition at line 87 of file ilCounterDetectorTest.php.

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

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