ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilStopWorkflowActivityTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
5 
17 {
19  public $test_dir;
20 
21  public function setUp()
22  {
23  chdir(dirname(__FILE__));
24  chdir('../../../../');
25 
26  try {
27  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
28  //ilUnitUtil::performInitialisation();
29  } catch (Exception $exception) {
30  if (!defined('IL_PHPUNIT_TEST')) {
31  define('IL_PHPUNIT_TEST', false);
32  }
33  }
34 
35  // Empty workflow.
36  require_once './Services/WorkflowEngine/classes/workflows/class.ilEmptyWorkflow.php';
37  $this->workflow = new ilEmptyWorkflow();
38 
39  // Basic node
40  require_once './Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
41  $this->node = new ilBasicNode($this->workflow);
42 
43  // Wiring up so the node is attached to the workflow.
44  $this->workflow->addNode($this->node);
45 
46  require_once './Services/WorkflowEngine/classes/activities/class.ilStopWorkflowActivity.php';
47 
48  $this->test_dir = vfs\vfsStream::setup('example');
49  }
50 
51  public function tearDown()
52  {
53  global $ilSetting;
54  if ($ilSetting != null) {
55  //$ilSetting->delete('IL_PHPUNIT_TEST_TIME');
56  //$ilSetting->delete('IL_PHPUNIT_TEST_MICROTIME');
57  }
58  }
59 
60  public function testConstructorValidContext()
61  {
62  // Act
63  $activity = new ilStopWorkflowActivity($this->node);
64 
65  // Assert
66  // No exception - good
67  $this->assertTrue(
68  true,
69  'Construction failed with valid context passed to constructor.'
70  );
71  }
72 
73  public function testGetContext()
74  {
75  // Arrange
76  $activity = new ilStopWorkflowActivity($this->node);
77 
78  // Act
79  $actual = $activity->getContext();
80 
81  // Assert
82  if ($actual === $this->node) {
83  $this->assertEquals($actual, $this->node);
84  } else {
85  $this->assertTrue(false, 'Context not identical.');
86  }
87  }
88 
89  public function testExecute()
90  {
91  $workflowMock = $this->getMockBuilder('ilEmptyWorkflow')
92  ->setMethods(array('stopWorkflow'))
93  ->getMock();
94 
95  $workflowMock->expects($this->once())
96  ->method('stopWorkflow');
97  $node = new ilBasicNode($workflowMock);
98 
99  $activity = new ilStopWorkflowActivity($node);
100 
101  // Act
102  $activity->execute();
103  }
104 }
PhpIncludeInspection
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
PhpIncludeInspection
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
ilStopWorkflowActivityTest is part of the workflow engine.
$test_dir
vfsStream Test Directory, see setup.