X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2FUserRightsTest.php;h=bd9124a91d38b1dd0cc6dcb793a9b7c12ff4d7d3;hb=0e91a38c9c8cbaec0d29c5762b8194d2044e848b;hp=6544ee53d75bac92dedb1df223314ea79b2529e3;hpb=2d8ad0409d8e78ec35a65156bc375eacbe561963;p=quix0rs-gnu-social.git diff --git a/tests/UserRightsTest.php b/tests/UserRightsTest.php index 6544ee53d7..bd9124a91d 100644 --- a/tests/UserRightsTest.php +++ b/tests/UserRightsTest.php @@ -6,7 +6,8 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { } define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('STATUSNET', true); +define('GNUSOCIAL', true); +define('STATUSNET', true); // compatibility require_once INSTALLDIR . '/lib/common.php'; @@ -16,14 +17,26 @@ class UserRightsTest extends PHPUnit_Framework_TestCase function setUp() { + $user = User::getKV('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 +46,8 @@ class UserRightsTest extends PHPUnit_Framework_TestCase function standardRoles() { - return array('admin', 'moderator'); + return array(array('admin'), + array('moderator')); } /** @@ -54,6 +68,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 +}