ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
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.ilStopWorkflowActivity.php';
51 
52  $this->test_dir = vfs\vfsStream::setup('example');
53  }
54 
55  public function tearDown()
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  }
64 
65  public function testConstructorValidContext()
66  {
67  // Act
68  $activity = new ilStopWorkflowActivity($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  }
77 
78  public function testGetContext()
79  {
80  // Arrange
81  $activity = new ilStopWorkflowActivity($this->node);
82 
83  // Act
84  $actual = $activity->getContext();
85 
86  // Assert
87  if ($actual === $this->node)
88  {
89  $this->assertEquals($actual, $this->node);
90  } else {
91  $this->assertTrue(false, 'Context not identical.');
92  }
93  }
94 
95  public function testExecute()
96  {
97  $workflowMock = $this->getMockBuilder('ilEmptyWorkflow')
98  ->setMethods(array('stopWorkflow'))
99  ->getMock();
100 
101  $workflowMock->expects($this->once())
102  ->method('stopWorkflow');
103  $node = new ilBasicNode($workflowMock);
104 
105  $activity = new ilStopWorkflowActivity($node);
106 
107  // Act
108  $activity->execute();
109  }
110 }
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.