Skip to content

Commit

Permalink
add more case for PMA_relation
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgsoc2013 committed Jul 8, 2013
1 parent 0265241 commit d100971
Showing 1 changed file with 58 additions and 12 deletions.
70 changes: 58 additions & 12 deletions test/libraries/PMA_relation_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Include to test.
*/
require_once 'libraries/Util.class.php';
require_once 'libraries/Theme.class.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/Tracker.class.php';
Expand All @@ -19,11 +20,14 @@ class PMA_Relation_Test extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$GLOBALS['server'] = "table";
$GLOBALS['server'] = 1;
$GLOBALS['cfg']['Server']['user'] = 'root';
$GLOBALS['cfg']['Server']['pmadb'] = 'phpmyadmin';
$_SESSION['relation'][$GLOBALS['server']] = "PMA_relation";
$GLOBALS['server'] = 1;
$_SESSION['PMA_Theme'] = new PMA_Theme();

$GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath();
$GLOBALS['pmaThemeImage'] = 'theme/';

include_once 'libraries/relation.lib.php';
}
Expand All @@ -41,21 +45,21 @@ public function testPMA_queryAsControlUser()

$dbi->expects($this->once())
->method('query')
->will($this->returnValue('executed'));
->will($this->returnValue('executeResult1'));

$dbi->expects($this->once())
->method('tryQuery')
->will($this->returnValue('executed'));
->will($this->returnValue('executeResult2'));

$GLOBALS['dbi'] = $dbi;

$sql = "insert into PMA_bookmark A,B values(1, 2)";
$this->assertEquals(
'executed',
'executeResult1',
PMA_queryAsControlUser($sql)
);
$this->assertEquals(
'executed',
'executeResult2',
PMA_queryAsControlUser($sql, false)
);
}
Expand All @@ -69,27 +73,69 @@ public function testPMA_getRelationsParam()
{
$GLOBALS['cfg']['ServerDefault'] = 0;
$_SESSION['relation'] = array();
$_SESSION['relation'][$GLOBALS['server']]['relwork'] = "relwork";
$GLOBALS['server'] = "table";

$relationsPara = PMA_getRelationsParam();
$this->assertEquals(
false,
$relationsPara['relwork']
);
$this->assertEquals(
false,
$relationsPara['bookmarkwork']
);
$this->assertEquals(
'root',
$relationsPara['user']
);
$this->assertEquals(
'phpmyadmin',
$relationsPara['db']
);

$retval = PMA_getRelationsParamDiagnostic($GLOBALS['cfgRelation']);
$retval = PMA_getRelationsParamDiagnostic($relationsPara);
//check $cfg['Servers'][$i]['pmadb']
$this->assertContains(
'<font color="green">Disabled</font>',
"\$cfg['Servers'][\$i]['pmadb']",
$retval
);
$this->assertContains(
'General relation features',
'<strong>OK</strong>',
$retval
);

//$cfg['Servers'][$i]['relation']
$result = "\$cfg['Servers'][\$i]['pmadb'] ... </th><td class=\"right\">"
. "<font color=\"green\"><strong>OK</strong></font>";
$this->assertContains(
'<strong>not OK</strong>',
$result,
$retval
);
// $cfg['Servers'][$i]['relation']
$result = "\$cfg['Servers'][\$i]['relation'] ... </th><td class=\"right\">"
. "<font color=\"red\"><strong>not OK</strong></font>";
$this->assertContains(
$result,
$retval
);
// General relation features
$result = 'General relation features: <font color="red">Disabled</font>';
$this->assertContains(
$result,
$retval
);
// $cfg['Servers'][$i]['table_info']
$result = "\$cfg['Servers'][\$i]['table_info'] ... </th><td class=\"right\">"
. "<font color=\"red\"><strong>not OK</strong></font>";
$this->assertContains(
$result,
$retval
);
// Display Features:
$result = 'Display Features: <font color="red">Disabled</font>';
$this->assertContains(
$result,
$retval
);
}
}

0 comments on commit d100971

Please sign in to comment.