/** * Tests PMA_getHtmlForUserGroupsTable() function when there are user groups * * @return void */ public function testGetHtmlForUserGroupsTableWithUserGroups() { $expectedQuery = "SELECT * FROM `pmadb`.`usergroups`" . " ORDER BY `usergroup` ASC"; $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); $dbi->expects($this->once())->method('tryQuery')->with($expectedQuery)->will($this->returnValue(true)); $dbi->expects($this->once())->method('numRows')->withAnyParameters()->will($this->returnValue(1)); $dbi->expects($this->at(2))->method('fetchAssoc')->withAnyParameters()->will($this->returnValue(array('usergroup' => 'usergroup', 'tab' => 'server_sql', 'allowed' => 'Y'))); $dbi->expects($this->at(3))->method('fetchAssoc')->withAnyParameters()->will($this->returnValue(false)); $dbi->expects($this->once())->method('freeResult'); $GLOBALS['dbi'] = $dbi; $html = PMA_getHtmlForUserGroupsTable(); $this->assertContains('<td>usergroup</td>', $html); $url_tag = '<a class="" href="server_user_groups.php' . PMA_URL_getCommon(array('viewUsers' => 1, 'userGroup' => htmlspecialchars('usergroup'))); $this->assertContains($url_tag, $html); $url_tag = '<a class="" href="server_user_groups.php' . PMA_URL_getCommon(array('editUserGroup' => 1, 'userGroup' => htmlspecialchars('usergroup'))); $this->assertContains($url_tag, $html); $url_tag = '<a class="deleteUserGroup ajax" href="server_user_groups.php' . PMA_URL_getCommon(array('deleteUserGroup' => 1, 'userGroup' => htmlspecialchars('usergroup'))); $this->assertContains($url_tag, $html); }
* Add a new user group */ if (! empty($_REQUEST['addUserGroupSubmit'])) { PMA_editUserGroup($_REQUEST['userGroup'], true); } /** * Update a user group */ if (! empty($_REQUEST['editUserGroupSubmit'])) { PMA_editUserGroup($_REQUEST['userGroup']); } if (isset($_REQUEST['viewUsers'])) { // Display users belonging to a user group $response->addHTML(PMA_getHtmlForListingUsersofAGroup($_REQUEST['userGroup'])); } if (isset($_REQUEST['addUserGroup'])) { // Display add user group dialog $response->addHTML(PMA_getHtmlToEditUserGroup()); } elseif (isset($_REQUEST['editUserGroup'])) { // Display edit user group dialog $response->addHTML(PMA_getHtmlToEditUserGroup($_REQUEST['userGroup'])); } else { // Display user groups table $response->addHTML(PMA_getHtmlForUserGroupsTable()); } $response->addHTML('</div>');