assertSame($expectedValue, LuPermissionsDataAccess::getUserEffectivePermissionByName($userId, $permissionName)); $this->assertSame($expectedValue, LuPermissionsDataAccess::getUserEffectivePermissionById($userId, $permissionId)); } public function testPermission0True() { static::permissionTest(true, "LU_TEST_SIMPLE_TRUE", 3, 0); } public function testPermission0False() { static::permissionTest(false, "LU_TEST_SIMPLE_FALSE", 4, 0); } public function testPermission0DoesNotExist() { static::permissionTest(null, "LU_TEST_DOES_NOT_EXIST", 0, 0); } public function testPermissionGroup1True() { static::permissionTest(true, "LU_TEST_GROUP_1_TRUE", 5, 1); } public function testPermissionGroup1False() { static::permissionTest(false, "LU_TEST_GROUP_1_FALSE", 6, 1); } public function testPermissionGroup2MultipleGroupsTrue() { static::permissionTest(true, "LU_TEST_GROUP_2_TRUE", 7, 2); } public function testPermissionGroup3MultipleGroupsTrueFalse() { static::permissionTest(false, "LU_TEST_GROUP_3_FALSE", 8, 3); } public function testPermissionGroup4MultipleGroupsFalse() { static::permissionTest(false, "LU_TEST_GROUP_4_FALSE", 9, 4); } public function testPermissionUser5True() { static::permissionTest(true, "LU_TEST_USER_5_TRUE", 10, 5); } public function testPermissionUser6False() { static::permissionTest(false, "LU_TEST_USER_6_FALSE", 11, 6); } public function testPermissionGetAll0() { $permissions = [ ["id" => 6, "name" =>"LU_TEST_GROUP_1_FALSE", "value" => true], ["id" => 5, "name" => "LU_TEST_GROUP_1_TRUE", "value" => true], ["id" => 7, "name" => "LU_TEST_GROUP_2_TRUE", "value" => false], ["id" => 8, "name" => "LU_TEST_GROUP_3_FALSE", "value" => true], ["id" => 9, "name" => "LU_TEST_GROUP_4_FALSE", "value" => true], ["id" => 4, "name" => "LU_TEST_SIMPLE_FALSE", "value" => false], ["id" => 3, "name" => "LU_TEST_SIMPLE_TRUE", "value" => true], ["id" => 10, "name" => "LU_TEST_USER_5_TRUE", "value" => false], ["id" => 11, "name" => "LU_TEST_USER_6_FALSE", "value" => true]]; $this->assertSame($permissions, LuDbo::serializeValue(LuPermissionsDataAccess::getUserEffectivePermissions(0))); } public function testPermissionGetAll4() { $permissions = [ ["id" => 6, "name" =>"LU_TEST_GROUP_1_FALSE", "value" => true], ["id" => 5, "name" => "LU_TEST_GROUP_1_TRUE", "value" => true], ["id" => 7, "name" => "LU_TEST_GROUP_2_TRUE", "value" => false], ["id" => 8, "name" => "LU_TEST_GROUP_3_FALSE", "value" => true], ["id" => 9, "name" => "LU_TEST_GROUP_4_FALSE", "value" => false], ["id" => 4, "name" => "LU_TEST_SIMPLE_FALSE", "value" => false], ["id" => 3, "name" => "LU_TEST_SIMPLE_TRUE", "value" => true], ["id" => 10, "name" => "LU_TEST_USER_5_TRUE", "value" => false], ["id" => 11, "name" => "LU_TEST_USER_6_FALSE", "value" => true]]; $this->assertSame($permissions, LuDbo::serializeValue(LuPermissionsDataAccess::getUserEffectivePermissions(4))); } public function testPermissionGetAll6() { $permissions = [ ["id" => 6, "name" =>"LU_TEST_GROUP_1_FALSE", "value" => true], ["id" => 5, "name" => "LU_TEST_GROUP_1_TRUE", "value" => true], ["id" => 7, "name" => "LU_TEST_GROUP_2_TRUE", "value" => false], ["id" => 8, "name" => "LU_TEST_GROUP_3_FALSE", "value" => true], ["id" => 9, "name" => "LU_TEST_GROUP_4_FALSE", "value" => true], ["id" => 4, "name" => "LU_TEST_SIMPLE_FALSE", "value" => false], ["id" => 3, "name" => "LU_TEST_SIMPLE_TRUE", "value" => true], ["id" => 10, "name" => "LU_TEST_USER_5_TRUE", "value" => false], ["id" => 11, "name" => "LU_TEST_USER_6_FALSE", "value" => false]]; $this->assertSame($permissions, LuDbo::serializeValue(LuPermissionsDataAccess::getUserEffectivePermissions(6))); } }