3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4 print "This script must be run from the command line\n";
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('STATUSNET', true);
11 require_once INSTALLDIR . '/lib/common.php';
13 class UserRightsTest extends PHPUnit_Framework_TestCase
15 protected $user = null;
19 $user = User::staticGet('nickname', 'userrightstestuser');
21 // Leftover from a broken test run?
22 $profile = $user->getProfile();
26 $this->user = User::register(array('nickname' => 'userrightstestuser'));
28 throw new Exception("Couldn't register userrightstestuser");
35 $profile = $this->user->getProfile();
36 $this->user->delete();
41 function testInvalidRole()
43 $this->assertFalse($this->user->hasRole('invalidrole'));
46 function standardRoles()
48 return array(array('admin'),
53 * @dataProvider standardRoles
57 function testUngrantedRole($role)
59 $this->assertFalse($this->user->hasRole($role));
63 * @dataProvider standardRoles
67 function testGrantedRole($role)
69 $this->user->grantRole($role);
70 $this->assertTrue($this->user->hasRole($role));