getUsersWithSiteAccess() public method

public getUsersWithSiteAccess ( $idSite, $access )
Exemplo n.º 1
0
 /**
  * normal case, set different access to different websites for multiple users
  */
 public function testSetUserAccessMultipleCallDistinctAccessMultipleUser()
 {
     $this->api->addUser("user1", "geqgegagae", "*****@*****.**", "alias");
     $this->api->addUser("user2", "geqgegagae", "*****@*****.**", "alias");
     list($id1, $id2, $id3) = $this->addSites(3);
     $this->api->setUserAccess("user1", "view", array($id1, $id2));
     $this->api->setUserAccess("user2", "admin", array($id1));
     $this->api->setUserAccess("user2", "view", array($id3, $id2));
     $access1 = $this->api->getSitesAccessFromUser("user1");
     $access1 = $this->_flatten($access1);
     $access2 = $this->api->getSitesAccessFromUser("user2");
     $access2 = $this->_flatten($access2);
     $wanted1 = array($id1 => 'view', $id2 => 'view');
     $wanted2 = array($id1 => 'admin', $id2 => 'view', $id3 => 'view');
     $this->assertEquals($wanted1, $access1);
     $this->assertEquals($wanted2, $access2);
     $access1 = $this->api->getUsersAccessFromSite($id1);
     $access2 = $this->api->getUsersAccessFromSite($id2);
     $access3 = $this->api->getUsersAccessFromSite($id3);
     $wanted1 = array('user1' => 'view', 'user2' => 'admin');
     $wanted2 = array('user1' => 'view', 'user2' => 'view');
     $wanted3 = array('user2' => 'view');
     $this->assertEquals($wanted1, $access1);
     $this->assertEquals($wanted2, $access2);
     $this->assertEquals($wanted3, $access3);
     $access1 = $this->api->getUsersSitesFromAccess('view');
     $access2 = $this->api->getUsersSitesFromAccess('admin');
     $wanted1 = array('user1' => array($id1, $id2), 'user2' => array($id2, $id3));
     $wanted2 = array('user2' => array($id1));
     $this->assertEquals($wanted1, $access1);
     $this->assertEquals($wanted2, $access2);
     // Test getUsersWithSiteAccess
     $users = $this->api->getUsersWithSiteAccess($id1, $access = 'view');
     $this->assertEquals(1, count($users));
     $this->assertEquals('user1', $users[0]['login']);
     $users = $this->api->getUsersWithSiteAccess($id2, $access = 'view');
     $this->assertEquals(2, count($users));
     $users = $this->api->getUsersWithSiteAccess($id1, $access = 'admin');
     $this->assertEquals(1, count($users));
     $this->assertEquals('user2', $users[0]['login']);
     $users = $this->api->getUsersWithSiteAccess($id3, $access = 'admin');
     $this->assertEquals(0, count($users));
 }