ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 

Additional Inherited Members

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

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.

References ILIAS\GlobalScreen\Provider\__construct().

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/emitters/class.ilActivationEmitter.php';
33  }
PhpIncludeInspection
__construct(Container $dic, ilPlugin $plugin)
PhpIncludeInspection
+ Here is the call graph for this function:

◆ tearDown()

ilActivationEmitterTest::tearDown ( )

Definition at line 35 of file ilActivationEmitterTest.php.

References $DIC.

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

◆ testConstructorValidContext()

ilActivationEmitterTest::testConstructorValidContext ( )

Definition at line 45 of file ilActivationEmitterTest.php.

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

◆ testEmitActivationValidState()

ilActivationEmitterTest::testEmitActivationValidState ( )

Definition at line 114 of file ilActivationEmitterTest.php.

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

◆ testEmitValidState()

ilActivationEmitterTest::testEmitValidState ( )

Definition at line 92 of file ilActivationEmitterTest.php.

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

◆ testGetContext()

ilActivationEmitterTest::testGetContext ( )

Definition at line 58 of file ilActivationEmitterTest.php.

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

◆ testSetGetTargetDetector()

ilActivationEmitterTest::testSetGetTargetDetector ( )

Definition at line 74 of file ilActivationEmitterTest.php.

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

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