ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.test_014_DataObject.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/WorkflowEngine/test/ilWorkflowEngineBaseTest.php';
5 
13 {
14  #region Helper
15  public $base_path = './Services/WorkflowEngine/test/parser/';
16  public $suite_path = '014_DataObject/';
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  parent::setUp();
39 
40  require_once './Services/WorkflowEngine/classes/parser/class.ilBPMN2Parser.php';
41  }
42 
43  public function test_DataObject_SimpleShouldOutputAccordingly()
44  {
45  $test_name = 'DataObject_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 $this->getTestOutputFilename($test_name);
60  $process = new $test_name;
61  $process->setInstanceVarById('DataObject_1', 'YaddaYadda');
62  $process->startWorkflow();
63  $all_triggered = true;
64  foreach ($process->getNodes() as $node) {
66  foreach ($node->getDetectors() as $detector) {
68  if (!$detector->getActivated()) {
69  $all_triggered = false;
70  }
71  }
72  foreach ($node->getEmitters() as $emitter) {
74  if (!$emitter->getActivated()) {
75  $all_triggered = false;
76  }
77  }
78  }
79  $this->assertEquals('YaddaYadda', $process->getInstanceVarById('DataObject_1'), 'Instancevar was not kept.');
80  $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
81  unlink($this->getTestOutputFilename($test_name));
82  }
83 
84  public function test_DataObject_RoleShouldOutputAccordingly()
85  {
86  $test_name = 'DataObject_Role';
87  $xml = file_get_contents($this->getTestInputFilename($test_name));
88  $parser = new ilBPMN2Parser();
89  $parse_result = $parser->parseBPMN2XML($xml);
90 
91  file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
92  $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
93 
94  $this->assertTrue(substr($return, 0, 25) == 'No syntax errors detected', 'Lint of output code failed.');
95 
96  $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
97  $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
98 
99  require_once $this->getTestOutputFilename($test_name);
101  $process = new $test_name;
102  $process->setInstanceVarById('DataObject_1', 'YaddaYadda');
103  $process->startWorkflow();
104  $all_triggered = true;
105  foreach ($process->getNodes() as $node) {
107  foreach ($node->getDetectors() as $detector) {
109  if (!$detector->getActivated()) {
110  $all_triggered = false;
111  }
112  }
113  foreach ($node->getEmitters() as $emitter) {
115  if (!$emitter->getActivated()) {
116  $all_triggered = false;
117  }
118  }
119  }
120  $this->assertEquals('YaddaYadda', $process->getInstanceVarById('DataObject_1'), 'Instancevar was not kept.');
121  $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
122  unlink($this->getTestOutputFilename($test_name));
123  }
124 }
Class ilWorkflowEngineBaseTest.
$parse_result
Definition: BPMN2Parser.php:25
$xml
Definition: metadata.php:240
$parser
Definition: BPMN2Parser.php:23
Class ilBPMN2Parser.