Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_doccontrol.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  /**
14  * Test ->control() method on HELPAGE family
15  * @param array $data test specification
16  * @dataProvider dataHelpPage
17  */
18  public function testHelpPage($data)
19  {
20  $myAction = self::getAction();
21 
22  if (isset($data['import'])) {
23  if (!is_array($data['import'])) {
24  $data['import'] = array(
25  $data['import']
26  );
27  }
28  foreach ($data['import'] as $import) {
29  $this->importDocument($import);
30  }
31  }
32 
33  if (!isset($data['control']) || !is_array($data['control'])) {
34  return;
35  }
36 
37  foreach ($data['control'] as $controlIdx => & $control) {
38  $user = new_Doc(self::$dbaccess, $control['user']);
39  $this->assertTrue($user->isAlive() , sprintf("control#%s> Could not get user with id '%s'.", $controlIdx, $control['user']));
40 
41  $login = $user->getRawValue('us_login');
42  $this->assertNotEmpty($login, sprintf("control#%s> User with id '%s' have an empty login.", $controlIdx, $control['user']));
43 
44  $this->sudo($login);
45 
46  $doc = new_Doc(self::$dbaccess, $control['doc']);
47  $this->assertTrue($doc->isAlive() , sprintf("control#%s> Could not get document with id '%s'.", $controlIdx, $control['doc']));
48 
49  $permission = $doc->control($control['acl']);
50  if ($control['result'] === false) {
51  $this->assertNotEmpty($permission, sprintf("control#%s> Unexpected empty control value while expecting a non-empty value.", $controlIdx));
52  } else {
53  $this->assertEmpty($permission, sprintf("control#%s> Unexpected control value '%s' while expecting empty value.", $controlIdx, $permission));
54  }
55 
56  $this->exitSudo();
57  }
58  unset($control);
59  }
60 
61  public function dataHelpPage()
62  {
63  return array(
64  array(
65  /* 0 */
66  array(
67  "import" => array(
68  "PU_data_dcp_doccontrol_users.ods",
69  "PU_data_dcp_doccontrol_profiles.ods",
70  "PU_data_dcp_doccontrol_families.ods",
71  "PU_data_dcp_doccontrol_docs.ods"
72  ) ,
73  "control" => array(
74  array(
75  "user" => "TST_U_HOMER_SIMPSON",
76  "doc" => "TST_HELPPAGE_01",
77  "acl" => "view",
78  "result" => true
79  ) ,
80  array(
81  "user" => "TST_U_HOMER_SIMPSON",
82  "doc" => "TST_HELPPAGE_01",
83  "acl" => "edit",
84  "result" => false
85  ) ,
86  array(
87  "user" => "TST_U_MARGE_SIMPSON",
88  "doc" => "TST_HELPPAGE_01",
89  "acl" => "view",
90  "result" => true
91  ) ,
92  array(
93  "user" => "TST_U_MARGE_SIMPSON",
94  "doc" => "TST_HELPPAGE_01",
95  "acl" => "edit",
96  "result" => false
97  )
98  )
99  )
100  )
101  );
102  }
103 }
104 ?>
static sudo($login)
static importDocument($file)
$login
Definition: dav.php:40
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
$import
$data
← centre documentaire © anakeen