ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilPluginNodeTest.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{
18 public $workflow;
19
20 public function setUp() : void
21 {
23
24 // Empty workflow.
25 require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
26 $this->workflow = new ilEmptyWorkflow();
27 }
28
29 public function tearDown() : void
30 {
31 global $DIC;
32
33 if (isset($DIC['ilSetting'])) {
34 $DIC['ilSetting']->delete('IL_PHPUNIT_TEST_TIME');
35 $DIC['ilSetting']->delete('IL_PHPUNIT_TEST_MICROTIME');
36 }
37 }
38
40 {
41 // Act
42 $node = new ilPluginNode($this->workflow);
43
44 // Assert
45 // No exception - good
46 $this->assertTrue(
47 true,
48 'Construction failed with valid context passed to constructor.'
49 );
50 }
51
52 public function testGetContext()
53 {
54 // Arrange
55 $node = new ilPluginNode($this->workflow);
56
57 // Act
58 $actual = $node->getContext();
59
60 // Assert
61 if ($actual === $this->workflow) {
62 $this->assertEquals($actual, $this->workflow);
63 } else {
64 $this->assertTrue(false, 'Context not identical.');
65 }
66 }
67
68 public function testIsActiveAndActivate()
69 {
70 // Arrange
71 $node = new ilPluginNode($this->workflow);
72 require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
73 $detector = new ilSimpleDetector($node);
74 $node->addDetector($detector);
75
76 // Act
77 $node->activate();
78
79 // Assert
80 $actual = $node->isActive();
81 $this->assertTrue($actual);
82 }
83
84 public function testDeactivate()
85 {
86 // Arrange
87 $node = new ilPluginNode($this->workflow);
88 require_once './Services/WorkflowEngine/classes/detectors/class.ilSimpleDetector.php';
89 $detector = new ilSimpleDetector($node);
90 $node->addDetector($detector);
91
92 // Act
93 $node->activate();
94
95 // Assert
96 $this->assertTrue($node->isActive(), 'Node should be active but is inactive.');
97 $node->deactivate();
98 $this->assertFalse($node->isActive(), 'Node should be inactive but is active.');
99 }
100}
An exception for terminatinating execution or to throw for unit testing.
@noinspection PhpIncludeInspection
ilPluginNodeTest is part of the petri net based workflow engine.
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
Class ilWorkflowEngineBaseTest.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46