ilLoggingActivityTest is part of the petri net based workflow engine.
More...
ilLoggingActivityTest is part of the petri net based workflow engine.
This class holds all tests for the class activities/class.ilLoggingActivity
- Author
- Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
- Version
- $Id$
/
Definition at line 17 of file ilLoggingActivityTest.php.
◆ setUp()
ilLoggingActivityTest::setUp |
( |
| ) |
|
Definition at line 22 of file ilLoggingActivityTest.php.
22 : void
23 {
24 chdir(dirname(__FILE__));
25 chdir('../../../../');
26
27 try {
28 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
29
30 } catch (Exception $exception) {
31 if (!defined('IL_PHPUNIT_TEST')) {
32 define('IL_PHPUNIT_TEST', false);
33 }
34 }
35
36
37 require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
39
40
41 require_once './Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
43
44
45 $this->workflow->addNode($this->node);
46
47 require_once './Services/WorkflowEngine/classes/activities/class.ilLoggingActivity.php';
48
49 $this->test_dir = vfs\vfsStream::setup('example');
50 }
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
◆ tearDown()
ilLoggingActivityTest::tearDown |
( |
| ) |
|
◆ testConstructorValidContext()
ilLoggingActivityTest::testConstructorValidContext |
( |
| ) |
|
Definition at line 61 of file ilLoggingActivityTest.php.
62 {
63
65
66
67
68 $this->assertTrue(
69 true,
70 'Construction failed with valid context passed to constructor.'
71 );
72 }
@noinspection PhpIncludeInspection
◆ testExecute()
ilLoggingActivityTest::testExecute |
( |
| ) |
|
Definition at line 214 of file ilLoggingActivityTest.php.
215 {
216
218 $activity->setLogFile(vfs\vfsStream::url('example/log.txt'));
219 $activity->setLogLevel('MESSAGE');
220 $activity->setLogMessage('TEST');
221
222
223 $activity->execute();
224
225
226 $expected = ' :: MESSAGE :: TEST';
227 $fp = fopen(vfs\vfsStream::url('example/log.txt'), 'r');
228 $line = fgets($fp);
229 $actual = substr($line, 25, strlen($line) - 27);
230
231 $this->assertEquals(
232 $actual,
233 $expected,
234 'Logging Activity did not write expected output.'
235 );
236 }
◆ testGetContext()
ilLoggingActivityTest::testGetContext |
( |
| ) |
|
Definition at line 250 of file ilLoggingActivityTest.php.
251 {
252
254
255
256 $actual = $activity->getContext();
257
258
259 if ($actual === $this->node) {
260 $this->assertEquals($actual, $this->node);
261 } else {
262 $this->assertTrue(false, 'Context not identical.');
263 }
264 }
◆ testPassInUnwriteablePath()
ilLoggingActivityTest::testPassInUnwriteablePath |
( |
| ) |
|
Definition at line 241 of file ilLoggingActivityTest.php.
242 {
243 $this->expectException(ilWorkflowFilesystemException::class);
244
245
247 $activity->setLogFile(vfs\vfsStream::url('example.txt'));
248 }
◆ testSetGetEmptyLogMessage()
ilLoggingActivityTest::testSetGetEmptyLogMessage |
( |
| ) |
|
Definition at line 166 of file ilLoggingActivityTest.php.
167 {
168 $this->expectException(ilWorkflowObjectStateException::class);
169
170
172
173
174 $activity->setLogMessage('');
175 $actual = $activity->getLogMessage();
176
177
178 }
◆ testSetGetIllegalExtensionLogFile()
ilLoggingActivityTest::testSetGetIllegalExtensionLogFile |
( |
| ) |
|
Definition at line 112 of file ilLoggingActivityTest.php.
113 {
114 $this->expectException(ilWorkflowObjectStateException::class);
115
116
118 $expected = './Services/WorkflowEngine/test/malicious.php';
119
120
121
122 $activity->setLogFile($expected);
123 $actual = $activity->getLogFile();
124
125
126 }
◆ testSetGetInvalidLogLevel()
ilLoggingActivityTest::testSetGetInvalidLogLevel |
( |
| ) |
|
Definition at line 201 of file ilLoggingActivityTest.php.
202 {
203 $this->expectException(ilWorkflowObjectStateException::class);
204
205
207 $expected = "guenther";
208
209
210 $activity->setLogLevel($expected);
211 $actual = $activity->getLogLevel();
212 }
◆ testSetGetLegalMessage()
ilLoggingActivityTest::testSetGetLegalMessage |
( |
| ) |
|
Definition at line 128 of file ilLoggingActivityTest.php.
129 {
130
132 $expected = 'Hallo Spencer!';
133
134
135 $activity->setLogMessage($expected);
136 $actual = $activity->getLogMessage();
137
138
139 $this->assertEquals(
140 $actual,
141 $expected,
142 'Get/Set corrupted message.'
143 );
144 }
◆ testSetGetNonWriteableLogFile()
ilLoggingActivityTest::testSetGetNonWriteableLogFile |
( |
| ) |
|
Definition at line 94 of file ilLoggingActivityTest.php.
95 {
96 $this->expectException(ilWorkflowFilesystemException::class);
97
98
100 $expected = '/dev/ilias_unit_test_log_file_can_be_deleted_safely.txt';
101
102
103 $activity->setLogFile($expected);
104 $actual = $activity->getLogFile();
105
106
107 }
◆ testSetGetNullLogMessage()
ilLoggingActivityTest::testSetGetNullLogMessage |
( |
| ) |
|
Definition at line 149 of file ilLoggingActivityTest.php.
150 {
151 $this->expectException(ilWorkflowObjectStateException::class);
152
153
155
156
157 $activity->setLogMessage(null);
158 $actual = $activity->getLogMessage();
159
160
161 }
◆ testSetGetValidLogFile()
ilLoggingActivityTest::testSetGetValidLogFile |
( |
| ) |
|
Definition at line 74 of file ilLoggingActivityTest.php.
75 {
76
78 $expected = './Services/WorkflowEngine/test/testlog.txt';
79
80
81 $activity->setLogFile($expected);
82 $actual = $activity->getLogFile();
83
84 $this->assertEquals(
85 $actual,
86 $expected,
87 'Valid log file was given, returned value differed.'
88 );
89 }
◆ testSetGetValidLogLevel()
ilLoggingActivityTest::testSetGetValidLogLevel |
( |
| ) |
|
Definition at line 180 of file ilLoggingActivityTest.php.
181 {
182
184 $expected = "MESSAGE";
185
186
187 $activity->setLogLevel($expected);
188 $actual = $activity->getLogLevel();
189
190
191 $this->assertEquals(
192 $actual,
193 $expected,
194 'Get/Set corrupted log level.'
195 );
196 }
◆ $test_dir
ilLoggingActivityTest::$test_dir |
The documentation for this class was generated from the following file: