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('GNUSOCIAL', true);
10 define('STATUSNET', true); // compatibility
12 require_once INSTALLDIR . '/lib/common.php';
14 class UserRightsTest extends PHPUnit_Framework_TestCase
16 protected $user = null;
20 $user = User::getKV('nickname', 'userrightstestuser');
22 if ($user instanceof User) {
23 // Leftover from a broken test run?
24 $profile = $user->getProfile();
29 $this->user = User::register(array('nickname' => 'userrightstestuser'));
32 throw new Exception("Couldn't register userrightstestuser");
39 $profile = $this->user->getProfile();
40 $this->user->delete();
45 function testInvalidRole()
47 $this->assertFalse($this->user->hasRole('invalidrole'));
50 function standardRoles()
52 return array(array('admin'),
57 * @dataProvider standardRoles
61 function testUngrantedRole($role)
63 $this->assertFalse($this->user->hasRole($role));
67 * @dataProvider standardRoles
71 function testGrantedRole($role)
73 $this->user->grantRole($role);
74 $this->assertTrue($this->user->hasRole($role));