ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
41  $ilSetting->delete( 'IL_PHPUNIT_TEST_TIME' );
42  $ilSetting->delete( 'IL_PHPUNIT_TEST_MICROTIME' );
43  }
44  }
global $ilSetting
Definition: privfeed.php:17

◆ testConstructorValidContext()

ilSimpleDetectorTest::testConstructorValidContext ( )

Definition at line 46 of file ilSimpleDetectorTest.php.

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

◆ testGetContext()

ilSimpleDetectorTest::testGetContext ( )

Definition at line 124 of file ilSimpleDetectorTest.php.

125  {
126  // Arrange
127  $detector = new ilSimpleDetector($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  }
PhpIncludeInspection

◆ testSetDetectorState()

ilSimpleDetectorTest::testSetDetectorState ( )

Definition at line 59 of file ilSimpleDetectorTest.php.

60  {
61  // Arrange
62  $workflow = new ilEmptyWorkflow();
63  $node = new ilBasicNode($workflow);
64  $detector = new ilSimpleDetector($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  }
PhpIncludeInspection
PhpIncludeInspection
PhpIncludeInspection

◆ testTrigger()

ilSimpleDetectorTest::testTrigger ( )

Definition at line 92 of file ilSimpleDetectorTest.php.

93  {
94  // Arrange
95  $workflow = new ilEmptyWorkflow();
96  $node = new ilBasicNode($workflow);
97  $detector = new ilSimpleDetector($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  }
PhpIncludeInspection
PhpIncludeInspection
PhpIncludeInspection

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