ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilActivationEmitterTest Class Reference

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

+ Inheritance diagram for ilActivationEmitterTest:
+ Collaboration diagram for ilActivationEmitterTest:

Public Member Functions

 setUp ()
 
 tearDown ()
 
 testConstructorValidContext ()
 
 testGetContext ()
 
 testSetGetTargetDetector ()
 
 testEmitValidState ()
 
 testEmitActivationValidState ()
 

Detailed Description

ilActivationEmitterTest is part of the petri net based workflow engine.

This class holds all tests for the class emitters/class.ilActivationEmitter

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

/

Definition at line 15 of file ilActivationEmitterTest.php.

Member Function Documentation

◆ setUp()

ilActivationEmitterTest::setUp ( )

Definition at line 17 of file ilActivationEmitterTest.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/emitters/class.ilActivationEmitter.php';
34  }
PhpIncludeInspection
PhpIncludeInspection

◆ tearDown()

ilActivationEmitterTest::tearDown ( )

Definition at line 36 of file ilActivationEmitterTest.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()

ilActivationEmitterTest::testConstructorValidContext ( )

Definition at line 46 of file ilActivationEmitterTest.php.

47  {
48  // Act
49  $emitter = new ilActivationEmitter($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  }

◆ testEmitActivationValidState()

ilActivationEmitterTest::testEmitActivationValidState ( )

Definition at line 116 of file ilActivationEmitterTest.php.

117  {
118  // Arrange
119  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
120  $target_node = new ilBasicNode($this->workflow);
121  $target_detector = new ilSimpleDetector($target_node);
122  $foo_detector = new ilSimpleDetector($target_node);
123  $target_node->addDetector($foo_detector);
124  $target_node->addDetector($target_detector);
125 
126  /* We want to see if the target node gets activated. To achieve
127  * that, we need a second detector, so the node won't transit
128  * and deactivate on receiving the emit to $target_detector.
129  * Thought you wondered.
130  */
131 
132  $emitter = new ilActivationEmitter($this->node);
133  $emitter->setTargetDetector($target_detector);
134 
135  // Act
136  $emitter->emit();
137  // Assert
138  $actual = $target_node->isActive();
139  $this->assertTrue($actual);
140  }
PhpIncludeInspection
PhpIncludeInspection

◆ testEmitValidState()

ilActivationEmitterTest::testEmitValidState ( )

Definition at line 94 of file ilActivationEmitterTest.php.

95  {
96  // Arrange
97  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
98  $target_node = new ilBasicNode($this->workflow);
99  $target_detector = new ilSimpleDetector($target_node);
100  $target_node->addDetector($target_detector);
101 
102  // Blocking detector to keep node from transitting and resetting state.
103  $foo_detector = new ilSimpleDetector($target_node);
104  $target_node->addDetector($foo_detector);
105 
106  $emitter = new ilActivationEmitter($this->node);
107  $emitter->setTargetDetector($target_detector);
108 
109  // Act
110  $emitter->emit();
111  // Assert
112  $actual = $target_detector->getDetectorState();
113  $this->assertTrue($actual);
114  }
PhpIncludeInspection
PhpIncludeInspection

◆ testGetContext()

ilActivationEmitterTest::testGetContext ( )

Definition at line 59 of file ilActivationEmitterTest.php.

60  {
61  // Arrange
62  $emitter = new ilActivationEmitter($this->node);
63 
64  // Act
65  $actual = $emitter->getContext();
66 
67  // Assert
68  if ($actual === $this->node)
69  {
70  $this->assertEquals($actual, $this->node);
71  } else {
72  $this->assertTrue(false, 'Context not identical.');
73  }
74  }

◆ testSetGetTargetDetector()

ilActivationEmitterTest::testSetGetTargetDetector ( )

Definition at line 76 of file ilActivationEmitterTest.php.

77  {
78  // Arrange
79  require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
80  $target_node = new ilBasicNode($this->workflow);
81  $target_detector = new ilSimpleDetector($target_node);
82  $target_node->addDetector($target_detector);
83 
84  $emitter = new ilActivationEmitter($this->node);
85 
86  // Act
87  $emitter->setTargetDetector($target_detector);
88 
89  // Assert
90  $actual = $emitter->getTargetDetector();
91  $this->assertEquals($target_detector, $actual);
92  }
PhpIncludeInspection
PhpIncludeInspection

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