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

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

+ Inheritance diagram for ilSimpleDetectorTest:
+ Collaboration diagram for ilSimpleDetectorTest:

Public Member Functions

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

Detailed Description

ilSimpleDetectorTest is part of the petri net based workflow engine.

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

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

/

Definition at line 15 of file ilSimpleDetectorTest.php.

Member Function Documentation

◆ setUp()

ilSimpleDetectorTest::setUp ( )

Definition at line 17 of file ilSimpleDetectorTest.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.ilSimpleDetector.php';
34  }
PhpIncludeInspection
PhpIncludeInspection

◆ tearDown()

ilSimpleDetectorTest::tearDown ( )

Definition at line 36 of file ilSimpleDetectorTest.php.

References $ilSetting.

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

◆ testConstructorValidContext()

ilSimpleDetectorTest::testConstructorValidContext ( )

Definition at line 45 of file ilSimpleDetectorTest.php.

46  {
47  // Act
48  $detector = new ilSimpleDetector($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  }
PhpIncludeInspection

◆ testGetContext()

ilSimpleDetectorTest::testGetContext ( )

Definition at line 119 of file ilSimpleDetectorTest.php.

120  {
121  // Arrange
122  $detector = new ilSimpleDetector($this->node);
123 
124  // Act
125  $actual = $detector->getContext();
126 
127  // Assert
128  if ($actual === $this->node) {
129  $this->assertEquals($actual, $this->node);
130  } else {
131  $this->assertTrue(false, 'Context not identical.');
132  }
133  }
PhpIncludeInspection

◆ testSetDetectorState()

ilSimpleDetectorTest::testSetDetectorState ( )

Definition at line 58 of file ilSimpleDetectorTest.php.

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

◆ testTrigger()

ilSimpleDetectorTest::testTrigger ( )

Definition at line 89 of file ilSimpleDetectorTest.php.

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

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