Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_importprofil.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 testErrorImportProfil($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"));
33  }
34  }
35  /**
36  * @dataProvider dataGoodFamilyFiles
37  */
38  public function testExecuteImportProfil($familyFile)
39  {
40  $err = '';
41  try {
42  $this->importDocument($familyFile);
43  }
44  catch(\Exception $e) {
45  $err = $e->getMessage();
46  }
47  $this->assertEmpty($err, sprintf("profil error detected : %s", $err));
48  }
49 
50  public function dataBadFamilyFiles()
51  {
52  return array(
53  // test unknow profid
54  array(
55  "PU_data_dcp_badprofil1.ods",
56  array(
57  "PRFL0001",
58  "PRFL0002",
59  "first",
60  "second",
61  "PRFL0003",
62  "third",
63  "TST_PDOC1",
64  "PRFL0004",
65  "PRFL0005",
66  "special"
67  )
68  ) ,
69  array(
70  "PU_data_dcp_badprofil2.ods",
71  array(
72  "PRFL0100",
73  "aclfour",
74  "PRFL0101",
75  "aclfive",
76  "PRFL0103",
77  "TST_JOHNDOE"
78  )
79  ) ,
80  array(
81  "PU_data_dcp_badprofil3.ods",
82  array(
83  "PRFL0200",
84  'TST_DYNPDOC1',
85  'nothing',
86  'TST_DYNPDOC2',
87  "PRFL0201",
88  'tst_title',
89  'TST_DYNPDOC3',
90  "PRFL0203",
91  'TST_DYNPDOC4',
92  "PRFL0201",
93  "tst_reltwo"
94  )
95  ) ,
96 
97  array(
98  "PU_data_dcp_badprofil4.ods",
99  array(
100  "PRFL0202",
101  "family document test"
102  )
103  )
104  );
105  }
106 
107  public function dataGoodFamilyFiles()
108  {
109  return array(
110  // test profil ref
111  array(
112  "PU_data_dcp_goodprofil1.ods"
113  )
114  );
115  }
116 }
117 ?>
static importDocument($file)
testErrorImportProfil($familyFile, $expectedErrors)
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen