object = new DisplayResults('as', '', '', ''); $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['PMA_Config']->enableBc(); $GLOBALS['text_dir'] = 'ltr'; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $dbi->expects($this->any())->method('fieldFlags') ->will($this->returnArgument(1)); $GLOBALS['dbi'] = $dbi; } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. * * @access protected * @return void */ protected function tearDown() { unset($this->object); } /** * Call private functions by setting visibility to public. * * @param string $name method name * @param array $params parameters for the invocation * * @return mixed the output from the private method. */ private function _callPrivateFunction($name, array $params) { $class = new ReflectionClass(DisplayResults::class); $method = $class->getMethod($name); $method->setAccessible(true); return $method->invokeArgs($this->object, $params); } /** * Test for _isSelect function * * @return void */ public function testisSelect() { $parser = new Parser('SELECT * FROM pma'); $this->assertTrue( $this->_callPrivateFunction( '_isSelect', [ [ 'statement' => $parser->statements[0], 'select_from' => true, ], ] ) ); } /** * Test for navigation buttons * * @param string $caption iconic caption for button * @param string $title text for button * @param integer $pos position for next query * @param string $html_sql_query query ready for display * * @return void * * @dataProvider providerForTestGetTableNavigationButton */ public function testGetTableNavigationButton( $caption, $title, $pos, $html_sql_query ) { $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; $_SESSION[' PMA_token '] = 'token'; $actual = $this->_callPrivateFunction( '_getTableNavigationButton', [&$caption, $title, $pos, $html_sql_query, true] ); $this->assertContains( '