ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilScriptActivityTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4use org\bovigo\vfs;
5use PHPUnit\Framework\TestCase;
6
17class ilScriptActivityTest extends TestCase
18{
20 public $test_dir;
21
22 public function setUp() : void
23 {
24 chdir(dirname(__FILE__));
25 chdir('../../../../');
26
27 try {
28 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
29 //ilUnitUtil::performInitialisation();
30 } catch (Exception $exception) {
31 if (!defined('IL_PHPUNIT_TEST')) {
32 define('IL_PHPUNIT_TEST', false);
33 }
34 }
35
36 // Empty workflow.
37 require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
38 $this->workflow = new ilEmptyWorkflow();
39
40 // Basic node
41 require_once './Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
42 $this->node = new ilBasicNode($this->workflow);
43
44 // Wiring up so the node is attached to the workflow.
45 $this->workflow->addNode($this->node);
46
47 require_once './Services/WorkflowEngine/classes/activities/class.ilScriptActivity.php';
48
49 $this->test_dir = vfs\vfsStream::setup('example');
50 }
51
52 public function tearDown() : void
53 {
54 global $ilSetting;
55 if ($ilSetting != null) {
56 //$ilSetting->delete('IL_PHPUNIT_TEST_TIME');
57 //$ilSetting->delete('IL_PHPUNIT_TEST_MICROTIME');
58 }
59 }
60
62 {
63 // Act
64 $activity = new ilScriptActivity($this->node);
65
66 // Assert
67 // No exception - good
68 $this->assertTrue(
69 true,
70 'Construction failed with valid context passed to constructor.'
71 );
72 }
73
74 public function testGetContext()
75 {
76 // Arrange
77 $activity = new ilScriptActivity($this->node);
78
79 // Act
80 $actual = $activity->getContext();
81
82 // Assert
83 if ($actual === $this->node) {
84 $this->assertEquals($actual, $this->node);
85 } else {
86 $this->assertTrue(false, 'Context not identical.');
87 }
88 }
89
90 public function testSetGetMethod()
91 {
92 // Arrange
93 $activity = new ilScriptActivity($this->node);
94
95 $activity->setMethod(function () {
96 return 'Hallo, Welt!';
97 });
98
99 // Act
100 $response = $activity->getScript();
101
102 // Assert
103 $this->assertEquals($response(), "Hallo, Welt!");
104 }
105}
An exception for terminatinating execution or to throw for unit testing.
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
ilScriptActivityTest is part of the workflow engine.
$test_dir
vfsStream Test Directory, see setup.
@noinspection PhpIncludeInspection
global $ilSetting
Definition: privfeed.php:17
$response