|
@@ -1,6 +1,7 @@
|
1
|
1
|
<?php
|
2
|
|
-use Luticate\Auth\DataAccess\Sp\SpLuGetUserEffectivePermissionById;
|
3
|
|
-use Luticate\Auth\DataAccess\Sp\SpLuGetUserEffectivePermissionByName;
|
|
2
|
+
|
|
3
|
+use Luticate\Auth\DataAccess\LuPermissionsDataAccess;
|
|
4
|
+use Luticate\Utils\Dbo\LuDbo;
|
4
|
5
|
|
5
|
6
|
/**
|
6
|
7
|
* Created by PhpStorm.
|
|
@@ -12,8 +13,8 @@ class LuPermissionTest extends \PHPUnit_Framework_TestCase
|
12
|
13
|
{
|
13
|
14
|
protected function permissionTest($expectedValue, string $permissionName, int $permissionId, int $userId)
|
14
|
15
|
{
|
15
|
|
- $this->assertSame($expectedValue, SpLuGetUserEffectivePermissionByName::getPermissionValue($userId, $permissionName));
|
16
|
|
- $this->assertSame($expectedValue, SpLuGetUserEffectivePermissionById::getPermissionValue($userId, $permissionId));
|
|
16
|
+ $this->assertSame($expectedValue, LuPermissionsDataAccess::getUserEffectivePermissionByName($userId, $permissionName));
|
|
17
|
+ $this->assertSame($expectedValue, LuPermissionsDataAccess::getUserEffectivePermissionById($userId, $permissionId));
|
17
|
18
|
}
|
18
|
19
|
|
19
|
20
|
public function testPermission0True()
|
|
@@ -65,4 +66,52 @@ class LuPermissionTest extends \PHPUnit_Framework_TestCase
|
65
|
66
|
{
|
66
|
67
|
static::permissionTest(false, "LU_TEST_USER_6_FALSE", 11, 6);
|
67
|
68
|
}
|
|
69
|
+
|
|
70
|
+ public function testPermissionGetAll0()
|
|
71
|
+ {
|
|
72
|
+ $permissions = [
|
|
73
|
+ ["id" => 6, "name" =>"LU_TEST_GROUP_1_FALSE", "value" => true],
|
|
74
|
+ ["id" => 5, "name" => "LU_TEST_GROUP_1_TRUE", "value" => true],
|
|
75
|
+ ["id" => 7, "name" => "LU_TEST_GROUP_2_TRUE", "value" => false],
|
|
76
|
+ ["id" => 8, "name" => "LU_TEST_GROUP_3_FALSE", "value" => true],
|
|
77
|
+ ["id" => 9, "name" => "LU_TEST_GROUP_4_FALSE", "value" => true],
|
|
78
|
+ ["id" => 4, "name" => "LU_TEST_SIMPLE_FALSE", "value" => false],
|
|
79
|
+ ["id" => 3, "name" => "LU_TEST_SIMPLE_TRUE", "value" => true],
|
|
80
|
+ ["id" => 10, "name" => "LU_TEST_USER_5_TRUE", "value" => false],
|
|
81
|
+ ["id" => 11, "name" => "LU_TEST_USER_6_FALSE", "value" => true]];
|
|
82
|
+
|
|
83
|
+ $this->assertSame($permissions, LuDbo::serializeValue(LuPermissionsDataAccess::getUserEffectivePermissions(0)));
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ public function testPermissionGetAll4()
|
|
87
|
+ {
|
|
88
|
+ $permissions = [
|
|
89
|
+ ["id" => 6, "name" =>"LU_TEST_GROUP_1_FALSE", "value" => true],
|
|
90
|
+ ["id" => 5, "name" => "LU_TEST_GROUP_1_TRUE", "value" => true],
|
|
91
|
+ ["id" => 7, "name" => "LU_TEST_GROUP_2_TRUE", "value" => false],
|
|
92
|
+ ["id" => 8, "name" => "LU_TEST_GROUP_3_FALSE", "value" => true],
|
|
93
|
+ ["id" => 9, "name" => "LU_TEST_GROUP_4_FALSE", "value" => false],
|
|
94
|
+ ["id" => 4, "name" => "LU_TEST_SIMPLE_FALSE", "value" => false],
|
|
95
|
+ ["id" => 3, "name" => "LU_TEST_SIMPLE_TRUE", "value" => true],
|
|
96
|
+ ["id" => 10, "name" => "LU_TEST_USER_5_TRUE", "value" => false],
|
|
97
|
+ ["id" => 11, "name" => "LU_TEST_USER_6_FALSE", "value" => true]];
|
|
98
|
+
|
|
99
|
+ $this->assertSame($permissions, LuDbo::serializeValue(LuPermissionsDataAccess::getUserEffectivePermissions(4)));
|
|
100
|
+ }
|
|
101
|
+
|
|
102
|
+ public function testPermissionGetAll6()
|
|
103
|
+ {
|
|
104
|
+ $permissions = [
|
|
105
|
+ ["id" => 6, "name" =>"LU_TEST_GROUP_1_FALSE", "value" => true],
|
|
106
|
+ ["id" => 5, "name" => "LU_TEST_GROUP_1_TRUE", "value" => true],
|
|
107
|
+ ["id" => 7, "name" => "LU_TEST_GROUP_2_TRUE", "value" => false],
|
|
108
|
+ ["id" => 8, "name" => "LU_TEST_GROUP_3_FALSE", "value" => true],
|
|
109
|
+ ["id" => 9, "name" => "LU_TEST_GROUP_4_FALSE", "value" => true],
|
|
110
|
+ ["id" => 4, "name" => "LU_TEST_SIMPLE_FALSE", "value" => false],
|
|
111
|
+ ["id" => 3, "name" => "LU_TEST_SIMPLE_TRUE", "value" => true],
|
|
112
|
+ ["id" => 10, "name" => "LU_TEST_USER_5_TRUE", "value" => false],
|
|
113
|
+ ["id" => 11, "name" => "LU_TEST_USER_6_FALSE", "value" => false]];
|
|
114
|
+
|
|
115
|
+ $this->assertSame($permissions, LuDbo::serializeValue(LuPermissionsDataAccess::getUserEffectivePermissions(6)));
|
|
116
|
+ }
|
68
|
117
|
}
|