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