ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.test_012_DataInput.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
12 #region Helper
13 public $base_path = './Services/WorkflowEngine/test/parser/';
14 public $suite_path = '012_DataInput/';
15
16 public function getTestInputFilename($test_name)
17 {
18 return $this->base_path . $this->suite_path . $test_name . '.bpmn2';
19 }
20
21 public function getTestOutputFilename($test_name)
22 {
23 return $this->base_path . $this->suite_path . $test_name . '_output.php';
24 }
25
26 public function getTestGoldsampleFilename($test_name)
27 {
28 return $this->base_path . $this->suite_path . $test_name . '_goldsample.php';
29 }
30
31 public function setUp()
32 {
33 chdir( dirname( __FILE__ ) );
34 chdir( '../../../../../' );
35
36 require_once './Services/WorkflowEngine/classes/parser/class.ilBPMN2Parser.php';
37 }
38
39 public function test_WorkflowWithSimpleDataInputShouldOutputAccordingly()
40 {
41 $test_name = 'DataInput_Simple';
42 $xml = file_get_contents($this->getTestInputFilename($test_name));
43 $parser = new ilBPMN2Parser();
44 $parse_result = $parser->parseBPMN2XML($xml);
45
46 file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
47 $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
48
49 $this->assertTrue(substr($return,0,25) == 'No syntax errors detected', 'Lint of output code failed.');
50
51 $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
52 $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
53
54 require_once $this->getTestOutputFilename($test_name);
56 $process = new $test_name;
57 $process->setInstanceVarById('DataInput_1', 'YaddaYadda');
58 $process->startWorkflow();
59 $all_triggered = true;
60 foreach($process->getNodes() as $node)
61 {
63 foreach($node->getDetectors() as $detector)
64 {
66 if(!$detector->getActivated())
67 {
68 $all_triggered = false;
69 }
70 }
71 foreach($node->getEmitters() as $emitter)
72 {
74 if(!$emitter->getActivated())
75 {
76 $all_triggered = false;
77 }
78 }
79 }
80 $this->assertEquals('YaddaYadda', $process->getInstanceVarById('DataInput_1'), 'Inputvar was not kept.');
81 $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
82
83 unlink($this->getTestOutputFilename($test_name));
84 }
85
86 public function test_WorkflowWithDataInputPropertiesShouldOutputAccordingly()
87 {
88 $test_name = 'DataInput_WithProperties';
89 $xml = file_get_contents($this->getTestInputFilename($test_name));
90 $parser = new ilBPMN2Parser();
91 $parse_result = $parser->parseBPMN2XML($xml);
92
93 file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
94 $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
95
96 $this->assertTrue(substr($return,0,25) == 'No syntax errors detected', 'Lint of output code failed.');
97
98 $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
99 $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
100
101 require_once $this->getTestOutputFilename($test_name);
103 $process = new $test_name;
104 $process->setInstanceVarById('DataInput_1', 'YaddaYadda');
105 $process->startWorkflow();
106 $all_triggered = true;
107 foreach($process->getNodes() as $node)
108 {
110 foreach($node->getDetectors() as $detector)
111 {
113 if(!$detector->getActivated())
114 {
115 $all_triggered = false;
116 }
117 }
118 foreach($node->getEmitters() as $emitter)
119 {
121 if(!$emitter->getActivated())
122 {
123 $all_triggered = false;
124 }
125 }
126 }
127 $this->assertEquals('YaddaYadda', $process->getInstanceVarById('DataInput_1'), 'Inputvar was not kept.');
128 $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
129
130 unlink($this->getTestOutputFilename($test_name));
131 }
132
133 public function test_WorkflowWithRepositoryObjectSelectorShouldOutputAccordingly()
134 {
135 $test_name = 'DataInput_RepositoryObjectSelector';
136 $xml = file_get_contents($this->getTestInputFilename($test_name));
137 $parser = new ilBPMN2Parser();
138 $parse_result = $parser->parseBPMN2XML($xml);
139
140 file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
141 $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
142
143 $this->assertTrue(substr($return,0,25) == 'No syntax errors detected', 'Lint of output code failed.');
144
145 $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
146 $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
147
148 require_once $this->getTestOutputFilename($test_name);
150 $process = new $test_name;
151 $process->setInstanceVarById('DataInput_1', 'YaddaYadda');
152 $process->startWorkflow();
153 $all_triggered = true;
154 foreach($process->getNodes() as $node)
155 {
157 foreach($node->getDetectors() as $detector)
158 {
160 if(!$detector->getActivated())
161 {
162 $all_triggered = false;
163 }
164 }
165 foreach($node->getEmitters() as $emitter)
166 {
168 if(!$emitter->getActivated())
169 {
170 $all_triggered = false;
171 }
172 }
173 }
174 $this->assertEquals('YaddaYadda', $process->getInstanceVarById('DataInput_1'), 'Inputvar was not kept.');
175 $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
176
177 unlink($this->getTestOutputFilename($test_name));
178 }
179
180}
$parser
Definition: BPMN2Parser.php:24
$parse_result
Definition: BPMN2Parser.php:26
An exception for terminatinating execution or to throw for unit testing.