object = new DbSearch('pma_test');
$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'pma';
$GLOBALS['collation_connection'] = 'utf-8';
//mock DBI
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$dbi->expects($this->any())
->method('getColumns')
->with('pma', 'table1')
->will($this->returnValue(array()));
$dbi->expects($this->any())
->method('escapeString')
->will($this->returnArgument(0));
$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 protected functions by setting visibility to public.
*
* @param string $name method name
* @param array $params parameters for the invocation
*
* @return the output from the protected method.
*/
private function _callProtectedFunction($name, $params)
{
$class = new ReflectionClass('PMA\libraries\DbSearch');
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method->invokeArgs($this->object, $params);
}
/**
* Test for _getSearchSqls
*
* @return void
*/
public function testGetSearchSqls()
{
$this->assertEquals(
array (
'select_columns' => 'SELECT * FROM `pma`.`table1` WHERE FALSE',
'select_count' => 'SELECT COUNT(*) AS `count` FROM `pma`.`table1` ' .
'WHERE FALSE',
'delete' => 'DELETE FROM `pma`.`table1` WHERE FALSE'
),
$this->_callProtectedFunction(
'_getSearchSqls',
array('table1')
)
);
}
/**
* Test for getSearchResults
*
* @return void
*/
public function testGetSearchResults()
{
$this->assertEquals(
'