diff options
-rw-r--r-- | classes/User.php | 2 | ||||
-rw-r--r-- | tests/UserRightsTest.php | 23 |
2 files changed, 19 insertions, 6 deletions
diff --git a/classes/User.php b/classes/User.php index d04f7d679..c62314d50 100644 --- a/classes/User.php +++ b/classes/User.php @@ -329,7 +329,7 @@ class User extends Memcached_DataObject $profile->query('COMMIT'); - if ($email && !$user->email) { + if (!empty($email) && !$user->email) { mail_confirm_address($user, $confirm->code, $profile->nickname, $email); } 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 |