ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDataEmitterTest.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/emitters/class.ilDataEmitter.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 }
46
48 {
49 // Act
50 $emitter = new ilDataEmitter($this->node);
51
52 // Assert
53 // No exception - good
54 $this->assertTrue(
55 true,
56 'Construction failed with valid context passed to constructor.'
57 );
58 }
59
60 public function testGetContext()
61 {
62 // Arrange
63 $emitter = new ilDataEmitter($this->node);
64
65 // Act
66 $actual = $emitter->getContext();
67
68 // Assert
69 if ($actual === $this->node)
70 {
71 $this->assertEquals($actual, $this->node);
72 } else {
73 $this->assertTrue(false, 'Context not identical.');
74 }
75 }
76
77 public function testSetGetTargetDetector()
78 {
79 // Arrange
80 require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
81 $target_node = new ilBasicNode($this->workflow);
82 $target_detector = new ilSimpleDetector($target_node);
83 $target_node->addDetector($target_detector);
84
85 $emitter = new ilDataEmitter($this->node);
86
87 // Act
88 $emitter->setTargetDetector($target_detector);
89
90 // Assert
91 $actual = $emitter->getTargetDetector();
92 $this->assertEquals($target_detector, $actual);
93 }
94
95 public function testEmitValidState()
96 {
97 // Arrange
98 require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
99 $target_node = new ilBasicNode($this->workflow);
100 $target_detector = new ilSimpleDetector($target_node);
101 $target_node->addDetector($target_detector);
102
103 $emitter = new ilDataEmitter($this->node);
104 $emitter->setTargetDetector($target_detector);
105
106 // Act
107 $emitter->emit();
108 // Assert
109 $actual = $target_detector->getDetectorState();
110 $this->assertTrue($actual);
111 }
112}
An exception for terminatinating execution or to throw for unit testing.
@noinspection PhpIncludeInspection
ilDataEmitterTest is part of the petri net based workflow engine.
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
global $ilSetting
Definition: privfeed.php:17