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

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

+ Inheritance diagram for ilDataDetectorTest:
+ Collaboration diagram for ilDataDetectorTest:

Public Member Functions

 setUp ()
 
 tearDown ()
 
 testConstructorValidContext ()
 
 testSetDetectorState ()
 
 testTrigger ()
 
 testGetContext ()
 

Detailed Description

ilDataDetectorTest is part of the petri net based workflow engine.

This class holds all tests for the class detectors/class.ilDataDetector

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

/

Definition at line 15 of file ilDataDetectorTest.php.

Member Function Documentation

◆ setUp()

ilDataDetectorTest::setUp ( )

Definition at line 17 of file ilDataDetectorTest.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.ilDataDetector.php';
34 }
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection

◆ tearDown()

ilDataDetectorTest::tearDown ( )

Definition at line 36 of file ilDataDetectorTest.php.

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

References $ilSetting.

◆ testConstructorValidContext()

ilDataDetectorTest::testConstructorValidContext ( )

Definition at line 46 of file ilDataDetectorTest.php.

47 {
48 // Act
49 $detector = new ilDataDetector($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 }
@noinspection PhpIncludeInspection

◆ testGetContext()

ilDataDetectorTest::testGetContext ( )

Definition at line 124 of file ilDataDetectorTest.php.

125 {
126 // Arrange
127 $detector = new ilDataDetector($this->node);
128
129 // Act
130 $actual = $detector->getContext();
131
132 // Assert
133 if ($actual === $this->node)
134 {
135 $this->assertEquals($actual, $this->node);
136 } else {
137 $this->assertTrue(false, 'Context not identical.');
138 }
139 }

◆ testSetDetectorState()

ilDataDetectorTest::testSetDetectorState ( )

Definition at line 59 of file ilDataDetectorTest.php.

60 {
61 // Arrange
62 $workflow = new ilEmptyWorkflow();
63 $node = new ilBasicNode($workflow);
64 $detector = new ilDataDetector($node);
65 $workflow->addNode($node);
66
67
68 // Act
69 $detector->setDetectorState(true);
70
71
72 // Assert
73 $valid_state = true;
74
75 if (!$detector->getDetectorState())
76 {
77 $valid_state = false;
78 }
79
80 if ($node->isActive())
81 {
82 // With this single detector satisfied, the
83 // parent node should have transitted and
84 // this would result in it being inactive
85 // afterwards.
86 $valid_state = false;
87 }
88
89 $this->assertTrue($valid_state, 'Invalid state after setting of detector state.');
90 }

◆ testTrigger()

ilDataDetectorTest::testTrigger ( )

Definition at line 92 of file ilDataDetectorTest.php.

93 {
94 // Arrange
95 $workflow = new ilEmptyWorkflow();
96 $node = new ilBasicNode($workflow);
97 $detector = new ilDataDetector($node);
98 $workflow->addNode($node);
99
100
101 // Act
102 $detector->trigger(null);
103
104 // Assert
105 $valid_state = true;
106
107 if (!$detector->getDetectorState())
108 {
109 $valid_state = false;
110 }
111
112 if ($node->isActive())
113 {
114 // With this single detector satisfied, the
115 // parent node should have transitted and
116 // this would result in it being inactive
117 // afterwards.
118 $valid_state = false;
119 }
120
121 $this->assertTrue($valid_state, 'Invalid state after setting of detector state.');
122 }

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