We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit a998bda4 authored by Brion Vibber's avatar Brion Vibber

Fix UserRightsTest unit tests

parent 0158f4f7
...@@ -329,7 +329,7 @@ class User extends Memcached_DataObject ...@@ -329,7 +329,7 @@ class User extends Memcached_DataObject
$profile->query('COMMIT'); $profile->query('COMMIT');
if ($email && !$user->email) { if (!empty($email) && !$user->email) {
mail_confirm_address($user, $confirm->code, $profile->nickname, $email); mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
} }
......
...@@ -16,15 +16,27 @@ class UserRightsTest extends PHPUnit_Framework_TestCase ...@@ -16,15 +16,27 @@ class UserRightsTest extends PHPUnit_Framework_TestCase
function setUp() 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')); $this->user = User::register(array('nickname' => 'userrightstestuser'));
if (!$this->user) {
throw new Exception("Couldn't register userrightstestuser");
}
} }
function tearDown() function tearDown()
{ {
if ($this->user) {
$profile = $this->user->getProfile(); $profile = $this->user->getProfile();
$this->user->delete(); $this->user->delete();
$profile->delete(); $profile->delete();
} }
}
function testInvalidRole() function testInvalidRole()
{ {
...@@ -33,7 +45,8 @@ class UserRightsTest extends PHPUnit_Framework_TestCase ...@@ -33,7 +45,8 @@ class UserRightsTest extends PHPUnit_Framework_TestCase
function standardRoles() function standardRoles()
{ {
return array('admin', 'moderator'); return array(array('admin'),
array('moderator'));
} }
/** /**
...@@ -54,6 +67,6 @@ class UserRightsTest extends PHPUnit_Framework_TestCase ...@@ -54,6 +67,6 @@ class UserRightsTest extends PHPUnit_Framework_TestCase
function testGrantedRole($role) function testGrantedRole($role)
{ {
$this->user->grantRole($role); $this->user->grantRole($role);
$this->assertFalse($this->user->hasRole($role)); $this->assertTrue($this->user->hasRole($role));
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment