5use PHPUnit\Framework\TestCase;
 
   24        chdir(dirname(__FILE__));
 
   25        chdir(
'../../../../');
 
   28            include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
 
   30        } 
catch (Exception $exception) {
 
   31            if (!defined(
'IL_PHPUNIT_TEST')) {
 
   32                define(
'IL_PHPUNIT_TEST', 
false);
 
   37        require_once 
'./Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
 
   41        require_once 
'./Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
 
   45        $this->workflow->addNode($this->node);
 
   47        require_once 
'./Services/WorkflowEngine/classes/activities/class.ilLoggingActivity.php';
 
   49        $this->test_dir = vfs\vfsStream::setup(
'example');
 
   70            'Construction failed with valid context passed to constructor.' 
   78        $expected = 
'./Services/WorkflowEngine/test/testlog.txt';
 
   81        $activity->setLogFile($expected);
 
   82        $actual = $activity->getLogFile();
 
   87            'Valid log file was given, returned value differed.' 
   96        $this->expectException(ilWorkflowFilesystemException::class);
 
  100        $expected = 
'/dev/ilias_unit_test_log_file_can_be_deleted_safely.txt';
 
  103        $activity->setLogFile($expected);
 
  104        $actual = $activity->getLogFile();
 
  114        $this->expectException(ilWorkflowObjectStateException::class);
 
  118        $expected = 
'./Services/WorkflowEngine/test/malicious.php';
 
  122        $activity->setLogFile($expected);
 
  123        $actual = $activity->getLogFile();
 
  132        $expected = 
'Hallo Spencer!';
 
  135        $activity->setLogMessage($expected);
 
  136        $actual = $activity->getLogMessage();
 
  142            'Get/Set corrupted message.' 
  151        $this->expectException(ilWorkflowObjectStateException::class);
 
  157        $activity->setLogMessage(
null);
 
  158        $actual = $activity->getLogMessage();
 
  168        $this->expectException(ilWorkflowObjectStateException::class);
 
  174        $activity->setLogMessage(
'');
 
  175        $actual = $activity->getLogMessage();
 
  184        $expected = 
"MESSAGE";
 
  187        $activity->setLogLevel($expected);
 
  188        $actual = $activity->getLogLevel();
 
  194            'Get/Set corrupted log level.' 
  203        $this->expectException(ilWorkflowObjectStateException::class);
 
  207        $expected = 
"guenther";
 
  210        $activity->setLogLevel($expected);
 
  211        $actual = $activity->getLogLevel();
 
  218        $activity->setLogFile(vfs\vfsStream::url(
'example/log.txt'));
 
  219        $activity->setLogLevel(
'MESSAGE');
 
  220        $activity->setLogMessage(
'TEST');
 
  223        $activity->execute();
 
  226        $expected = 
' :: MESSAGE :: TEST';
 
  227        $fp = fopen(vfs\vfsStream::url(
'example/log.txt'), 
'r');
 
  229        $actual = substr($line, 25, strlen($line) - 27);
 
  234            'Logging Activity did not write expected output.' 
  243        $this->expectException(ilWorkflowFilesystemException::class);
 
  247        $activity->setLogFile(vfs\vfsStream::url(
'example.txt'));
 
  256        $actual = $activity->getContext();
 
  259        if ($actual === $this->node) {
 
  260            $this->assertEquals($actual, $this->node);
 
  262            $this->assertTrue(
false, 
'Context not identical.');
 
An exception for terminatinating execution or to throw for unit testing.
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection
ilLoggingActivityTest is part of the petri net based workflow engine.
testSetGetInvalidLogLevel()
testSetGetEmptyLogMessage()
$test_dir
vfsStream Test Directory, see setup.
testConstructorValidContext()
testSetGetIllegalExtensionLogFile()
testSetGetNullLogMessage()
testSetGetValidLogLevel()
testPassInUnwriteablePath()
testSetGetNonWriteableLogFile()
@noinspection PhpIncludeInspection