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

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

+ Inheritance diagram for ilCaseNodeTest:
+ Collaboration diagram for ilCaseNodeTest:

Public Member Functions

 setUp ()
 
 tearDown ()
 
 testConstructorValidContext ()
 
 testGetContext ()
 
 testIsActiveAndActivate ()
 
 testDeactivate ()
 
 testCheckTransitionPreconditionsValid ()
 
 testCheckTransitionPreconditionsValidOnExclusiveJoin ()
 
 testNotifyDetectorSatisfactionAndTransit ()
 
 testCheckTransitionPreconditionsInvalid ()
 
 testAttemptTransitionPreconditionsValidOnExclusiveJoin ()
 
 testExecuteTransition ()
 
 testExecuteTransitionExclusiveFork ()
 
 testExecuteActivitiesViaExecuteTransition ()
 
 testExecuteEmitterViaExecuteTransition ()
 
 testExecuteEmitterViaExecuteTransitionExclusiveFork ()
 
 testAddDetectorFirst ()
 
 testAddGetActivity ()
 

Data Fields

 $workflow
 

Detailed Description

ilCaseNodeTest is part of the petri net based workflow engine.

This class holds all tests for the class nodes/class.ilCaseNode

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

/

Definition at line 15 of file ilCaseNodeTest.php.

Member Function Documentation

◆ setUp()

ilCaseNodeTest::setUp ( )

Definition at line 20 of file ilCaseNodeTest.php.

21  {
22  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
23  //ilUnitUtil::performInitialisation();
24 
25  // Empty workflow.
26  require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
27  $this->workflow = new ilEmptyWorkflow();
28  }
PhpIncludeInspection

◆ tearDown()

ilCaseNodeTest::tearDown ( )

Definition at line 30 of file ilCaseNodeTest.php.

References $ilSetting.

31  {
32  global $ilSetting;
33  if ($ilSetting != null) {
34  $ilSetting->delete('IL_PHPUNIT_TEST_TIME');
35  $ilSetting->delete('IL_PHPUNIT_TEST_MICROTIME');
36  }
37  }
global $ilSetting
Definition: privfeed.php:17

◆ testAddDetectorFirst()

ilCaseNodeTest::testAddDetectorFirst ( )

Definition at line 324 of file ilCaseNodeTest.php.

325  {
326  // Arrange
327  $node = new ilCaseNode($this->workflow);
328  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
329  $detector = new ilSimpleDetector($node);
330 
331  // Act
332  $node->addDetector($detector);
333  $detectors = $node->getDetectors();
334 
335  // Assert
336  $this->assertEquals($detector, $detectors[0]);
337  }
PhpIncludeInspection
PhpIncludeInspection

◆ testAddGetActivity()

ilCaseNodeTest::testAddGetActivity ( )

Definition at line 339 of file ilCaseNodeTest.php.

340  {
341  // Arrange
342  $node = new ilCaseNode($this->workflow);
343  require_once './Services/WorkflowEngine/classes/activities/class.ilLoggingActivity.php';
344  $activity = new ilLoggingActivity($node);
345 
346  // Act
347  $node->addActivity($activity);
348  $activities = $node->getActivities();
349 
350  // Assert
351  $this->assertEquals($activity, $activities[0]);
352  }
PhpIncludeInspection
PhpIncludeInspection

◆ testAttemptTransitionPreconditionsValidOnExclusiveJoin()

ilCaseNodeTest::testAttemptTransitionPreconditionsValidOnExclusiveJoin ( )

Definition at line 181 of file ilCaseNodeTest.php.

References $success.

182  {
183  // Arrange
184  $node = new ilCaseNode($this->workflow);
185  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
186  $detector1 = new ilSimpleDetector($node);
187  $node->addDetector($detector1);
188  $detector2 = new ilSimpleDetector($node);
189  $node->addDetector($detector2);
190  $node->setIsExclusiveJoin(true);
191  $detector1->trigger(null);
192  $detector2->trigger(null);
193 
194  // Act
195  $success = $node->attemptTransition();
196 
197  // Assert
198  $this->assertTrue($success);
199  }
PhpIncludeInspection
$success
Definition: Utf8Test.php:86
PhpIncludeInspection

◆ testCheckTransitionPreconditionsInvalid()

ilCaseNodeTest::testCheckTransitionPreconditionsInvalid ( )

Definition at line 161 of file ilCaseNodeTest.php.

162  {
163  // Arrange
164  $node = new ilCaseNode($this->workflow);
165  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
166  $detector1 = new ilSimpleDetector($node);
167  $node->addDetector($detector1);
168  $detector2 = new ilSimpleDetector($node);
169  $node->addDetector($detector2);
170 
171  $detector1->trigger(null);
172  //$detector2->trigger(null);
173 
174  // Act
175  $preconditions = $node->checkTransitionPreconditions();
176 
177  // Assert
178  $this->assertFalse($preconditions);
179  }
PhpIncludeInspection
PhpIncludeInspection

