Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test case for PMA_relation #533

Merged
merged 3 commits into from Jul 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
84 changes: 81 additions & 3 deletions test/libraries/PMA_relation_test.php
Expand Up @@ -25,9 +25,11 @@ public function setUp()
$GLOBALS['cfg']['Server']['pmadb'] = 'phpmyadmin';
$_SESSION['relation'][$GLOBALS['server']] = "PMA_relation";
$_SESSION['PMA_Theme'] = new PMA_Theme();
$_SESSION['relation'] = array();

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

include_once 'libraries/relation.lib.php';
}
Expand Down Expand Up @@ -71,9 +73,6 @@ public function testPMA_queryAsControlUser()
*/
public function testPMA_getRelationsParam()
{
$GLOBALS['cfg']['ServerDefault'] = 0;
$_SESSION['relation'] = array();

$relationsPara = PMA_getRelationsParam();
$this->assertEquals(
false,
Expand Down Expand Up @@ -137,5 +136,84 @@ public function testPMA_getRelationsParam()
$retval
);
}

/**
* Test for PMA_getDisplayField
*
* @return void
*/
public function testPMA_getDisplayField()
{

$db = 'information_schema';
$table = 'CHARACTER_SETS';
$this->assertEquals(
'DESCRIPTION',
PMA_getDisplayField($db, $table)
);

$db = 'information_schema';
$table = 'TABLES';
$this->assertEquals(
'TABLE_COMMENT',
PMA_getDisplayField($db, $table)
);

$db = 'information_schema';
$table = 'PMA';
$this->assertEquals(
false,
PMA_getDisplayField($db, $table)
);

}

/**
* Test for PMA_getComments
*
* @return void
*/
public function testPMA_getComments()
{
$GLOBALS['cfg']['ServerDefault'] = 0;
$_SESSION['relation'] = array();

$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
->getMock();

$getColumnsResult = array(
array(
'Field' => 'field1',
'Type' => 'int(11)',
'Comment' => 'Comment1'
),
array(
'Field' => 'field2',
'Type' => 'text',
'Comment' => 'Comment1'
)
);
$dbi->expects($this->any())->method('getColumns')
->will($this->returnValue($getColumnsResult));

$GLOBALS['dbi'] = $dbi;

$db = 'information_schema';
$this->assertEquals(
array(''),
PMA_getComments($db)
);

$db = 'information_schema';
$table = 'TABLES';
$this->assertEquals(
array(
'field1' => 'Comment1',
'field2' => 'Comment1'
),
PMA_getComments($db, $table)
);
}
}