Skip to content

Commit

Permalink
Merge pull request #533 from adamgsoc2013/UT_plu_parse
Browse files Browse the repository at this point in the history
add test case for PMA_relation
  • Loading branch information
nijel committed Jul 22, 2013
2 parents 1b34f8f + 7d3dda4 commit a649bcb
Showing 1 changed file with 81 additions and 3 deletions.
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)
);
}
}

0 comments on commit a649bcb

Please sign in to comment.