ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.test_015_Data_Wiring.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 = '015_Data_Wiring/';
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_WorkflowWithInputTaskWiredDataIOShouldOutputAccordingly()
40 {
41 $test_name = 'Data_Wiring_Input_Task';
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', 234);
58 $process->startWorkflow();
59
60 foreach($process->getNodes() as $node)
61 {
62 if($node->getName() == '$_v_Task_1')
63 {
64 $runtime_vars = $node->getRuntimeVars();
65 }
66 }
67 $this->assertEquals(234, $runtime_vars['user_id'], 'IO data was not forwarded from input to task runtime var.');
68 $this->assertEquals(234, $process->getInstanceVarById('DataInput_1'), 'IO data was not kept as input var.');
69 unlink($this->getTestOutputFilename($test_name));
70 }
71
72
73 public function test_WorkflowWithInputObjectOutputWiredDataIOShouldOutputAccordingly()
74 {
75 $test_name = 'DataObject_Wiring_Input_Object_Output';
76 $xml = file_get_contents($this->getTestInputFilename($test_name));
77 $parser = new ilBPMN2Parser();
78 $parse_result = $parser->parseBPMN2XML($xml);
79
80 file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
81 $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
82
83 $this->assertTrue(substr($return,0,25) == 'No syntax errors detected', 'Lint of output code failed.');
84
85 $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
86 $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
87
88 require_once $this->getTestOutputFilename($test_name);
90 $process = new $test_name;
91 $process->setInstanceVarById('DataInput_1', 'YaddaYadda');
92 $process->startWorkflow();
93
94 //$this->assertEquals('YaddaYadda', $process->getInstanceVarById('DataOutput_1'), 'IO data was not forwarded through process.');
95 unlink($this->getTestOutputFilename($test_name));
96 }
97
98}
$parser
Definition: BPMN2Parser.php:24
$parse_result
Definition: BPMN2Parser.php:26
An exception for terminatinating execution or to throw for unit testing.