diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/FunctionTest.php | 32 | ||||
-rw-r--r-- | tests/units/Model/ProjectPermissionModelTest.php | 21 |
2 files changed, 51 insertions, 2 deletions
diff --git a/tests/units/FunctionTest.php b/tests/units/FunctionTest.php index 1c5f971d..0709f1fb 100644 --- a/tests/units/FunctionTest.php +++ b/tests/units/FunctionTest.php @@ -59,6 +59,38 @@ class FunctionTest extends Base $this->assertSame($expected, array_column_index($input, 'k1')); } + public function testArrayColumnIndexUnique() + { + $input = array( + array( + 'k1' => 11, + 'k2' => 22, + ), + array( + 'k1' => 11, + 'k2' => 55, + ), + array( + 'k1' => 33, + 'k2' => 44, + ), + array() + ); + + $expected = array( + 11 => array( + 'k1' => 11, + 'k2' => 22, + ), + 33 => array( + 'k1' => 33, + 'k2' => 44, + ) + ); + + $this->assertSame($expected, array_column_index_unique($input, 'k1')); + } + public function testArrayMergeRelation() { $relations = array( diff --git a/tests/units/Model/ProjectPermissionModelTest.php b/tests/units/Model/ProjectPermissionModelTest.php index 3313cf2d..7f604374 100644 --- a/tests/units/Model/ProjectPermissionModelTest.php +++ b/tests/units/Model/ProjectPermissionModelTest.php @@ -26,7 +26,7 @@ class ProjectPermissionModelTest extends Base $this->assertEquals(1, $projectModel->create(array('name' => 'Project 1'))); $this->assertEquals(2, $userModel->create(array('username' => 'user1'))); - $this->assertEquals(3, $userModel->create(array('username' => 'user2'))); + $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User 2', 'email' => 'test@here', 'avatar_path' => 'test'))); $this->assertEquals(4, $userModel->create(array('username' => 'user3'))); $this->assertEquals(1, $groupModel->create('Group A')); @@ -35,7 +35,24 @@ class ProjectPermissionModelTest extends Base $this->assertTrue($groupRoleModel->addGroup(1, 1, Role::PROJECT_MEMBER)); $this->assertTrue($userRoleModel->addUser(1, 3, Role::PROJECT_MANAGER)); - $this->assertEquals(array('user1', 'user2'), $projectPermissionModel->findUsernames(1, 'us')); + $expected = array( + 'user1' => array( + 'username' => 'user1', + 'name' => null, + 'email' => null, + 'avatar_path' => null, + 'id' => '2', + ), + 'user2' => array( + 'username' => 'user2', + 'name' => 'User 2', + 'email' => 'test@here', + 'avatar_path' => 'test', + 'id' => '3', + ) + ); + + $this->assertEquals($expected, $projectPermissionModel->findUsernames(1, 'us')); $this->assertEmpty($projectPermissionModel->findUsernames(1, 'a')); $this->assertEmpty($projectPermissionModel->findUsernames(2, 'user')); } |