diff options
author | Teamjungla{CODE} <junglacode@gmail.com> | 2016-08-20 13:47:12 -0500 |
---|---|---|
committer | Teamjungla{CODE} <junglacode@gmail.com> | 2016-08-20 13:47:12 -0500 |
commit | fe8e9cdcfe3afc1475c7e7f4392d2b2cc601a12b (patch) | |
tree | 001403874e9e3716de7c6d51a9f536e9b3c3be5e /tests/units/Helper | |
parent | b1e795fc5b45369f7b9b565b1e106d2673361977 (diff) | |
parent | 98efcf21e355ed6ac3827058b99df86ca67c75bb (diff) |
Merge branch 'stable' of https://github.com/kanboard/kanboard
Diffstat (limited to 'tests/units/Helper')
-rw-r--r-- | tests/units/Helper/UserHelperTest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/units/Helper/UserHelperTest.php b/tests/units/Helper/UserHelperTest.php index 10bbc58e..4d1947d8 100644 --- a/tests/units/Helper/UserHelperTest.php +++ b/tests/units/Helper/UserHelperTest.php @@ -13,6 +13,21 @@ use Kanboard\Model\UserModel; class UserHelperTest extends Base { + public function testGetFullname() + { + $userModel = new UserModel($this->container); + $userHelper = new UserHelper($this->container); + + $this->assertEquals(2, $userModel->create(array('username' => 'user1'))); + $this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User #2'))); + + $user1 = $userModel->getById(2); + $user2 = $userModel->getById(3); + + $this->assertEquals('user1', $userHelper->getFullname($user1)); + $this->assertEquals('User #2', $userHelper->getFullname($user2)); + } + public function testInitials() { $helper = new UserHelper($this->container); @@ -31,6 +46,12 @@ class UserHelperTest extends Base $this->assertEquals('Project Viewer', $helper->getRoleName(Role::PROJECT_VIEWER)); } + public function testHasAccessWithoutSession() + { + $helper = new UserHelper($this->container); + $this->assertFalse($helper->hasAccess('UserCreationController', 'create')); + } + public function testHasAccessForAdmins() { $helper = new UserHelper($this->container); @@ -73,6 +94,15 @@ class UserHelperTest extends Base $this->assertTrue($helper->hasAccess('ProjectCreationController', 'createPrivate')); } + public function testHasProjectAccessWithoutSession() + { + $helper = new UserHelper($this->container); + $project = new ProjectModel($this->container); + + $this->assertEquals(1, $project->create(array('name' => 'My project'))); + $this->assertFalse($helper->hasProjectAccess('ProjectEditController', 'edit', 1)); + } + public function testHasProjectAccessForAdmins() { $helper = new UserHelper($this->container); |