ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilStaticMethodCallActivityTest.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()
18  {
19  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20  //ilUnitUtil::performInitialisation();
21 
22  // Empty workflow.
23  require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
24  $this->workflow = new ilEmptyWorkflow();
25 
26  // Basic node
27  require_once './Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
28  $this->node = new ilBasicNode($this->workflow);
29 
30  // Wiring up so the node is attached to the workflow.
31  $this->workflow->addNode($this->node);
32 
33  require_once './Services/WorkflowEngine/classes/activities/class.ilStaticMethodCallActivity.php';
34  }
35 
36  public function tearDown()
37  {
38  global $ilSetting;
39  if ($ilSetting != NULL)
40  {
41  $ilSetting->delete('IL_PHPUNIT_TEST_TIME');
42  $ilSetting->delete('IL_PHPUNIT_TEST_MICROTIME');
43  }
44  }
45 
46  public function testConstructorValidContext()
47  {
48  // Act
49  $activity = new ilStaticMethodCallActivity($this->node);
50 
51  // Assert
52  // No exception - good
53  $this->assertTrue(
54  true,
55  'Construction failed with valid context passed to constructor.'
56  );
57  }
58 
59  public function testSetGetIncludeFilename()
60  {
61  // Arrange
62  $activity = new ilStaticMethodCallActivity($this->node);
63  $expected = 'Services/WorkflowEngine/classes/utils/class.ilWorkflowUtils.php';
64 
65  // Act
66  $activity->setIncludeFilename($expected);
67  $actual = $activity->getIncludeFilename();
68 
69  // Assert
70  $this->assertEquals($actual, $expected);
71  }
72 
73  public function testSetGetClassAndMethodName()
74  {
75  // Arrange
76  $activity = new ilStaticMethodCallActivity($this->node);
77  $expected = 'ilWorkflowUtils::targetMethod';
78 
79  // Act
80  $activity->setClassAndMethodName($expected);
81  $actual = $activity->getClassAndMethodName();
82 
83  // Assert
84  $this->assertEquals($actual, $expected);
85  }
86 
87  public function testSetGetParameters()
88  {
89  // Arrange
90  $activity = new ilStaticMethodCallActivity($this->node);
91  $expected = array('homer', 'marge', 'bart', 'lisa', 'maggy');
92 
93  // Act
94  $activity->setParameters($expected);
95  $actual = $activity->getParameters();
96 
97  // Assert
98  $this->assertEquals($actual, $expected);
99  }
100 
101  public function testExecute()
102  {
103  // Arrange
104  $activity = new ilStaticMethodCallActivity($this->node);
105  $file = 'Services/WorkflowEngine/test/activities/ilStaticMethodCallActivityTest.php';
106  $class_and_method = 'ilStaticMethodCallActivityTest::executionTargetMethod';
107  $parameters = array('homer', 'marge', 'bart', 'lisa', 'maggy');
108 
109  // Act
110  $activity->setIncludeFilename($file);
111  $activity->setClassAndMethodName($class_and_method);
112  $activity->setParameters($parameters);
113  $activity->execute();
114 
115  // Assert
116  $this->assertTrue(true, 'There dont seem to be problems here.');
117  }
118 
119  public static function executionTargetMethod($context, $param)
120  {
121  $parameters = array('homer' => 'homer', 'marge' => 'marge', 'bart' => 'bart', 'lisa' => 'lisa', 'maggy' => 'maggy');
122 
123  if ($context == null)
124  {
125  throw new Exception('Something went wrong with the context.');
126  }
127 
128  if ($param[0] != $parameters)
129  {
130  throw new Exception('Something went wrong with the parameters.');
131  }
132 
133  return true;
134  }
135 
136  public function testGetContext()
137  {
138  // Arrange
139  $activity = new ilStaticMethodCallActivity($this->node);
140 
141  // Act
142  $actual = $activity->getContext();
143 
144  // Assert
145  if ($actual === $this->node)
146  {
147  $this->assertEquals($actual, $this->node);
148  } else {
149  $this->assertTrue(false, 'Context not identical.');
150  }
151  }
152 }
ilStaticMethodCallActivityTest is part of the petri net based workflow engine.
PhpIncludeInspection
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
PhpIncludeInspection
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file