]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix UserRightsTest unit tests
authorBrion Vibber <brion@pobox.com>
Tue, 15 Dec 2009 22:49:53 +0000 (14:49 -0800)
committerBrion Vibber <brion@pobox.com>
Wed, 16 Dec 2009 14:27:48 +0000 (09:27 -0500)
classes/User.php
tests/UserRightsTest.php

index d04f7d679ffca7abbd3858b377053cd88d42a1a5..c62314d50074217e29db0ca168e515a1a4f2048a 100644 (file)
@@ -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);
         }
 
index 6544ee53d75bac92dedb1df223314ea79b2529e3..d24a172f6f58adad60c030b1d0181b73eefac068 100644 (file)
@@ -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