◆ testCheckTransitionPreconditionsValid()

ilCaseNodeTest::testCheckTransitionPreconditionsValid ( )

Definition at line 102 of file ilCaseNodeTest.php.

103  {
104  // Arrange
105  $node = new ilCaseNode($this->workflow);
106  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
107  $detector1 = new ilSimpleDetector($node);
108  $node->addDetector($detector1);
109  $detector2 = new ilSimpleDetector($node);
110  $node->addDetector($detector2);
111 
112  $detector1->trigger(null);
113  $detector2->trigger(null);
114 
115  // Act
116  $preconditions = $node->checkTransitionPreconditions();
117 
118  // Assert
119  $this->assertTrue($preconditions);
120  }
PhpIncludeInspection
PhpIncludeInspection

◆ testCheckTransitionPreconditionsValidOnExclusiveJoin()

ilCaseNodeTest::testCheckTransitionPreconditionsValidOnExclusiveJoin ( )

Definition at line 122 of file ilCaseNodeTest.php.

123  {
124  // Arrange
125  $node = new ilCaseNode($this->workflow);
126  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
127  $detector1 = new ilSimpleDetector($node);
128  $node->addDetector($detector1);
129  $detector2 = new ilSimpleDetector($node);
130  $node->addDetector($detector2);
131  $node->setIsExclusiveJoin(true);
132  $detector1->trigger(null);
133  $detector2->trigger(null);
134 
135  // Act
136  $preconditions = $node->checkTransitionPreconditions();
137 
138  // Assert
139  $this->assertTrue($preconditions);
140  }
PhpIncludeInspection
PhpIncludeInspection

◆ testConstructorValidContext()

ilCaseNodeTest::testConstructorValidContext ( )

Definition at line 39 of file ilCaseNodeTest.php.

40  {
41  // Act
42  $node = new ilCaseNode($this->workflow);
43 
44  // Assert
45  // No exception - good
46  $this->assertTrue(
47  true,
48  'Construction failed with valid context passed to constructor.'
49  );
50  }
PhpIncludeInspection

◆ testDeactivate()

ilCaseNodeTest::testDeactivate ( )

Definition at line 84 of file ilCaseNodeTest.php.

85  {
86  // Arrange
87  $node = new ilCaseNode($this->workflow);
88  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
89  $detector = new ilSimpleDetector($node);
90  $node->addDetector($detector);
91 
92  // Act
93  $node->activate();
94  $was_activated = $node->isActive();
95  $node->deactivate();
96  $was_deactivated = !$node->isActive();
97 
98  // Assert
99  $this->assertEquals($was_activated, $was_deactivated);
100  }
PhpIncludeInspection
PhpIncludeInspection

◆ testExecuteActivitiesViaExecuteTransition()

ilCaseNodeTest::testExecuteActivitiesViaExecuteTransition ( )

Definition at line 236 of file ilCaseNodeTest.php.

237  {
238  // Arrange
239  $node = new ilCaseNode($this->workflow);
240  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
241  $detector = new ilSimpleDetector($node);
242  $node->addDetector($detector);
243 
244  require_once './Services/WorkflowEngine/classes/activities/class.ilLoggingActivity.php';
245  $activity = new ilLoggingActivity($node);
246  $activity->setLogFile('ilTransitionLog.txt');
247  $activity->setLogLevel('MESSAGE');
248  $activity->setLogMessage('TEST');
249  $node->addActivity($activity);
250 
251  // Act
252  $node->activate();
253  $node->executeTransition();
254 
255  // Assert
256  $expected = ' :: MESSAGE :: TEST';
257  $fp = fopen('ilTransitionLog.txt', r);
258  $line = fgets($fp);
259  $actual = substr($line, 25, strlen($line)-27);
260  @unlink('ilTransitionLog.txt'); // TODO: Use vfsStrream
261  $this->assertEquals(
262  $expected,
263  $actual
264  );
265  }
PhpIncludeInspection
PhpIncludeInspection
PhpIncludeInspection

◆ testExecuteEmitterViaExecuteTransition()

ilCaseNodeTest::testExecuteEmitterViaExecuteTransition ( )

Definition at line 267 of file ilCaseNodeTest.php.

268  {
269  // Arrange
270  $node = new ilCaseNode($this->workflow);
271  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
272  $detector = new ilSimpleDetector($node);
273  $node->addDetector($detector);
274 
275  require_once './Services/WorkflowEngine/classes/emitters/class.ilActivationEmitter.php';
276  $t_node = new ilBasicNode($this->workflow);
277  $t_detector = new ilSimpleDetector($t_node);
278  $t_node->addDetector($t_detector);
279  $foo_detector = new ilSimpleDetector($t_node);
280  $t_node->addDetector($foo_detector);
281  // again a foo_detector to keep the t_node from transitting
282 
283  $emitter = new ilActivationEmitter($node);
284  $emitter->setTargetDetector($t_detector);
285  $node->addEmitter($emitter);
286 
287  // Act
288  $node->activate();
289  $node->executeTransition();
290 
291  // Assert
292  $this->assertTrue($t_node->isActive());
293  }
PhpIncludeInspection
PhpIncludeInspection
PhpIncludeInspection

