ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
11{
12 #region Helper
13 public $base_path = './Services/WorkflowEngine/test/parser/';
14 public $suite_path = '008_IntermediateThrowEvent/';
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_WorkflowWithSimpleIntermediateThrowSignalEventShouldOutputAccordingly()
40 {
41 $test_name = 'IntermediateThrowEvent_Signal_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 './Services/EventHandling/classes/class.ilAppEventHandler.php';
55 $ilappeventhandler_mock = $this->getMock('ilAppEventHandler', array('raise'), array(), '', false, false);
56 $ilappeventhandler_mock
57 ->expects( $this->once() )
58 ->method( 'raise' )
59 ->will( $this->returnValue(true) );
60
61 global $ilAppEventHandler;
62 $ilAppEventHandler = $ilappeventhandler_mock;
63 $GLOBALS['ilAppEventHandler'] = $ilappeventhandler_mock;
64
65 require_once $this->getTestOutputFilename($test_name);
66 $process = new $test_name;
67 $process->startWorkflow();
68 $all_triggered = true;
69 foreach($process->getNodes() as $node)
70 {
72 foreach($node->getDetectors() as $detector)
73 {
75 if(!$detector->getActivated())
76 {
77 $all_triggered = false;
78 }
79 }
80 foreach($node->getEmitters() as $emitter)
81 {
83 if(!$emitter->getActivated())
84 {
85 $all_triggered = false;
86 }
87 }
88 }
89 $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
90
91 unlink($this->getTestOutputFilename($test_name));
92 }
93
94 public function test_WorkflowWithSimpleIntermediateThrowMessageEventShouldOutputAccordingly()
95 {
96 $test_name = 'IntermediateThrowEvent_Message_Simple';
97 $xml = file_get_contents($this->getTestInputFilename($test_name));
98 $parser = new ilBPMN2Parser();
99 $parse_result = $parser->parseBPMN2XML($xml);
100
101 file_put_contents($this->getTestOutputFilename($test_name), $parse_result);
102 $return = exec('php -l ' . $this->getTestOutputFilename($test_name));
103
104 $this->assertTrue(substr($return,0,25) == 'No syntax errors detected', 'Lint of output code failed.');
105
106 $goldsample = file_get_contents($this->getTestGoldsampleFilename($test_name));
107 $this->assertEquals($goldsample, $parse_result, 'Output does not match goldsample.');
108
109 $ilappeventhandler_mock = $this->getMock('ilAppEventHandler', array('raise'), array(), '', false, false);
110 $ilappeventhandler_mock
111 ->expects( $this->once() )
112 ->method( 'raise' )
113 ->will( $this->returnValue(true) );
114
115
116 global $ilAppEventHandler;
117 $ilAppEventHandler = $ilappeventhandler_mock;
118 $GLOBALS['ilAppEventHandler'] = $ilappeventhandler_mock;
119
120 require_once $this->getTestOutputFilename($test_name);
121 $process = new $test_name;
122 $process->startWorkflow();
123 $all_triggered = true;
124 foreach($process->getNodes() as $node)
125 {
127 foreach($node->getDetectors() as $detector)
128 {
130 if(!$detector->getActivated())
131 {
132 $all_triggered = false;
133 }
134 }
135 foreach($node->getEmitters() as $emitter)
136 {
138 if(!$emitter->getActivated())
139 {
140 $all_triggered = false;
141 }
142 }
143 }
144 $this->assertTrue($all_triggered, 'Not all nodes were triggered.');
145
146 unlink($this->getTestOutputFilename($test_name));
147 }
148}
$parser
Definition: BPMN2Parser.php:24
$parse_result
Definition: BPMN2Parser.php:26
An exception for terminatinating execution or to throw for unit testing.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.