ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilEventRaisingActivityTest Class Reference

ilEventRaisingActivityTest is part of the workflow engine. More...

+ Inheritance diagram for ilEventRaisingActivityTest:
+ Collaboration diagram for ilEventRaisingActivityTest:

Public Member Functions

 setUp ()
 
 tearDown ()
 
 testConstructorValidContext ()
 
 testSetGetEventNameShouldReturnSetValue ()
 
 testSetGetEventTypeShouldReturnSetValue ()
 
 testGetContext ()
 
 testSetGetFixedParamsSinglePair ()
 
 testSetGetFixedParamsMultiplePairs ()
 
 testExecute ()
 

Data Fields

 $test_dir
 vfsStream Test Directory, see setup. More...
 

Detailed Description

ilEventRaisingActivityTest is part of the workflow engine.

This class holds all tests for the class activities/class.ilEventRaisingActivity

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

/

Definition at line 16 of file ilEventRaisingActivityTest.php.

Member Function Documentation

◆ setUp()

ilEventRaisingActivityTest::setUp ( )

Definition at line 21 of file ilEventRaisingActivityTest.php.

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.ilEventRaisingActivity.php';
51
52 $this->test_dir = vfs\vfsStream::setup('example');
53 }
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

References defined.

◆ tearDown()

ilEventRaisingActivityTest::tearDown ( )

Definition at line 55 of file ilEventRaisingActivityTest.php.

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 }
global $ilSetting
Definition: privfeed.php:17

References $ilSetting.

◆ testConstructorValidContext()

ilEventRaisingActivityTest::testConstructorValidContext ( )

Definition at line 65 of file ilEventRaisingActivityTest.php.

66 {
67 // Act
68 $activity = new ilEventRaisingActivity($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 }
@noinspection PhpIncludeInspection

◆ testExecute()

ilEventRaisingActivityTest::testExecute ( )

Definition at line 171 of file ilEventRaisingActivityTest.php.

172 {
173 $this->markTestIncomplete('Needs further investigation. $ilDB->quote vs. mock.');
174 // Arrange
175 $activity = new ilEventRaisingActivity($this->node);
176 $activity->setEventName('EVTName');
177 $activity->setEventType('EVTType');
178 $key = 'Key';
179 $value = 123;
180 $expected[] = array('key' => $key, 'value' => $value);
181 $expected[] = array('key' => 'context', 'value' => $activity);
182
183 $activity->addFixedParam($key, $value);
184
185 $appHandlerMock = $this->getMockBuilder('ilAppEventHandler', 'getParamsArray')
186 ->setMethods(array('raise'))
187 ->getMock();
188
189 $appHandlerMock->expects($this->once())
190 ->method('raise')
191 ->with(
192 $this->equalTo('EVTType'),
193 $this->equalTo('EVTName'),
194 $this->equalTo($expected)
195 );
196 $GLOBALS['ilAppEventHandler'] = $appHandlerMock;
197 $activity->execute();
198 }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $GLOBALS.

◆ testGetContext()

ilEventRaisingActivityTest::testGetContext ( )

Definition at line 112 of file ilEventRaisingActivityTest.php.

113 {
114 // Arrange
115 $activity = new ilEventRaisingActivity($this->node);
116
117 // Act
118 $actual = $activity->getContext();
119
120 // Assert
121 if ($actual === $this->node)
122 {
123 $this->assertEquals($actual, $this->node);
124 } else {
125 $this->assertTrue(false, 'Context not identical.');
126 }
127 }

◆ testSetGetEventNameShouldReturnSetValue()

ilEventRaisingActivityTest::testSetGetEventNameShouldReturnSetValue ( )

Definition at line 78 of file ilEventRaisingActivityTest.php.

79 {
80 // Arrange
81 $activity = new ilEventRaisingActivity($this->node);
82 $expected = 'HokusPokus';
83
84 // Act
85 $activity->setEventName($expected);
86 $actual = $activity->getEventName();
87
88 $this->assertEquals(
89 $actual,
90 $expected,
91 'Retrieved EventName differs from input value.'
92 );
93 }

◆ testSetGetEventTypeShouldReturnSetValue()

ilEventRaisingActivityTest::testSetGetEventTypeShouldReturnSetValue ( )

Definition at line 95 of file ilEventRaisingActivityTest.php.

96 {
97 // Arrange
98 $activity = new ilEventRaisingActivity($this->node);
99 $expected = 'HokusPokus';
100
101 // Act
102 $activity->setEventType($expected);
103 $actual = $activity->getEventType();
104
105 $this->assertEquals(
106 $actual,
107 $expected,
108 'Retrieved EventType differs from input value.'
109 );
110 }

◆ testSetGetFixedParamsMultiplePairs()

ilEventRaisingActivityTest::testSetGetFixedParamsMultiplePairs ( )

Definition at line 146 of file ilEventRaisingActivityTest.php.

147 {
148 // Arrange
149 $activity = new ilEventRaisingActivity($this->node);
150 $key1 = 'Key1';
151 $value1 = 123;
152 $key2 = 'Key2';
153 $value2 = 234;
154 $key3 = 'Key3';
155 $value3 = 345;
156 $expected[] = array('key' => $key1, 'value' => $value1);
157 $expected[] = array('key' => $key2, 'value' => $value2);
158 $expected[] = array('key' => $key3, 'value' => $value3);
159 $expected[] = array('key' => 'context', 'value' => $activity);
160
161 // Act
162 $activity->addFixedParam($key1, $value1);
163 $activity->addFixedParam($key2, $value2);
164 $activity->addFixedParam($key3, $value3);
165 $params = $activity->getParamsArray();
166
167 // Assert
168 $this->assertEquals($expected, $params);
169 }
$params
Definition: example_049.php:96

References $params.

◆ testSetGetFixedParamsSinglePair()

ilEventRaisingActivityTest::testSetGetFixedParamsSinglePair ( )

Definition at line 129 of file ilEventRaisingActivityTest.php.

130 {
131 // Arrange
132 $activity = new ilEventRaisingActivity($this->node);
133 $key = 'Key';
134 $value = 123;
135 $expected[] = array('key' => $key, 'value' => $value);
136 $expected[] = array('key' => 'context', 'value' => $activity);
137
138 // Act
139 $activity->addFixedParam($key, $value);
140 $params = $activity->getParamsArray();
141
142 // Assert
143 $this->assertEquals($expected, $params);
144 }

References $params.

Field Documentation

◆ $test_dir

ilEventRaisingActivityTest::$test_dir

vfsStream Test Directory, see setup.

Definition at line 19 of file ilEventRaisingActivityTest.php.


The documentation for this class was generated from the following file: