1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- use Luticate\Auth\DataAccess\Sp\SpLuGetUserPermissionById;
- use Luticate\Auth\DataAccess\Sp\SpLuGetUserPermissionByName;
-
- /**
- * Created by PhpStorm.
- * User: robin
- * Date: 7/2/16
- * Time: 5:26 PM
- */
- class LuPermissionTest extends \PHPUnit_Framework_TestCase
- {
- protected function permissionTest($expectedValue, string $permissionName, int $permissionId, int $userId)
- {
- $this->assertSame($expectedValue, SpLuGetUserPermissionByName::getPermissionValue($userId, $permissionName));
- $this->assertSame($expectedValue, SpLuGetUserPermissionById::getPermissionValue($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);
- }
- }
|