Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_app_inherit_acl.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_application.php';
10 
12 {
13  public static function appConfig()
14  {
15  return array(
16  array(
17  "appRoot" => join(DIRECTORY_SEPARATOR, array(
19  "DCPTEST",
20  "app"
21  )) ,
22  "appName" => "INHERIT_ACL_A",
23  ) ,
24  array(
25  "appRoot" => join(DIRECTORY_SEPARATOR, array(
27  "DCPTEST",
28  "app"
29  )) ,
30  "appName" => "INHERIT_ACL_B",
31  "import" => array(
32  "PU_data_dcp_app_inherit_acl.ods"
33  )
34  )
35  );
36  }
37  /**
38  * Test applications inherited ACLs
39  * @param string $appName The application name
40  * @param string $aclName The ACL name
41  * @param string $userId The user id or logical name
42  * @param bool $expectedPermission The expected permission (true or false)
43  * @return void
44  * @dataProvider dataInheritedAcl
45  */
46  public function testInheritedAcl($appName, $aclName, $userId, $expectedPermission)
47  {
48  $myAction = self::getAction();
49 
50  $user = new_doc(self::$dbaccess, $userId);
51  $this->assertTrue($user->isAlive() , sprintf("Could not get user with id '%s'.", $userId));
52 
53  $wuser = new \User(self::$dbaccess, $user->getRawValue('us_whatid'));
54  $this->assertTrue(is_numeric($wuser->id) , sprintf("Invalid user what id '%s' for user '%s'.", $wuser->id, $userId));
55 
56  $this->sudo($wuser->login);
57 
58  $perm = $myAction->hasPermission($aclName, $appName);
59  $this->assertTrue($perm === $expectedPermission, sprintf("Unexpected permission '%s' while expecting '%s' for user '%s', ACL '%' and application '%s'.", ($perm ? 'true' : 'false') , ($expectedPermission ? 'true' : 'false') , $userId, $aclName, $appName));
60 
61  $this->exitSudo();
62  }
63  public static function dataInheritedAcl()
64  {
65  return array(
66  array(
67  "INHERIT_ACL_A",
68  "ACL_A_1",
69  "TST_U_INHERIT_ACL_1",
70  true
71  ) ,
72  array(
73  "INHERIT_ACL_A",
74  "ACL_A_2",
75  "TST_U_INHERIT_ACL_1",
76  false
77  ) ,
78  array(
79  "INHERIT_ACL_B",
80  "ACL_A_1",
81  "TST_U_INHERIT_ACL_1",
82  true
83  ) ,
84  array(
85  "INHERIT_ACL_B",
86  "ACL_A_2",
87  "TST_U_INHERIT_ACL_1",
88  false
89  )
90  );
91  }
92 }
static sudo($login)
testInheritedAcl($appName, $aclName, $userId, $expectedPermission)
const DEFAULT_PUBDIR
Definition: Lib.Prefix.php:28
$dbaccess
Definition: checkVault.php:17
← centre documentaire © anakeen