ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDataDetectorTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16{
17 public function setUp()
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 }
35
36 public function tearDown()
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 }
45
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 }
58
59 public function testSetDetectorState()
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 }
91
92 public function testTrigger()
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 }
123
124 public function testGetContext()
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 }
140}
An exception for terminatinating execution or to throw for unit testing.
@noinspection PhpIncludeInspection
ilDataDetectorTest is part of the petri net based workflow engine.
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
global $ilSetting
Definition: privfeed.php:17