633191d808
Orbited plugin may not work at all anymore, I had no means to try it. But there's a check whether 'LACONICA' is defined there, which is a very unlikely thing in the future. So far only tests and scripts have been migrated consistently, though.
74 lines
1.6 KiB
PHP
74 lines
1.6 KiB
PHP
<?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('GNUSOCIAL', true);
|
|
define('STATUSNET', true); // compatibility
|
|
|
|
require_once INSTALLDIR . '/lib/common.php';
|
|
|
|
class UserRightsTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
protected $user = null;
|
|
|
|
function setUp()
|
|
{
|
|
$user = User::getKV('nickname', 'userrightstestuser');
|
|
if ($user) {
|
|
// Leftover from a broken test run?
|
|
$profile = $user->getProfile();
|
|
$user->delete();
|
|
$profile->delete();
|
|
}
|
|
$this->user = User::register(array('nickname' => 'userrightstestuser'));
|
|
if (!$this->user) {
|
|
throw new Exception("Couldn't register userrightstestuser");
|
|
}
|
|
}
|
|
|
|
function tearDown()
|
|
{
|
|
if ($this->user) {
|
|
$profile = $this->user->getProfile();
|
|
$this->user->delete();
|
|
$profile->delete();
|
|
}
|
|
}
|
|
|
|
function testInvalidRole()
|
|
{
|
|
$this->assertFalse($this->user->hasRole('invalidrole'));
|
|
}
|
|
|
|
function standardRoles()
|
|
{
|
|
return array(array('admin'),
|
|
array('moderator'));
|
|
}
|
|
|
|
/**
|
|
* @dataProvider standardRoles
|
|
*
|
|
*/
|
|
|
|
function testUngrantedRole($role)
|
|
{
|
|
$this->assertFalse($this->user->hasRole($role));
|
|
}
|
|
|
|
/**
|
|
* @dataProvider standardRoles
|
|
*
|
|
*/
|
|
|
|
function testGrantedRole($role)
|
|
{
|
|
$this->user->grantRole($role);
|
|
$this->assertTrue($this->user->hasRole($role));
|
|
}
|
|
}
|