PMA_VERSION, 'db' => 'pmadb', 'users' => 'users', 'usergroups' => 'usergroups' ); $GLOBALS['pmaThemeImage'] = 'image'; $_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new Theme(); } /** * Tests PMA_getHtmlForUserGroupsTable() function when there are no user groups * * @return void * @group medium */ public function testGetHtmlForUserGroupsTableWithNoUserGroups() { $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(0)); $dbi->expects($this->once()) ->method('freeResult'); $GLOBALS['dbi'] = $dbi; $html = PMA_getHtmlForUserGroupsTable(); $this->assertNotContains( '', $html ); $url_tag = '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( '', $html ); $url_tag = 'getMockBuilder('PMA\libraries\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $dbi->expects($this->at(1)) ->method('query') ->with($userDelQuery); $dbi->expects($this->at(3)) ->method('query') ->with($userGrpDelQuery); $dbi->expects($this->any()) ->method('escapeString') ->will($this->returnArgument(0)); $GLOBALS['dbi'] = $dbi; PMA_deleteUserGroup('ug'); } /** * Tests PMA_getHtmlToEditUserGroup() function * * @return void */ public function testGetHtmlToEditUserGroup() { // adding a user group $html = PMA_getHtmlToEditUserGroup(); $this->assertContains( 'assertContains( 'getMockBuilder('PMA\libraries\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $dbi->expects($this->once()) ->method('tryQuery') ->with($expectedQuery) ->will($this->returnValue(true)); $dbi->expects($this->exactly(2)) ->method('fetchAssoc') ->willReturnOnConsecutiveCalls( array( 'usergroup' => 'ug', 'tab' => 'server_sql', 'allowed' => 'Y' ), false ); $dbi->expects($this->once()) ->method('freeResult'); $dbi->expects($this->any()) ->method('escapeString') ->will($this->returnArgument(0)); $GLOBALS['dbi'] = $dbi; // editing a user group $html = PMA_getHtmlToEditUserGroup('ug'); $this->assertContains( 'assertContains( 'assertContains( 'assertContains( '', $html ); $this->assertContains( '', $html ); } }
usergroup