Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_importworkflow.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package Dcp\Pu
5 */
6 
7 namespace Dcp\Pu;
8 
9 require_once 'PU_testcase_dcp_document.php';
10 
12 {
13  protected static $outputDir;
14  /**
15  * @dataProvider dataBadFamilyFiles
16  */
17  public function testErrorImportWorkflow($familyFile, $expectedErrors)
18  {
19  $err = '';
20  try {
21  $this->importDocument($familyFile);
22  }
23  catch(\Exception $e) {
24  $err = $e->getMessage();
25  }
26  $this->assertNotEmpty($err, "no import error detected");
27  if (!is_array($expectedErrors)) $expectedErrors = array(
28  $expectedErrors
29  );
30 
31  foreach ($expectedErrors as $expectedError) {
32  $this->assertContains($expectedError, $err, sprintf("not the correct error reporting : %s", $err));
33  }
34  }
35  /**
36  * test import workflow
37  * @dataProvider dataGoodFamilyFiles
38  */
39  public function testExecuteImportWorkflow($familyFile, $familyName)
40  {
41  $err = '';
42  try {
43  $this->importDocument($familyFile);
44  }
45  catch(\Exception $e) {
46  $err = $e->getMessage();
47  }
48  $this->assertEmpty($err, "import error detected $err");
49  $doc = createDoc("", $familyName);
50  $this->assertTrue(is_object($doc));
51  $err = $doc->store();
52  $this->assertEmpty($err, "cannot create good doc");
53 
54  $wdoc = new_doc('', $doc->wid);
55  $this->assertTrue($wdoc->isAlive() , "workflow not alive");
56  $this->assertTrue(is_subclass_of($wdoc, "WDoc"));
57  }
58 
59  public function dataBadFamilyFiles()
60  {
61  return array(
62  // test workflow
63  array(
64  "PU_data_dcp_badfamily4.ods",
65  array(
66  "WFL0105",
67  "WTST_WFFAMIMP4"
68  )
69  ) ,
70  // test workflow class name syntax error
71  array(
72  "PU_data_dcp_badfamily5.ods",
73  array(
74  "WFL0002",
75  "WImpTest5"
76  )
77  ) ,
78  // test workflow without class
79  array(
80  "PU_data_dcp_badfamily6.ods",
81  array(
82  "WFL0005",
83  "WNotFound"
84  )
85  ) ,
86  // test workflow with a incorrect class name
87  array(
88  "PU_data_dcp_badfamily7.ods",
89  array(
90  "WFL0004",
91  "WTestBadNameImp7"
92  )
93  ) ,
94  // test workflow with class syntax error
95  array(
96  "PU_data_dcp_badfamily8.ods",
97  array(
98  "WFL0003",
99  "Parse error"
100  )
101  ) ,
102  // test workflow attrPrefix empty
103  array(
104  "PU_data_dcp_badfamily9.ods",
105  array(
106  "WFL0105",
107  "WFL0007",
108  "attrPrefix"
109  )
110  ) ,
111  // test workflow attrPrefix syntax
112  array(
113  "PU_data_dcp_badfamily10.ods",
114  array(
115  "WFL0008",
116  "syntax"
117  ) ,
118  ) ,
119  // test workflow transition model definition
120  array(
121  "PU_data_dcp_badfamily11.ods",
122  array(
123  "WFL0101",
124  "WFL0103",
125  "WFL0105",
126  "unknowM1",
127  "WFL0106",
128  "unknowM2",
129  "WFL0108",
130  "unknowM0",
131  "WFL0109",
132  "unknowM3",
133  "WFL0050"
134  )
135  ) ,
136  // test workflow transition definition
137  array(
138  "PU_data_dcp_badfamily12.ods",
139  array(
140  "WFL0050",
141  "WFL0201",
142  "WFL0202",
143  "WFL0052",
144  "WFL0107",
145  "dead or not",
146  " e3 "
147  )
148  ) ,
149  // test inherit workflow class
150  array(
151  "PU_data_dcp_badfamily13.ods",
152  array(
153  "WFL0006"
154  )
155  ) ,
156  // test inherit workflow class
157  array(
158  "PU_data_dcp_badfamily14.ods",
159  array(
160  "WFL0100",
161  "WFL0200",
162  "WFL0051"
163  )
164  ) ,
165  // without classname
166  array(
167  "PU_data_dcp_badfamily15.ods",
168  array(
169  "WFL0001"
170  )
171  ) ,
172  // too many transition model
173  array(
174  "PU_data_dcp_badfamily16.ods",
175  array(
176  "WFL0102"
177  )
178  ) ,
179  // test ask unknow attribute
180  array(
181  "PU_data_dcp_badfamily17.ods",
182  array(
183  "WFL0104"
184  )
185  ) ,
186  // test malformed $transitions or $cycle structure
187  array(
188  "PU_data_dcp_badfamily18.ods",
189  array(
190  "WFL0110",
191  "WFL0203"
192  )
193  )
194  );
195  }
196 
197  public function dataGoodFamilyFiles()
198  {
199  return array(
200  // test workflow family
201  array(
202  "PU_data_dcp_impworkflowfamily1.ods",
203  "TST_WFFAMIMP1",
204  true
205  )
206  );
207  }
208 }
209 ?>
static importDocument($file)
testErrorImportWorkflow($familyFile, $expectedErrors)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
testExecuteImportWorkflow($familyFile, $familyName)
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen