]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - tests/UserRightsTest.php
Merge remote branch 'statusnet/0.8.x' into 0.9.x
[quix0rs-gnu-social.git] / tests / UserRightsTest.php
1 <?php
2
3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4     print "This script must be run from the command line\n";
5     exit();
6 }
7
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('STATUSNET', true);
10
11 require_once INSTALLDIR . '/lib/common.php';
12
13 class UserRightsTest extends PHPUnit_Framework_TestCase
14 {
15     protected $user = null;
16
17     function setUp()
18     {
19         $this->user = User::register(array('nickname' => 'userrightstestuser'));
20     }
21
22     function tearDown()
23     {
24         $profile = $this->user->getProfile();
25         $this->user->delete();
26         $profile->delete();
27     }
28
29     function testInvalidRole()
30     {
31         $this->assertFalse($this->user->hasRole('invalidrole'));
32     }
33
34     function standardRoles()
35     {
36         return array('admin', 'moderator');
37     }
38
39     /**
40      * @dataProvider standardRoles
41      *
42      */
43
44     function testUngrantedRole($role)
45     {
46         $this->assertFalse($this->user->hasRole($role));
47     }
48
49     /**
50      * @dataProvider standardRoles
51      *
52      */
53
54     function testGrantedRole($role)
55     {
56         $this->user->grantRole($role);
57         $this->assertFalse($this->user->hasRole($role));
58     }
59 }