ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSettingActivityTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/WorkflowEngine/test/ilWorkflowEngineBaseTest.php';
5 
17 {
18  public function setUp()
19  {
20  parent::setUp();
21 
22  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
23  //ilUnitUtil::performInitialisation();
24 
25  // Empty workflow.
26  require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
27  $this->workflow = new ilEmptyWorkflow();
28 
29  // Basic node
30  require_once './Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
31  $this->node = new ilBasicNode($this->workflow);
32 
33  // Wiring up so the node is attached to the workflow.
34  $this->workflow->addNode($this->node);
35 
36  require_once './Services/WorkflowEngine/classes/activities/class.ilSettingActivity.php';
37  }
38 
39  public function tearDown()
40  {
41  global $ilSetting;
42  if ($ilSetting != null) {
43  $ilSetting->delete('IL_PHPUNIT_TEST_TIME');
44  $ilSetting->delete('IL_PHPUNIT_TEST_MICROTIME');
45  }
46  }
47 
48  public function testConstructorValidContext()
49  {
50  // Act
51  $activity = new ilSettingActivity($this->node);
52 
53  // Assert
54  // No exception - good
55  $this->assertTrue(
56  true,
57  'Construction failed with valid context passed to constructor.'
58  );
59  }
60 
61  public function testSetGetSettingName()
62  {
63  // Arrange
64  $activity = new ilSettingActivity($this->node);
65 
66  // Act
67  $expected = 'Günther';
68  $activity->setSettingName($expected);
69  $actual = $activity->getSettingName();
70 
71  // Assert
72  $this->assertEquals($actual, $expected);
73  }
74 
75  public function testSetGetSettingValue()
76  {
77  // Arrange
78  $activity = new ilSettingActivity($this->node);
79 
80  // Act
81  $expected = 'Günther';
82  $activity->setSettingValue($expected);
83  $actual = $activity->getSettingValue();
84 
85  // Assert
86  $this->assertEquals($actual, $expected);
87  }
88 
89  public function testSetSetting()
90  {
91  // Arrange
92  $activity = new ilSettingActivity($this->node);
93 
94  // Act
95  $expected_name = 'Ralle';
96  $expected_value = 'OK';
97  $activity->setSetting($expected_name, $expected_value);
98  $actual_name = $activity->getSettingName();
99  $actual_value = $activity->getSettingValue();
100 
101  // Assert
102  $this->assertEquals(
103  $actual_name . $actual_value,
104  $expected_name . $expected_value
105  );
106  }
107 
108  public function testExecute()
109  {
110  // Arrange
111  $activity = new ilSettingActivity($this->node);
112  $expected_name = 'Ralle';
113  $expected_val = 'OK';
114  $activity->setSetting($expected_name, $expected_val);
115 
116  require_once './Services/Administration/classes/class.ilSetting.php';
117  $ilSetting_mock = $this->createMock('ilSetting', array('set'), array(), '', false);
118 
119  $ilSetting_mock->expects($this->exactly(1))
120  ->method('set')
121  ->with($expected_name, $expected_val);
122  $stashed_real_object = @$GLOBALS['ilSetting'];
123  $GLOBALS['ilSetting'] = $ilSetting_mock;
124 
125  // Act
126  $activity->execute();
127 
128  $GLOBALS['ilSetting'] = $stashed_real_object;
129  }
130 
131  public function testGetContext()
132  {
133  // Arrange
134  $activity = new ilSettingActivity($this->node);
135 
136  // Act
137  $actual = $activity->getContext();
138 
139  // Assert
140  if ($actual === $this->node) {
141  $this->assertEquals($actual, $this->node);
142  } else {
143  $this->assertTrue(false, 'Context not identical.');
144  }
145  }
146 }
Class ilWorkflowEngineBaseTest.
ilSettingActivityTest is part of the petri net based workflow engine.
PhpIncludeInspection
PhpIncludeInspection
global $ilSetting
Definition: privfeed.php:17
PhpIncludeInspection
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.