Merge pull request #474 from ayushchd/unit_testing

Fix unit test failures
This commit is contained in:
Michal Čihař 2013-07-01 13:18:35 -07:00
commit fb72df59eb
5 changed files with 18 additions and 14 deletions

View File

@ -21,8 +21,6 @@ class PMA_ConfigFile_Test extends PHPUnit_Framework_TestCase
{
protected $object;
protected $server;
/**
* Setup function for test cases
*
@ -31,10 +29,9 @@ class PMA_ConfigFile_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$GLOBALS['server'] = 1;
$GLOBALS['cfg']['AvailableCharsets'] = array();
$GLOBALS['server'] = 1;
$this->object = ConfigFile::getInstance();
$this->server = $GLOBALS['server'];
}
/**
@ -45,7 +42,6 @@ class PMA_ConfigFile_Test extends PHPUnit_Framework_TestCase
protected function tearDown()
{
$GLOBALS['server'] = $this->server;
unset($_SESSION[$this->readAttribute($this->object, "_id")]);
unset($this->object);
}
@ -57,7 +53,11 @@ class PMA_ConfigFile_Test extends PHPUnit_Framework_TestCase
* @test
*/
public function testConfigFileConstructor()
{
{
$attr_instance = new ReflectionProperty("ConfigFile", "_instance");
$attr_instance->setAccessible(true);
$attr_instance->setValue(null, null);
$this->object = ConfigFile::getInstance();
$cfg = $this->readAttribute($this->object, '_cfg');
$this->assertEquals(
@ -83,11 +83,11 @@ class PMA_ConfigFile_Test extends PHPUnit_Framework_TestCase
$this->assertEquals(
array(),
$_SESSION["ConfigFile" . $GLOBALS['server']]
$_SESSION["ConfigFile1"]
);
$this->assertAttributeEquals(
"ConfigFile" . $GLOBALS['server'],
"ConfigFile1",
"_id",
$this->object
);

View File

@ -242,7 +242,6 @@ class PMA_Tracker_Test extends PHPUnit_Framework_TestCase
PMA_Tracker::enable();
$trackingwork = $_SESSION['relation'][$GLOBALS['server']]['trackingwork'];
$_SESSION['relation'][$GLOBALS['server']]['trackingwork'] = false;
$this->assertFalse(
@ -260,8 +259,6 @@ class PMA_Tracker_Test extends PHPUnit_Framework_TestCase
$this->assertFalse(
PMA_Tracker::isTracked("pma_test_db", "pma_test_table2")
);
$_SESSION['relation'][$GLOBALS['server']]['trackingwork'] = $trackingwork;
}
/**
@ -958,8 +955,7 @@ class PMA_Tracker_Test extends PHPUnit_Framework_TestCase
"- ALTER DATABASE db1; -",
"DDL",
"ALTER DATABASE",
"",
"db1"
""
);
$query[] = array(
"- DROP DATABASE db1; -",

View File

@ -80,6 +80,7 @@ class PMA_MySQL_Charsets_Test extends PHPUnit_Framework_TestCase
'Cannot redefine constant/function - missing APD or/and runkit extension'
);
} else {
$GLOBALS['server'] = 1;
// test case for system schema
$this->assertEquals(
'utf8_general_ci',
@ -94,6 +95,7 @@ class PMA_MySQL_Charsets_Test extends PHPUnit_Framework_TestCase
}
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['DBG']['sql'] = false;
$this->assertEquals(
'utf8_general_ci',
PMA_getDbCollation('pma_test')
@ -285,6 +287,7 @@ class PMA_MySQL_Charsets_Test extends PHPUnit_Framework_TestCase
*/
public function testGetServerCollation()
{
$GLOBALS['server'] = 1;
$GLOBALS['cfg']['DBG']['sql'] = false;
$this->assertEquals('utf8_general_ci', PMA_getServerCollation());
}

View File

@ -145,7 +145,11 @@ class PMA_Transformation_Test extends PHPUnit_Framework_TestCase
* @return void
*/
public function testGetMime()
{
{
$_SESSION['relation'][$GLOBALS['server']]['commwork'] = true;
$_SESSION['relation'][$GLOBALS['server']]['db'] = "pmadb";
$_SESSION['relation'][$GLOBALS['server']]['column_info'] = "column_info";
$_SESSION['relation'][$GLOBALS['server']]['trackingwork'] = false;
$this->assertEquals(
array('o' => array(
'column_name' => 'o',

View File

@ -96,6 +96,7 @@ class PMA_DBI_Test extends PHPUnit_Framework_TestCase
*/
function testFormatError($number, $message, $expected)
{
$GLOBALS['server'] = 1;
$this->assertEquals(
$expected,
$GLOBALS['dbi']->formatError($number, $message)