◆ testExecuteEmitterViaExecuteTransitionExclusiveFork()

ilCaseNodeTest::testExecuteEmitterViaExecuteTransitionExclusiveFork ( )

Definition at line 295 of file ilCaseNodeTest.php.

296  {
297  // Arrange
298  $node = new ilCaseNode($this->workflow);
299  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
300  $detector = new ilSimpleDetector($node);
301  $node->addDetector($detector);
302 
303  require_once './Services/WorkflowEngine/classes/emitters/class.ilActivationEmitter.php';
304  $t_node = new ilBasicNode($this->workflow);
305  $t_detector = new ilSimpleDetector($t_node);
306  $t_node->addDetector($t_detector);
307  $foo_detector = new ilSimpleDetector($t_node);
308  $t_node->addDetector($foo_detector);
309  // again a foo_detector to keep the t_node from transitting
310 
311  $emitter = new ilActivationEmitter($node);
312  $emitter->setTargetDetector($t_detector);
313  $node->addEmitter($emitter);
314  $node->setIsExclusiveFork(true);
315 
316  // Act
317  $node->activate();
318  $node->executeTransition();
319 
320  // Assert
321  $this->assertTrue($t_node->isActive());
322  }
PhpIncludeInspection
PhpIncludeInspection
PhpIncludeInspection

◆ testExecuteTransition()

ilCaseNodeTest::testExecuteTransition ( )

Definition at line 201 of file ilCaseNodeTest.php.

References $state.

202  {
203  // Arrange
204  $node = new ilCaseNode($this->workflow);
205  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
206  $detector = new ilSimpleDetector($node);
207  $node->addDetector($detector);
208  $node->activate();
209 
210  // Act
211  $node->executeTransition();
212  $state = $node->isActive();
213 
214  // Assert
215  $this->assertFalse($state);
216  }
PhpIncludeInspection
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
PhpIncludeInspection

◆ testExecuteTransitionExclusiveFork()

ilCaseNodeTest::testExecuteTransitionExclusiveFork ( )

Definition at line 218 of file ilCaseNodeTest.php.

References $state.

219  {
220  // Arrange
221  $node = new ilCaseNode($this->workflow);
222  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
223  $detector = new ilSimpleDetector($node);
224  $node->addDetector($detector);
225  $node->activate();
226  $node->setIsExclusiveFork(true);
227 
228  // Act
229  $node->executeTransition();
230  $state = $node->isActive();
231 
232  // Assert
233  $this->assertFalse($state);
234  }
PhpIncludeInspection
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
PhpIncludeInspection

◆ testGetContext()

ilCaseNodeTest::testGetContext ( )

Definition at line 52 of file ilCaseNodeTest.php.

53  {
54  // Arrange
55  $node = new ilCaseNode($this->workflow);
56 
57  // Act
58  $actual = $node->getContext();
59 
60  // Assert
61  if ($actual === $this->workflow) {
62  $this->assertEquals($actual, $this->workflow);
63  } else {
64  $this->assertTrue(false, 'Context not identical.');
65  }
66  }
PhpIncludeInspection

◆ testIsActiveAndActivate()

ilCaseNodeTest::testIsActiveAndActivate ( )

Definition at line 68 of file ilCaseNodeTest.php.

69  {
70  // Arrange
71  $node = new ilCaseNode($this->workflow);
72  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
73  $detector = new ilSimpleDetector($node);
74  $node->addDetector($detector);
75 
76  // Act
77  $node->activate();
78 
79  // Assert
80  $actual = $node->isActive();
81  $this->assertTrue($actual);
82  }
PhpIncludeInspection
PhpIncludeInspection

◆ testNotifyDetectorSatisfactionAndTransit()

ilCaseNodeTest::testNotifyDetectorSatisfactionAndTransit ( )

Definition at line 142 of file ilCaseNodeTest.php.

143  {
144  // Arrange
145  $node = new ilCaseNode($this->workflow);
146  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
147  $detector1 = new ilSimpleDetector($node);
148  $node->addDetector($detector1);
149  $detector2 = new ilSimpleDetector($node);
150  $node->addDetector($detector2);
151 
152  // Act
153  $node->activate();
154  $this->assertTrue($node->isActive());
155  $detector1->trigger(null);
156  $detector2->trigger(null);
157  // TODO: Assert something more meaningful here.
158  $this->assertFalse($node->isActive());
159  }
PhpIncludeInspection
PhpIncludeInspection

Field Documentation

◆ $workflow

ilCaseNodeTest::$workflow

Definition at line 18 of file ilCaseNodeTest.php.


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