diff options
author | Evan Prodromou <evan@status.net> | 2009-09-15 15:28:11 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-09-27 21:11:45 -0400 |
commit | 6c069312e2911d3b2fe54d051354f579fde7bb63 (patch) | |
tree | cdc6ad4e49325fcb8808faa54544b90524b7e5dd /tests | |
parent | a8d1b7e9c26b4449a4a1e0e250f9b6766b2d8e62 (diff) |
user rights
Diffstat (limited to 'tests')
-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 |