ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
5 
17 {
19  public $test_dir;
20 
21  public function setUp()
22  {
23  chdir(dirname(__FILE__));
24  chdir('../../../../');
25 
26  try {
27  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
28  //ilUnitUtil::performInitialisation();
29  } catch (Exception $exception) {
30  if (!defined('IL_PHPUNIT_TEST')) {
31  define('IL_PHPUNIT_TEST', false);
32  }
33  }
34 
35  // Empty workflow.
36  require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
37  $this->workflow = new ilEmptyWorkflow();
38 
39  // Basic node
40  require_once './Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
41  $this->node = new ilBasicNode($this->workflow);
42 
43  // Wiring up so the node is attached to the workflow.
44  $this->workflow->addNode($this->node);
45 
46  require_once './Services/WorkflowEngine/classes/activities/class.ilScriptActivity.php';
47 
48  $this->test_dir = vfs\vfsStream::setup('example');
49  }
50 
51  public function tearDown()
52  {
53  global $ilSetting;
54  if ($ilSetting != null) {
55  //$ilSetting->delete('IL_PHPUNIT_TEST_TIME');
56  //$ilSetting->delete('IL_PHPUNIT_TEST_MICROTIME');
57  }
58  }
59 
60  public function testConstructorValidContext()
61  {
62  // Act
63  $activity = new ilScriptActivity($this->node);
64 
65  // Assert
66  // No exception - good
67  $this->assertTrue(
68  true,
69  'Construction failed with valid context passed to constructor.'
70  );
71  }
72 
73  public function testGetContext()
74  {
75  // Arrange
76  $activity = new ilScriptActivity($this->node);
77 
78  // Act
79  $actual = $activity->getContext();
80 
81  // Assert
82  if ($actual === $this->node) {
83  $this->assertEquals($actual, $this->node);
84  } else {
85  $this->assertTrue(false, 'Context not identical.');
86  }
87  }
88 
89  public function testSetGetMethod()
90  {
91  // Arrange
92  $activity = new ilScriptActivity($this->node);
93 
94  $activity->setMethod(function () {
95  return 'Hallo, Welt!';
96  });
97 
98  // Act
99  $response = $activity->getScript();
100 
101  // Assert
102  $this->assertEquals($response(), "Hallo, Welt!");
103  }
104 }
ilScriptActivityTest is part of the workflow engine.
PhpIncludeInspection
PhpIncludeInspection
$test_dir
vfsStream Test Directory, see setup.
global $ilSetting
Definition: privfeed.php:17
PhpIncludeInspection
$response