ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilSimpleEmitterTest.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() : void
18 {
20
21 // Empty workflow.
22 require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
23 $this->workflow = new ilEmptyWorkflow();
24
25 // Basic node
26 require_once './Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
27 $this->node = new ilBasicNode($this->workflow);
28
29 // Wiring up so the node is attached to the workflow.
30 $this->workflow->addNode($this->node);
31
32 require_once './Services/WorkflowEngine/classes/emitters/class.ilSimpleEmitter.php';
33 }
34
35 public function tearDown() : void
36 {
37 global $DIC;
38
39 if (isset($DIC['ilSetting'])) {
40 $DIC['ilSetting']->delete('IL_PHPUNIT_TEST_TIME');
41 $DIC['ilSetting']->delete('IL_PHPUNIT_TEST_MICROTIME');
42 }
43 }
44
46 {
47 // Act
48 $emitter = new ilSimpleEmitter($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 }
57
58 public function testGetContext()
59 {
60 // Arrange
61 $emitter = new ilSimpleEmitter($this->node);
62
63 // Act
64 $actual = $emitter->getContext();
65
66 // Assert
67 if ($actual === $this->node) {
68 $this->assertEquals($actual, $this->node);
69 } else {
70 $this->assertTrue(false, 'Context not identical.');
71 }
72 }
73
74 public function testSetGetTargetDetector()
75 {
76 // Arrange
77 require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
78 $target_node = new ilBasicNode($this->workflow);
79 $target_detector = new ilSimpleDetector($target_node);
80 $target_node->addDetector($target_detector);
81
82 $emitter = new ilSimpleEmitter($this->node);
83
84 // Act
85 $emitter->setTargetDetector($target_detector);
86
87 // Assert
88 $actual = $emitter->getTargetDetector();
89 $this->assertEquals($target_detector, $actual);
90 }
91
92 public function testEmitValidState()
93 {
94 // Arrange
95 require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
96 $target_node = new ilBasicNode($this->workflow);
97 $target_detector = new ilSimpleDetector($target_node);
98 $target_node->addDetector($target_detector);
99
100 $emitter = new ilSimpleEmitter($this->node);
101 $emitter->setTargetDetector($target_detector);
102
103 // Act
104 $emitter->emit();
105 // Assert
106 $actual = $target_detector->getDetectorState();
107 $this->assertTrue($actual);
108 }
109}
An exception for terminatinating execution or to throw for unit testing.
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
ilSimpleEmitterTest is part of the petri net based workflow engine.
@noinspection PhpIncludeInspection
Class ilWorkflowEngineBaseTest.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46