From a998bda4a57014d0a319fd0bc31552705f0887ed Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 15 Dec 2009 14:49:53 -0800 Subject: Fix UserRightsTest unit tests --- tests/UserRightsTest.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/UserRightsTest.php b/tests/UserRightsTest.php index 6544ee53d..d24a172f6 100644 --- a/tests/UserRightsTest.php +++ b/tests/UserRightsTest.php @@ -16,14 +16,26 @@ class UserRightsTest extends PHPUnit_Framework_TestCase function setUp() { + $user = User::staticGet('nickname', 'userrightstestuser'); + if ($user) { + // Leftover from a broken test run? + $profile = $user->getProfile(); + $user->delete(); + $profile->delete(); + } $this->user = User::register(array('nickname' => 'userrightstestuser')); + if (!$this->user) { + throw new Exception("Couldn't register userrightstestuser"); + } } function tearDown() { - $profile = $this->user->getProfile(); - $this->user->delete(); - $profile->delete(); + if ($this->user) { + $profile = $this->user->getProfile(); + $this->user->delete(); + $profile->delete(); + } } function testInvalidRole() @@ -33,7 +45,8 @@ class UserRightsTest extends PHPUnit_Framework_TestCase function standardRoles() { - return array('admin', 'moderator'); + return array(array('admin'), + array('moderator')); } /** @@ -54,6 +67,6 @@ class UserRightsTest extends PHPUnit_Framework_TestCase function testGrantedRole($role) { $this->user->grantRole($role); - $this->assertFalse($this->user->hasRole($role)); + $this->assertTrue($this->user->hasRole($role)); } } \ No newline at end of file -- cgit v1.2.3-54-g00ecf