setSuperUserAccess() public méthode

Enable or disable Super user access to the given user login. Note: When granting Super User access all previous permissions of the user will be removed as the user gains access to everything.
public setSuperUserAccess ( string $userLogin, boolean | integer $hasSuperUserAccess )
$userLogin string the user login.
$hasSuperUserAccess boolean | integer true or '1' to grant Super User access, false or '0' to remove Super User access.
 public function testSetSuperUserAccess_ShouldAddAndRemoveSuperUserAccessOnlyForGivenLogin()
 {
     $this->api->addUser('login1', 'password1', '*****@*****.**', false);
     $this->api->addUser('login2', 'password2', '*****@*****.**', false);
     $this->api->addUser('login3', 'password3', '*****@*****.**', false);
     $this->api->setSuperUserAccess('login2', true);
     // test add Super User access
     $users = $this->api->getUsers();
     $this->assertEquals(0, $users[0]['superuser_access']);
     $this->assertEquals(1, $users[1]['superuser_access']);
     $this->assertEquals('login2', $users[1]['login']);
     $this->assertEquals(0, $users[2]['superuser_access']);
     // should also accept string '1' to add Super User access
     $this->api->setSuperUserAccess('login1', '1');
     // test remove Super User access
     $this->api->setSuperUserAccess('login2', false);
     $users = $this->api->getUsers();
     $this->assertEquals(1, $users[0]['superuser_access']);
     $this->assertEquals('login1', $users[0]['login']);
     $this->assertEquals(0, $users[1]['superuser_access']);
     $this->assertEquals(0, $users[2]['superuser_access']);
     $this->api->setSuperUserAccess('login3', true);
     // should also accept string '0' to remove Super User access
     $this->api->setSuperUserAccess('login1', '0');
     $users = $this->api->getUsers();
     $this->assertEquals(0, $users[0]['superuser_access']);
     $this->assertEquals(0, $users[1]['superuser_access']);
     $this->assertEquals('login3', $users[2]['login']);
     $this->assertEquals(1, $users[2]['superuser_access']);
 }
Exemple #2
0
 public function test_getSitesAccessFromUser_forSuperUser()
 {
     $user2 = 'userLogin2';
     $this->api->addUser($user2, 'password', '*****@*****.**');
     // new user doesn't have access to anything
     $access = $this->api->getSitesAccessFromUser($user2);
     $this->assertEmpty($access);
     $this->api->setSuperUserAccess($user2, true);
     // super user has admin access for every site
     $access = $this->api->getSitesAccessFromUser($user2);
     $expected = array(array('site' => 1, 'access' => 'admin'), array('site' => 2, 'access' => 'admin'), array('site' => 3, 'access' => 'admin'));
     $this->assertEquals($expected, $access);
 }