ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
All Data Structures Namespaces Files Functions Variables Typedefs Modules Pages
class.test_005_ExclusiveGateway.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
14  #region Helper
15  public $base_path = './Services/WorkflowEngine/test/parser/';
16  public $suite_path = '005_ExclusiveGateway/';
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()
34  {
35  chdir( dirname( __FILE__ ) );
36  chdir( '../../../../../' );
37 
38  require_once './Services/WorkflowEngine/classes/parser/class.ilBPMN2Parser.php';
39  }
40 
41  public function test_WorkflowWithExclusiveGatewayForkingShouldOutputAccordingly()
42  {
43  $test_name = 'ExclusiveGateway_Fork_Simple';
44  $xml = file_get_contents($this->getTestInputFilename($test_name));
45  $parser = new ilBPMN2Parser();
46  $parse_result = $parser->parseBPMN2XML($xml);
47 
48  file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
49  $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
50 
51  $this->assertTrue(substr($return,0,25) == 'No syntax errors detected', 'Lint of output code failed.');
52 
53  $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
54  $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
55 
56  require_once $this->getTestOutputFilename($test_name);
57  $process = new $test_name;
58  $this->assertFalse($process->isActive(), 'Process is not active.');
59 
60  $process->startWorkflow();
61  $all_triggered = true;
62  foreach($process->getNodes() as $node)
63  {
65  foreach($node->getDetectors() as $detector)
66  {
68  if(!$detector->getActivated())
69  {
70  $all_triggered = false;
71  }
72  }
73  foreach($node->getEmitters() as $emitter)
74  {
76  if(!$emitter->getActivated())
77  {
78  $all_triggered = false;
79  }
80  }
81  }
82  $this->assertFalse($all_triggered, 'All nodes were triggered.');
83 
84  $all_inactive = true;
85  foreach($process->getNodes() as $node)
86  {
87  if($node->isActive())
88  {
89  $all_inactive = false;
90  }
91  }
92  $this->assertFalse($all_inactive, 'Not all nodes are inactive.');
96  unlink($this->getTestOutputFilename($test_name));
97  }
98 
99  public function test_WorkflowWithExclusiveGatewayJoiningShouldOutputAccordingly()
100  {
101  $test_name = 'ExclusiveGateway_Join_Simple';
102  $xml = file_get_contents($this->getTestInputFilename($test_name));
103  $parser = new ilBPMN2Parser();
104  $parse_result = $parser->parseBPMN2XML($xml);
105 
106  file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
107  $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
108 
109  $this->assertTrue(substr($return,0,25) == 'No syntax errors detected', 'Lint of output code failed.');
110 
111  $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
112  $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
113 
114  require_once $this->getTestOutputFilename($test_name);
115  $process = new $test_name;
116  $this->assertFalse($process->isActive(), 'Process is inactive.');
117 
118  $process->startWorkflow();
119  $all_triggered = true;
120  foreach($process->getNodes() as $node)
121  {
123  foreach($node->getDetectors() as $detector)
124  {
126  if(!$detector->getActivated())
127  {
128  $all_triggered = false;
129  }
130  }
131  foreach($node->getEmitters() as $emitter)
132  {
134  if(!$emitter->getActivated())
135  {
136  $all_triggered = false;
137  }
138  }
139  }
140  $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
141 
142  $all_inactive = true;
143  foreach($process->getNodes() as $node)
144  {
145  if($node->isActive())
146  {
147  $all_inactive = false;
148  }
149  }
150  $this->assertTrue($all_inactive, 'Not all nodes are inactive.');
151 
152  unlink($this->getTestOutputFilename($test_name));
153  }
154 }
$parse_result
Definition: BPMN2Parser.php:26
$parser
Definition: BPMN2Parser.php:24
Class ilBPMN2Parser.