ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  $ilSetting->delete('IL_PHPUNIT_TEST_TIME');
41  $ilSetting->delete('IL_PHPUNIT_TEST_MICROTIME');
42  }
43  }
44 
45  public function testConstructorValidContext()
46  {
47  // Act
48  $activity = new ilStaticMethodCallActivity($this->node);
49 
50  // Assert
51  // No exception - good
52  $this->assertTrue(
53  true,
54  'Construction failed with valid context passed to constructor.'
55  );
56  }
57 
58  public function testSetGetIncludeFilename()
59  {
60  // Arrange
61  $activity = new ilStaticMethodCallActivity($this->node);
62  $expected = 'Services/WorkflowEngine/classes/utils/class.ilWorkflowUtils.php';
63 
64  // Act
65  $activity->setIncludeFilename($expected);
66  $actual = $activity->getIncludeFilename();
67 
68  // Assert
69  $this->assertEquals($actual, $expected);
70  }
71 
72  public function testSetGetClassAndMethodName()
73  {
74  // Arrange
75  $activity = new ilStaticMethodCallActivity($this->node);
76  $expected = 'ilWorkflowUtils::targetMethod';
77 
78  // Act
79  $activity->setClassAndMethodName($expected);
80  $actual = $activity->getClassAndMethodName();
81 
82  // Assert
83  $this->assertEquals($actual, $expected);
84  }
85 
86  public function testSetGetParameters()
87  {
88  // Arrange
89  $activity = new ilStaticMethodCallActivity($this->node);
90  $expected = array('homer', 'marge', 'bart', 'lisa', 'maggy');
91 
92  // Act
93  $activity->setParameters($expected);
94  $actual = $activity->getParameters();
95 
96  // Assert
97  $this->assertEquals($actual, $expected);
98  }
99 
100  public function testExecute()
101  {
102  // Arrange
103  $activity = new ilStaticMethodCallActivity($this->node);
104  $file = 'Services/WorkflowEngine/test/activities/ilStaticMethodCallActivityTest.php';
105  $class_and_method = 'ilStaticMethodCallActivityTest::executionTargetMethod';
106  $parameters = array('homer', 'marge', 'bart', 'lisa', 'maggy');
107 
108  // Act
109  $activity->setIncludeFilename($file);
110  $activity->setClassAndMethodName($class_and_method);
111  $activity->setParameters($parameters);
112  $activity->execute();
113 
114  // Assert
115  $this->assertTrue(true, 'There dont seem to be problems here.');
116  }
117 
118  public static function executionTargetMethod($context, $param)
119  {
120  $parameters = array(
121  'homer' => 'homer', 0 => 'homer',
122  'marge' => 'marge', 1 => 'marge',
123  'bart' => 'bart', 2 => 'bart',
124  'lisa' => 'lisa', 3 => 'lisa',
125  'maggy' => 'maggy', 4 => 'maggy'
126  );
127 
128  if ($context == null) {
129  throw new Exception('Something went wrong with the context.');
130  }
131 
132  if ($param[0] != $parameters) {
133  throw new Exception('Something went wrong with the parameters.');
134  }
135 
136  return true;
137  }
138 
139  public function testGetContext()
140  {
141  // Arrange
142  $activity = new ilStaticMethodCallActivity($this->node);
143 
144  // Act
145  $actual = $activity->getContext();
146 
147  // Assert
148  if ($actual === $this->node) {
149  $this->assertEquals($actual, $this->node);
150  } else {
151  $this->assertTrue(false, 'Context not identical.');
152  }
153  }
154 }
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