ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.test_008_IntermediateThrowEvent.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/WorkflowEngine/test/ilWorkflowEngineBaseTest.php';
5
13{
14 #region Helper
15 public $base_path = './Services/WorkflowEngine/test/parser/';
16 public $suite_path = '008_IntermediateThrowEvent/';
17
18 public function getTestInputFilename($test_name)
19 {
20 return $this->base_path . $this->suite_path . $test_name . '.bpmn2';
21 }
22
23 public function getTestOutputFilename($test_name)
24 {
25 return $this->base_path . $this->suite_path . $test_name . '_output.php';
26 }
27
28 public function getTestGoldsampleFilename($test_name)
29 {
30 return $this->base_path . $this->suite_path . $test_name . '_goldsample.php';
31 }
32
33 public function setUp() : void
34 {
35 chdir(dirname(__FILE__));
36 chdir('../../../../../');
37
38 parent::setUp();
39
40 require_once './Services/WorkflowEngine/classes/parser/class.ilBPMN2Parser.php';
41 }
42
43 public function test_WorkflowWithSimpleIntermediateThrowSignalEventShouldOutputAccordingly()
44 {
45 $test_name = 'IntermediateThrowEvent_Signal_Simple';
46 $xml = file_get_contents($this->getTestInputFilename($test_name));
47 $parser = new ilBPMN2Parser();
48 $parse_result = $parser->parseBPMN2XML($xml);
49
50 file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
51 $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
52
53 $this->assertTrue(substr($return, 0, 25) == 'No syntax errors detected', 'Lint of output code failed.');
54
55 $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
56 $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
57
58 //require_once './Services/EventHandling/classes/class.ilAppEventHandler.php';
59 $ilappeventhandler_mock = $this->createMock('ilAppEventHandler', array('raise'), array(), '', false, false);
60 $ilappeventhandler_mock
61 ->expects($this->once())
62 ->method('raise')
63 ->will($this->returnValue(true));
64
65 global $ilAppEventHandler;
66 $ilAppEventHandler = $ilappeventhandler_mock;
67 $GLOBALS['ilAppEventHandler'] = $ilappeventhandler_mock;
68
69 require_once $this->getTestOutputFilename($test_name);
70 $process = new $test_name;
71 $process->startWorkflow();
72 $all_triggered = true;
73 foreach ($process->getNodes() as $node) {
75 foreach ($node->getDetectors() as $detector) {
77 if (!$detector->getActivated()) {
78 $all_triggered = false;
79 }
80 }
81 foreach ($node->getEmitters() as $emitter) {
83 if (!$emitter->getActivated()) {
84 $all_triggered = false;
85 }
86 }
87 }
88 $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
89
90 unlink($this->getTestOutputFilename($test_name));
91 }
92
93 public function test_WorkflowWithSimpleIntermediateThrowMessageEventShouldOutputAccordingly()
94 {
95 $test_name = 'IntermediateThrowEvent_Message_Simple';
96 $xml = file_get_contents($this->getTestInputFilename($test_name));
97 $parser = new ilBPMN2Parser();
98 $parse_result = $parser->parseBPMN2XML($xml);
99
100 file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
101 $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
102
103 $this->assertTrue(substr($return, 0, 25) == 'No syntax errors detected', 'Lint of output code failed.');
104
105 $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
106 $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
107
108 $ilappeventhandler_mock = $this->createMock('ilAppEventHandler', array('raise'), array(), '', false, false);
109 $ilappeventhandler_mock
110 ->expects($this->once())
111 ->method('raise')
112 ->will($this->returnValue(true));
113
114
115 global $ilAppEventHandler;
116 $ilAppEventHandler = $ilappeventhandler_mock;
117 $GLOBALS['ilAppEventHandler'] = $ilappeventhandler_mock;
118
119 require_once $this->getTestOutputFilename($test_name);
120 $process = new $test_name;
121 $process->startWorkflow();
122 $all_triggered = true;
123 foreach ($process->getNodes() as $node) {
125 foreach ($node->getDetectors() as $detector) {
127 if (!$detector->getActivated()) {
128 $all_triggered = false;
129 }
130 }
131 foreach ($node->getEmitters() as $emitter) {
133 if (!$emitter->getActivated()) {
134 $all_triggered = false;
135 }
136 }
137 }
138 $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
139
140 unlink($this->getTestOutputFilename($test_name));
141 }
142}
$parser
Definition: BPMN2Parser.php:23
$parse_result
Definition: BPMN2Parser.php:25
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Class ilWorkflowEngineBaseTest.
$xml
Definition: metadata.php:332