add test case for PMA_Node classes

This commit is contained in:
adamgsoc2013 2013-05-06 22:01:15 +08:00
parent 87f98e4d84
commit fce4d79b95
3 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,51 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for NodeFactory class and Node_Column class
*
* @package PhpMyAdmin-test
*/
require_once 'libraries/navigation/NodeFactory.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Theme.class.php';
class Node_Function_Test extends PHPUnit_Framework_TestCase
{
public function setup()
{
$GLOBALS['server'] = 0;
$GLOBALS['token'] = 'token';
$_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme');
}
public function testConstructor()
{
$parent = PMA_NodeFactory::getInstance('Node_Function');
$this->assertArrayHasKey(
'text',
$parent->links
);
$this->assertContains(
'db_routines.php',
$parent->links['text']
);
}
public function testAddNode()
{
$parent = PMA_NodeFactory::getInstance('Node_Function', 'parent');
$child = PMA_NodeFactory::getInstance('Node_Function', 'child');
$parent->addChild($child);
$this->assertEquals(
$parent->getChild($child->name),
$child
);
$this->assertEquals(
$parent->getChild($child->real_name, true),
$child
);
}
}
?>

View File

@ -0,0 +1,51 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for NodeFactory class and Node_Column class
*
* @package PhpMyAdmin-test
*/
require_once 'libraries/navigation/NodeFactory.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Theme.class.php';
class Node_Index_Test extends PHPUnit_Framework_TestCase
{
public function setup()
{
$GLOBALS['server'] = 0;
$GLOBALS['token'] = 'token';
$_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme');
}
public function testConstructor()
{
$parent = PMA_NodeFactory::getInstance('Node_Index');
$this->assertArrayHasKey(
'text',
$parent->links
);
$this->assertContains(
'tbl_indexes.php',
$parent->links['text']
);
}
public function testAddNode()
{
$parent = PMA_NodeFactory::getInstance('Node_Index', 'parent');
$child = PMA_NodeFactory::getInstance('Node_Index', 'child');
$parent->addChild($child);
$this->assertEquals(
$parent->getChild($child->name),
$child
);
$this->assertEquals(
$parent->getChild($child->real_name, true),
$child
);
}
}
?>

View File

@ -0,0 +1,51 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for NodeFactory class and Node_Column class
*
* @package PhpMyAdmin-test
*/
require_once 'libraries/navigation/NodeFactory.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Theme.class.php';
class Node_Procedure_Test extends PHPUnit_Framework_TestCase
{
public function setup()
{
$GLOBALS['server'] = 0;
$GLOBALS['token'] = 'token';
$_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme');
}
public function testConstructor()
{
$parent = PMA_NodeFactory::getInstance('Node_Procedure');
$this->assertArrayHasKey(
'text',
$parent->links
);
$this->assertContains(
'db_routines.php',
$parent->links['text']
);
}
public function testAddNode()
{
$parent = PMA_NodeFactory::getInstance('Node_Procedure', 'parent');
$child = PMA_NodeFactory::getInstance('Node_Procedure', 'child');
$parent->addChild($child);
$this->assertEquals(
$parent->getChild($child->name),
$child
);
$this->assertEquals(
$parent->getChild($child->real_name, true),
$child
);
}
}
?>