Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_importaccess.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 testErrorImportAccess($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("access : not the correct error reporting : %s", $err));
33  }
34  }
35  /**
36  * @dataProvider dataGoodFamilyFiles
37  */
38  public function testExecuteImportAccess($familyFile, $userid, $appName, array $acls)
39  {
40  $err = '';
41  try {
42  $this->importDocument($familyFile);
43  }
44  catch(\Exception $e) {
45  $err = $e->getMessage();
46  }
47  $this->assertEmpty($err, sprintf("access error detected %s", $err));
48  $this->sudo($userid);
49  foreach ($acls as $acl) {
50  $hasPriv = $this->getAction()->HasPermission($acl, $appName);
51  $this->assertTrue($hasPriv, sprintf("access error privilege"));
52  }
53  $this->exitSudo();
54  }
55 
56  public function dataBadFamilyFiles()
57  {
58  return array(
59  // test unknow profid
60  array(
61  "PU_data_dcp_badaccess1.ods",
62  array(
63  "ACCS0001",
64  "TSTAPPUNKNOW"
65  )
66  ) ,
67  // test unknow acl
68  array(
69  "PU_data_dcp_badaccess2.ods",
70  array(
71  "ACCS0002",
72  "SYSTEM2",
73  "ACCS0004",
74  "acl test",
75  "ACCS0003",
76  "GTST_UNKNOW",
77  "ACCS0007",
78  "ACCS0005",
79  "not an application",
80  "ACCS0006"
81  )
82  )
83  );
84  }
85 
86  public function dataGoodFamilyFiles()
87  {
88  return array(
89  // test access
90  array(
91  "PU_data_dcp_goodaccess1.ods",
92  "GADMIN",
93  "FDL",
94  array(
95  "SYSTEM",
96  "NORMAL"
97  )
98  )
99  );
100  }
101 }
102 ?>
static sudo($login)
testExecuteImportAccess($familyFile, $userid, $appName, array $acls)
static importDocument($file)
testErrorImportAccess($familyFile, $expectedErrors)
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen