diff options
author | Evan Prodromou <evan@status.net> | 2009-10-01 11:30:04 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-10-01 11:30:04 -0400 |
commit | a41ed1a66a902b078876be7528183ab61e6a3d03 (patch) | |
tree | db690c52820ebd4aefae6222cb4f3b48c2d9398f /tests/UserRightsTest.php | |
parent | 3449843f839b6c17618b27b031c608860761cd32 (diff) | |
parent | acc78972383c2346b5729192ab00c90c48c5b2a6 (diff) |
Merge branch '0.9.x' into schema
Diffstat (limited to 'tests/UserRightsTest.php')
-rw-r--r-- | tests/UserRightsTest.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/UserRightsTest.php b/tests/UserRightsTest.php new file mode 100644 index 000000000..6544ee53d --- /dev/null +++ b/tests/UserRightsTest.php @@ -0,0 +1,59 @@ +<?php + +if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + print "This script must be run from the command line\n"; + exit(); +} + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('STATUSNET', true); + +require_once INSTALLDIR . '/lib/common.php'; + +class UserRightsTest extends PHPUnit_Framework_TestCase +{ + protected $user = null; + + function setUp() + { + $this->user = User::register(array('nickname' => 'userrightstestuser')); + } + + function tearDown() + { + $profile = $this->user->getProfile(); + $this->user->delete(); + $profile->delete(); + } + + function testInvalidRole() + { + $this->assertFalse($this->user->hasRole('invalidrole')); + } + + function standardRoles() + { + return array('admin', 'moderator'); + } + + /** + * @dataProvider standardRoles + * + */ + + function testUngrantedRole($role) + { + $this->assertFalse($this->user->hasRole($role)); + } + + /** + * @dataProvider standardRoles + * + */ + + function testGrantedRole($role) + { + $this->user->grantRole($role); + $this->assertFalse($this->user->hasRole($role)); + } +}
\ No newline at end of file |