Initial commit
This commit is contained in:
166
#pma/test/classes/navigation/NavigationTest.php
Normal file
166
#pma/test/classes/navigation/NavigationTest.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\Navigation class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'libraries/relation.lib.php';
|
||||
require_once 'libraries/url_generating.lib.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\Navigation class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NavigationTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* @var PMA\libraries\navigation\Navigation
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->object = new PMA\libraries\navigation\Navigation();
|
||||
$GLOBALS['cfgRelation']['db'] = 'pmadb';
|
||||
$GLOBALS['cfgRelation']['navigationhiding'] = 'navigationhiding';
|
||||
$GLOBALS['cfg']['Server']['user'] = 'user';
|
||||
$GLOBALS['cfg']['ActionLinksMode'] = 'both';
|
||||
|
||||
$GLOBALS['pmaThemeImage'] = 'image';
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
$_SESSION['PMA_Theme'] = new Theme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
unset($this->object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests hideNavigationItem() method.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testHideNavigationItem()
|
||||
{
|
||||
$expectedQuery = "INSERT INTO `pmadb`.`navigationhiding`"
|
||||
. "(`username`, `item_name`, `item_type`, `db_name`, `table_name`)"
|
||||
. " VALUES ('user','itemName','itemType','db','')";
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with($expectedQuery);
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$this->object->hideNavigationItem('itemName', 'itemType', 'db');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests unhideNavigationItem() method.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testUnhideNavigationItem()
|
||||
{
|
||||
$expectedQuery = "DELETE FROM `pmadb`.`navigationhiding`"
|
||||
. " WHERE `username`='user' AND `item_name`='itemName'"
|
||||
. " AND `item_type`='itemType' AND `db_name`='db'";
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with($expectedQuery);
|
||||
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$this->object->unhideNavigationItem('itemName', 'itemType', 'db');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getItemUnhideDialog() method.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testGetItemUnhideDialog()
|
||||
{
|
||||
$expectedQuery = "SELECT `item_name`, `item_type`"
|
||||
. " FROM `pmadb`.`navigationhiding`"
|
||||
. " WHERE `username`='user' AND `db_name`='db' AND `table_name`=''";
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with($expectedQuery)
|
||||
->will($this->returnValue(true));
|
||||
$dbi->expects($this->at(3))
|
||||
->method('fetchArray')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'item_name' => 'tableName',
|
||||
'item_type' => 'table'
|
||||
)
|
||||
)
|
||||
);
|
||||
$dbi->expects($this->at(4))
|
||||
->method('fetchArray')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(
|
||||
'item_name' => 'viewName',
|
||||
'item_type' => 'view'
|
||||
)
|
||||
)
|
||||
);
|
||||
$dbi->expects($this->at(5))
|
||||
->method('fetchArray')
|
||||
->will($this->returnValue(false));
|
||||
$dbi->expects($this->once())
|
||||
->method('freeResult');
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$html = $this->object->getItemUnhideDialog('db');
|
||||
$this->assertContains(
|
||||
'<td>tableName</td>',
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
'<a href="navigation.php' . PMA_URL_getCommon()
|
||||
. '&unhideNavItem=true&itemType=table&itemName=tableName&dbName=db"'
|
||||
. ' class="unhideNavItem ajax">',
|
||||
$html
|
||||
);
|
||||
}
|
||||
}
|
104
#pma/test/classes/navigation/NavigationTreeTest.php
Normal file
104
#pma/test/classes/navigation/NavigationTreeTest.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\NavigationTree class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* we must set $GLOBALS['server'] here
|
||||
* since 'check_user_privileges.lib.php' will use it globally
|
||||
*/
|
||||
use PMA\libraries\navigation\NavigationTree;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'libraries/relation.lib.php';
|
||||
require_once 'libraries/url_generating.lib.php';
|
||||
require_once 'libraries/check_user_privileges.lib.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\NavigationTree class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NavigationTreeTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* @var NavigationTree
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['server'] = 1;
|
||||
$GLOBALS['PMA_Config'] = new PMA\libraries\Config();
|
||||
$GLOBALS['PMA_Config']->enableBc();
|
||||
$GLOBALS['cfg']['Server']['host'] = 'localhost';
|
||||
$GLOBALS['cfg']['Server']['user'] = 'root';
|
||||
$GLOBALS['cfg']['Server']['pmadb'] = '';
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = true;
|
||||
$GLOBALS['cfg']['ShowDatabasesNavigationAsTree'] = true;
|
||||
|
||||
$GLOBALS['pmaThemeImage'] = 'image';
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
$_SESSION['PMA_Theme'] = new Theme();
|
||||
$this->object = new PMA\libraries\navigation\NavigationTree();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
unset($this->object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Very basic rendering test.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRenderState()
|
||||
{
|
||||
$result = $this->object->renderState();
|
||||
$this->assertContains('pma_quick_warp', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Very basic path rendering test.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRenderPath()
|
||||
{
|
||||
$result = $this->object->renderPath();
|
||||
$this->assertContains('list_container', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Very basic select rendering test.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRenderDbSelect()
|
||||
{
|
||||
$result = $this->object->renderDbSelect();
|
||||
$this->assertContains('pma_navigation_select_database', $result);
|
||||
}
|
||||
}
|
51
#pma/test/classes/navigation/NodeColumnContainerTest.php
Normal file
51
#pma/test/classes/navigation/NodeColumnContainerTest.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeColumnContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeColumnContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeColumnContainerTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\NodeFactory::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeColumnContainer');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'tbl_structure.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('columns', $parent->real_name);
|
||||
}
|
||||
}
|
50
#pma/test/classes/navigation/NodeColumnTest.php
Normal file
50
#pma/test/classes/navigation/NodeColumnTest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeColumn class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeColumn class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeColumnTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\NodeFactory::getInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeColumn');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'tbl_structure.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
}
|
||||
}
|
91
#pma/test/classes/navigation/NodeDatabaseChildTest.php
Normal file
91
#pma/test/classes/navigation/NodeDatabaseChildTest.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\nodes\NodeDatabaseChild
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\navigation\nodes\NodeDatabaseChild;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/url_generating.lib.php';
|
||||
require_once 'libraries/relation.lib.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeDatabaseChild class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeDatabaseChildTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* @var NodeDatabaseChild
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$_SESSION['PMA_Theme'] = new Theme();
|
||||
$GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath();
|
||||
$GLOBALS['pmaThemeImage'] = 'theme/';
|
||||
$GLOBALS['cfg']['DefaultTabDatabase'] = 'structure';
|
||||
$GLOBALS['server'] = 1;
|
||||
$GLOBALS['cfg']['ServerDefault'] = 1;
|
||||
$_SESSION['relation'][1]['PMA_VERSION'] = PMA_VERSION;
|
||||
$_SESSION['relation'][1]['navwork'] = true;
|
||||
$this->object = $this->getMockForAbstractClass(
|
||||
'PMA\libraries\navigation\nodes\NodeDatabaseChild', array('child')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
unset($this->object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getHtmlForControlButtons() method
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testGetHtmlForControlButtons()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeDatabase', 'parent');
|
||||
$parent->addChild($this->object);
|
||||
$this->object->expects($this->once())
|
||||
->method('getItemType')
|
||||
->will($this->returnValue('itemType'));
|
||||
$html = $this->object->getHtmlForControlButtons();
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
'<span class="navItemControls">',
|
||||
$html
|
||||
);
|
||||
$this->assertStringEndsWith(
|
||||
'</span>',
|
||||
$html
|
||||
);
|
||||
$this->assertContains(
|
||||
'<a href="navigation.php' . PMA_URL_getCommon()
|
||||
. '&hideNavItem=true&itemType=itemType&itemName=child'
|
||||
. '&dbName=parent" class="hideNavItem ajax">',
|
||||
$html
|
||||
);
|
||||
}
|
||||
}
|
137
#pma/test/classes/navigation/NodeDatabaseTest.php
Normal file
137
#pma/test/classes/navigation/NodeDatabaseTest.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeDatabase class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeDatabase class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeDatabaseTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['cfg']['DefaultTabDatabase'] = 'structure';
|
||||
$GLOBALS['cfg']['MaxNavigationItems'] = 250;
|
||||
$GLOBALS['cfg']['Server'] = array();
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = true;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeDatabase');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_structure.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertContains('database', $parent->classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getPresence
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetPresence()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeDatabase');
|
||||
$this->assertEquals(
|
||||
2,
|
||||
$parent->getPresence('tables')
|
||||
);
|
||||
$this->assertEquals(
|
||||
0,
|
||||
$parent->getPresence('views')
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
$parent->getPresence('functions')
|
||||
);
|
||||
$this->assertEquals(
|
||||
0,
|
||||
$parent->getPresence('procedures')
|
||||
);
|
||||
$this->assertEquals(
|
||||
0,
|
||||
$parent->getPresence('events')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getData
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetData()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeDatabase');
|
||||
|
||||
$tables = $parent->getData('tables', 0);
|
||||
$this->assertContains(
|
||||
'test1',
|
||||
$tables
|
||||
);
|
||||
$this->assertContains(
|
||||
'test2',
|
||||
$tables
|
||||
);
|
||||
|
||||
$views = $parent->getData('views', 0);
|
||||
$this->assertEmpty($views);
|
||||
|
||||
$functions = $parent->getData('functions', 0);
|
||||
$this->assertContains(
|
||||
'testFunction',
|
||||
$functions
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
count($functions)
|
||||
);
|
||||
|
||||
$this->assertEmpty($parent->getData('procedures', 0));
|
||||
$this->assertEmpty($parent->getData('events', 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for setHiddenCount and getHiddenCount
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testHiddenCount()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeDatabase');
|
||||
|
||||
$parent->setHiddenCount(3);
|
||||
$this->assertEquals(
|
||||
3,
|
||||
$parent->getHiddenCount()
|
||||
);
|
||||
}
|
||||
}
|
51
#pma/test/classes/navigation/NodeEventContainerTest.php
Normal file
51
#pma/test/classes/navigation/NodeEventContainerTest.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeEventContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeEventContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeEventContainerTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeEventContainer');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_events.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('events', $parent->real_name);
|
||||
}
|
||||
}
|
50
#pma/test/classes/navigation/NodeEventTest.php
Normal file
50
#pma/test/classes/navigation/NodeEventTest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeEvent class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeEvent class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeEventTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeEvent');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_events.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
}
|
||||
}
|
103
#pma/test/classes/navigation/NodeFactoryTest.php
Normal file
103
#pma/test/classes/navigation/NodeFactoryTest.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for NodeFactory class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\navigation\nodes\Node;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for NodeFactory class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeFactoryTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\NodeFactory::getInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDefaultNode()
|
||||
{
|
||||
$node = NodeFactory::getInstance();
|
||||
$this->assertEquals('default', $node->name);
|
||||
$this->assertEquals(Node::OBJECT, $node->type);
|
||||
$this->assertEquals(false, $node->is_group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\NodeFactory::getInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDefaultContainer()
|
||||
{
|
||||
$node = NodeFactory::getInstance(
|
||||
'Node',
|
||||
'default',
|
||||
Node::CONTAINER
|
||||
);
|
||||
$this->assertEquals('default', $node->name);
|
||||
$this->assertEquals(Node::CONTAINER, $node->type);
|
||||
$this->assertEquals(false, $node->is_group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\NodeFactory::getInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGroupContainer()
|
||||
{
|
||||
$node = NodeFactory::getInstance(
|
||||
'Node',
|
||||
'default',
|
||||
Node::CONTAINER,
|
||||
true
|
||||
);
|
||||
$this->assertEquals('default', $node->name);
|
||||
$this->assertEquals(Node::CONTAINER, $node->type);
|
||||
$this->assertEquals(true, $node->is_group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\NodeFactory::getInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFileError()
|
||||
{
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
NodeFactory::getInstance('NodeDoesNotExist');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA\libraries\navigation\NodeFactory::getInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testClassNameError()
|
||||
{
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
NodeFactory::getInstance('Invalid');
|
||||
}
|
||||
}
|
51
#pma/test/classes/navigation/NodeFunctionContainerTest.php
Normal file
51
#pma/test/classes/navigation/NodeFunctionContainerTest.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeFunctionContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeFunctionContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeFunctionContainerTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeFunctionContainer');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_routines.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('functions', $parent->real_name);
|
||||
}
|
||||
}
|
50
#pma/test/classes/navigation/NodeFunctionTest.php
Normal file
50
#pma/test/classes/navigation/NodeFunctionTest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeFunction class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeFunction class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeFunctionTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeFunction');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_routines.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
}
|
||||
}
|
51
#pma/test/classes/navigation/NodeIndexContainerTest.php
Normal file
51
#pma/test/classes/navigation/NodeIndexContainerTest.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeIndexContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeIndexContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeIndexContainerTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeIndexContainer');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'tbl_structure.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('indexes', $parent->real_name);
|
||||
}
|
||||
}
|
50
#pma/test/classes/navigation/NodeIndexTest.php
Normal file
50
#pma/test/classes/navigation/NodeIndexTest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeIndex class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeIndex class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeIndexTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeIndex');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'tbl_indexes.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
}
|
||||
}
|
51
#pma/test/classes/navigation/NodeProcedureContainerTest.php
Normal file
51
#pma/test/classes/navigation/NodeProcedureContainerTest.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeProcedureContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeProcedureContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeProcedureContainerTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeProcedureContainer');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_routines.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('procedures', $parent->real_name);
|
||||
}
|
||||
}
|
50
#pma/test/classes/navigation/NodeProcedureTest.php
Normal file
50
#pma/test/classes/navigation/NodeProcedureTest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeProcedure class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeProcedure class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeProcedureTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeProcedure');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_routines.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
}
|
||||
}
|
57
#pma/test/classes/navigation/NodeTableContainerTest.php
Normal file
57
#pma/test/classes/navigation/NodeTableContainerTest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeTableContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeTableContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeTableContainerTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = true;
|
||||
$GLOBALS['cfg']['NavigationTreeDbSeparator'] = '_';
|
||||
$GLOBALS['cfg']['NavigationTreeTableSeparator'] = '__';
|
||||
$GLOBALS['cfg']['NavigationTreeTableLevel'] = 1;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeTableContainer');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_structure.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('tables', $parent->real_name);
|
||||
$this->assertContains('tableContainer', $parent->classes);
|
||||
}
|
||||
}
|
92
#pma/test/classes/navigation/NodeTableTest.php
Normal file
92
#pma/test/classes/navigation/NodeTableTest.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeTable class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeTable class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeTableTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = 'b_browse';
|
||||
$GLOBALS['cfg']['NavigationTreeDefaultTabTable2'] = '';
|
||||
$GLOBALS['cfg']['DefaultTabTable'] = 'browse';
|
||||
$GLOBALS['cfg']['MaxNavigationItems'] = 250;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = true;
|
||||
$GLOBALS['cfg']['NavigationTreeDbSeparator'] = '_';
|
||||
$GLOBALS['cfg']['NavigationTreeTableSeparator'] = '__';
|
||||
$GLOBALS['cfg']['NavigationTreeTableLevel'] = 1;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeTable');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'sql.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertContains('table', $parent->classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the node icon is properly set based on the icon target.
|
||||
*
|
||||
* @param string $target target of the icon
|
||||
* @param string $imageName name of the image that should be set
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider providerForTestIcon
|
||||
*/
|
||||
public function testIcon($target, $imageName)
|
||||
{
|
||||
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = $target;
|
||||
$node = NodeFactory::getInstance('NodeTable');
|
||||
$this->assertContains($imageName, $node->icon[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testIcon().
|
||||
*
|
||||
* @return array data for testIcon()
|
||||
*/
|
||||
public function providerForTestIcon()
|
||||
{
|
||||
return array(
|
||||
array('structure', 'b_props'),
|
||||
array('search', 'b_search'),
|
||||
array('insert', 'b_insrow'),
|
||||
array('sql', 'b_sql'),
|
||||
array('browse', 'b_browse'),
|
||||
);
|
||||
}
|
||||
}
|
574
#pma/test/classes/navigation/NodeTest.php
Normal file
574
#pma/test/classes/navigation/NodeTest.php
Normal file
@ -0,0 +1,574 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for Node class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\navigation\nodes\Node;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for Node class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
/**
|
||||
* SetUp for AddNode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddNode()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('Node', 'parent');
|
||||
$child = NodeFactory::getInstance('Node', 'child');
|
||||
$parent->addChild($child);
|
||||
$this->assertEquals(
|
||||
$parent->getChild($child->name),
|
||||
$child
|
||||
);
|
||||
$this->assertEquals(
|
||||
$parent->getChild($child->real_name, true),
|
||||
$child
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SetUp for getChild
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetChildError()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('Node', 'parent');
|
||||
$this->assertEquals(
|
||||
$parent->getChild("foo"),
|
||||
false
|
||||
);
|
||||
$this->assertEquals(
|
||||
$parent->getChild("foo", true),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SetUp for getChild
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRemoveNode()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('Node', 'parent');
|
||||
$child = NodeFactory::getInstance('Node', 'child');
|
||||
$parent->addChild($child);
|
||||
$this->assertEquals(
|
||||
$parent->getChild($child->name),
|
||||
$child
|
||||
);
|
||||
$parent->removeChild($child->name);
|
||||
$this->assertEquals(
|
||||
$parent->getChild($child->name),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SetUp for hasChildren
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNodeHasChildren()
|
||||
{
|
||||
$parent = NodeFactory::getInstance();
|
||||
$empty_container = NodeFactory::getInstance(
|
||||
'Node', 'empty', Node::CONTAINER
|
||||
);
|
||||
$child = NodeFactory::getInstance();
|
||||
// test with no children
|
||||
$this->assertEquals(
|
||||
$parent->hasChildren(true),
|
||||
false
|
||||
);
|
||||
$this->assertEquals(
|
||||
$parent->hasChildren(false),
|
||||
false
|
||||
);
|
||||
// test with an empty container
|
||||
$parent->addChild($empty_container);
|
||||
$this->assertEquals(
|
||||
$parent->hasChildren(true),
|
||||
true
|
||||
);
|
||||
$this->assertEquals(
|
||||
$parent->hasChildren(false),
|
||||
false
|
||||
);
|
||||
// test with a real child
|
||||
$parent->addChild($child);
|
||||
$this->assertEquals(
|
||||
$parent->hasChildren(true),
|
||||
true
|
||||
);
|
||||
$this->assertEquals(
|
||||
$parent->hasChildren(false),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SetUp for numChildren
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNumChildren()
|
||||
{
|
||||
// start with root node only
|
||||
$parent = NodeFactory::getInstance();
|
||||
$this->assertEquals($parent->numChildren(), 0);
|
||||
// add a child
|
||||
$child = NodeFactory::getInstance();
|
||||
$parent->addChild($child);
|
||||
$this->assertEquals($parent->numChildren(), 1);
|
||||
// add a direct grandchild, this one doesn't count as
|
||||
// it's not enclosed in a CONTAINER
|
||||
$child->addChild(NodeFactory::getInstance());
|
||||
$this->assertEquals($parent->numChildren(), 1);
|
||||
// add a container, this one doesn't count wither
|
||||
$container = NodeFactory::getInstance(
|
||||
'Node', 'default', Node::CONTAINER
|
||||
);
|
||||
$parent->addChild($container);
|
||||
$this->assertEquals($parent->numChildren(), 1);
|
||||
// add a grandchild to container, this one counts
|
||||
$container->addChild(NodeFactory::getInstance());
|
||||
$this->assertEquals($parent->numChildren(), 2);
|
||||
// add another grandchild to container, this one counts
|
||||
$container->addChild(NodeFactory::getInstance());
|
||||
$this->assertEquals($parent->numChildren(), 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* SetUp for parents
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testParents()
|
||||
{
|
||||
$parent = NodeFactory::getInstance();
|
||||
$this->assertEquals($parent->parents(), array()); // exclude self
|
||||
$this->assertEquals($parent->parents(true), array($parent)); // include self
|
||||
|
||||
$child = NodeFactory::getInstance();
|
||||
$parent->addChild($child);
|
||||
|
||||
$this->assertEquals($child->parents(), array($parent)); // exclude self
|
||||
$this->assertEquals(
|
||||
$child->parents(true),
|
||||
array($child, $parent)
|
||||
); // include self
|
||||
}
|
||||
|
||||
/**
|
||||
* SetUp for realParent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRealParent()
|
||||
{
|
||||
$parent = NodeFactory::getInstance();
|
||||
$this->assertEquals($parent->realParent(), false);
|
||||
|
||||
$child = NodeFactory::getInstance();
|
||||
$parent->addChild($child);
|
||||
$this->assertEquals($child->realParent(), $parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether Node->hasSiblings() method returns false
|
||||
* when the node does not have any siblings.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testHasSiblingsWithNoSiblings()
|
||||
{
|
||||
$parent = NodeFactory::getInstance();
|
||||
$child = NodeFactory::getInstance();
|
||||
$parent->addChild($child);
|
||||
$this->assertEquals(false, $child->hasSiblings());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether Node->hasSiblings() method returns true
|
||||
* when it actually has siblings.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testHasSiblingsWithSiblings()
|
||||
{
|
||||
$parent = NodeFactory::getInstance();
|
||||
$firstChild = NodeFactory::getInstance();
|
||||
$parent->addChild($firstChild);
|
||||
$secondChild = NodeFactory::getInstance();
|
||||
$parent->addChild($secondChild);
|
||||
// Normal case; two Node:NODE type siblings
|
||||
$this->assertEquals(true, $firstChild->hasSiblings());
|
||||
|
||||
$parent = NodeFactory::getInstance();
|
||||
$firstChild = NodeFactory::getInstance();
|
||||
$parent->addChild($firstChild);
|
||||
$secondChild = NodeFactory::getInstance(
|
||||
'Node', 'default', Node::CONTAINER
|
||||
);
|
||||
$parent->addChild($secondChild);
|
||||
// Empty Node::CONTAINER type node should not be considered in hasSiblings()
|
||||
$this->assertEquals(false, $firstChild->hasSiblings());
|
||||
|
||||
$grandChild = NodeFactory::getInstance();
|
||||
$secondChild->addChild($grandChild);
|
||||
// Node::CONTAINER type nodes with children are counted for hasSiblings()
|
||||
$this->assertEquals(true, $firstChild->hasSiblings());
|
||||
}
|
||||
|
||||
/**
|
||||
* It is expected that Node->hasSiblings() method always return true
|
||||
* for Nodes that are 3 levels deep (columns and indexes).
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testHasSiblingsForNodesAtLevelThree()
|
||||
{
|
||||
$parent = NodeFactory::getInstance();
|
||||
$child = NodeFactory::getInstance();
|
||||
$parent->addChild($child);
|
||||
$grandChild = NodeFactory::getInstance();
|
||||
$child->addChild($grandChild);
|
||||
$greatGrandChild = NodeFactory::getInstance();
|
||||
$grandChild->addChild($greatGrandChild);
|
||||
|
||||
// Should return false for node that are two levels deeps
|
||||
$this->assertEquals(false, $grandChild->hasSiblings());
|
||||
// Should return true for node that are three levels deeps
|
||||
$this->assertEquals(true, $greatGrandChild->hasSiblings());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests private method _getWhereClause()
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testGetWhereClause()
|
||||
{
|
||||
$method = new ReflectionMethod(
|
||||
'PMA\libraries\navigation\nodes\Node', '_getWhereClause'
|
||||
);
|
||||
$method->setAccessible(true);
|
||||
|
||||
// Vanilla case
|
||||
$node = NodeFactory::getInstance();
|
||||
$this->assertEquals(
|
||||
"WHERE TRUE ", $method->invoke($node, 'SCHEMA_NAME')
|
||||
);
|
||||
|
||||
// When a schema names is passed as search clause
|
||||
$this->assertEquals(
|
||||
"WHERE TRUE AND `SCHEMA_NAME` LIKE '%schemaName%' ",
|
||||
$method->invoke($node, 'SCHEMA_NAME', 'schemaName')
|
||||
);
|
||||
|
||||
if (! isset($GLOBALS['cfg']['Server'])) {
|
||||
$GLOBALS['cfg']['Server'] = array();
|
||||
}
|
||||
|
||||
// When hide_db regular expression is present
|
||||
$GLOBALS['cfg']['Server']['hide_db'] = 'regexpHideDb';
|
||||
$this->assertEquals(
|
||||
"WHERE TRUE AND `SCHEMA_NAME` NOT REGEXP 'regexpHideDb' ",
|
||||
$method->invoke($node, 'SCHEMA_NAME')
|
||||
);
|
||||
unset($GLOBALS['cfg']['Server']['hide_db']);
|
||||
|
||||
// When only_db directive is present and it's a single db
|
||||
$GLOBALS['cfg']['Server']['only_db'] = 'stringOnlyDb';
|
||||
$this->assertEquals(
|
||||
"WHERE TRUE AND ( `SCHEMA_NAME` LIKE 'stringOnlyDb' ) ",
|
||||
$method->invoke($node, 'SCHEMA_NAME')
|
||||
);
|
||||
unset($GLOBALS['cfg']['Server']['only_db']);
|
||||
|
||||
// When only_db directive is present and it's an array of dbs
|
||||
$GLOBALS['cfg']['Server']['only_db'] = array('onlyDbOne', 'onlyDbTwo');
|
||||
$this->assertEquals(
|
||||
"WHERE TRUE AND ( `SCHEMA_NAME` LIKE 'onlyDbOne' "
|
||||
. "OR `SCHEMA_NAME` LIKE 'onlyDbTwo' ) ",
|
||||
$method->invoke($node, 'SCHEMA_NAME')
|
||||
);
|
||||
unset($GLOBALS['cfg']['Server']['only_db']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getData() method when DisableIS is false and navigation tree
|
||||
* grouping enabled.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testGetDataWithEnabledISAndGroupingEnabled()
|
||||
{
|
||||
$pos = 10;
|
||||
$limit = 20;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = true;
|
||||
$GLOBALS['cfg']['FirstLevelNavigationItems'] = $limit;
|
||||
$GLOBALS['cfg']['NavigationTreeDbSeparator'] = '_';
|
||||
|
||||
$expectedSql = "SELECT `SCHEMA_NAME` ";
|
||||
$expectedSql .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA`, ";
|
||||
$expectedSql .= "(";
|
||||
$expectedSql .= "SELECT DB_first_level ";
|
||||
$expectedSql .= "FROM ( ";
|
||||
$expectedSql .= "SELECT DISTINCT SUBSTRING_INDEX(SCHEMA_NAME, ";
|
||||
$expectedSql .= "'_', 1) ";
|
||||
$expectedSql .= "DB_first_level ";
|
||||
$expectedSql .= "FROM INFORMATION_SCHEMA.SCHEMATA ";
|
||||
$expectedSql .= "WHERE TRUE ";
|
||||
$expectedSql .= ") t ";
|
||||
$expectedSql .= "ORDER BY DB_first_level ASC ";
|
||||
$expectedSql .= "LIMIT $pos, $limit";
|
||||
$expectedSql .= ") t2 ";
|
||||
$expectedSql .= "WHERE TRUE AND 1 = LOCATE(CONCAT(DB_first_level, '_'), ";
|
||||
$expectedSql .= "CONCAT(SCHEMA_NAME, '_')) ";
|
||||
$expectedSql .= "ORDER BY SCHEMA_NAME ASC";
|
||||
|
||||
// It would have been better to mock _getWhereClause method
|
||||
// but strangely, mocking private methods is not supported in PHPUnit
|
||||
$node = NodeFactory::getInstance();
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('fetchResult')
|
||||
->with($expectedSql);
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$node->getData('', $pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getData() method when DisableIS is false and navigation tree
|
||||
* grouping disabled.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testGetDataWithEnabledISAndGroupingDisabled()
|
||||
{
|
||||
$pos = 10;
|
||||
$limit = 20;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = false;
|
||||
$GLOBALS['cfg']['FirstLevelNavigationItems'] = $limit;
|
||||
|
||||
$expectedSql = "SELECT `SCHEMA_NAME` ";
|
||||
$expectedSql .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` ";
|
||||
$expectedSql .= "WHERE TRUE ";
|
||||
$expectedSql .= "ORDER BY `SCHEMA_NAME` ";
|
||||
$expectedSql .= "LIMIT $pos, $limit";
|
||||
|
||||
// It would have been better to mock _getWhereClause method
|
||||
// but strangely, mocking private methods is not supported in PHPUnit
|
||||
$node = NodeFactory::getInstance();
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('fetchResult')
|
||||
->with($expectedSql);
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$node->getData('', $pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getData() method when DisableIS is true and navigation tree
|
||||
* grouping enabled.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testGetDataWithDisabledISAndGroupingEnabled()
|
||||
{
|
||||
$pos = 0;
|
||||
$limit = 10;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = true;
|
||||
$GLOBALS['dbs_to_test'] = false;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = true;
|
||||
$GLOBALS['cfg']['FirstLevelNavigationItems'] = $limit;
|
||||
$GLOBALS['cfg']['NavigationTreeDbSeparator'] = '_';
|
||||
|
||||
$node = NodeFactory::getInstance();
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with("SHOW DATABASES WHERE TRUE AND `Database` LIKE '%db%' ")
|
||||
->will($this->returnValue(true));
|
||||
$dbi->expects($this->exactly(3))
|
||||
->method('fetchArray')
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(
|
||||
'0' => 'db'
|
||||
),
|
||||
array(
|
||||
'0' => 'aa_db'
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
$dbi->expects($this->once())
|
||||
->method('fetchResult')
|
||||
->with(
|
||||
"SHOW DATABASES WHERE TRUE AND `Database` LIKE '%db%' AND ("
|
||||
. " LOCATE('db_', CONCAT(`Database`, '_')) = 1"
|
||||
. " OR LOCATE('aa_', CONCAT(`Database`, '_')) = 1 )"
|
||||
);
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$node->getData('', $pos, 'db');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getPresence method when DisableIS is false and navigation tree
|
||||
* grouping enabled.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testGetPresenceWithEnabledISAndGroupingEnabled()
|
||||
{
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = true;
|
||||
$GLOBALS['cfg']['NavigationTreeDbSeparator'] = '_';
|
||||
|
||||
$query = "SELECT COUNT(*) ";
|
||||
$query .= "FROM ( ";
|
||||
$query .= "SELECT DISTINCT SUBSTRING_INDEX(SCHEMA_NAME, '_', 1) ";
|
||||
$query .= "DB_first_level ";
|
||||
$query .= "FROM INFORMATION_SCHEMA.SCHEMATA ";
|
||||
$query .= "WHERE TRUE ";
|
||||
$query .= ") t ";
|
||||
|
||||
// It would have been better to mock _getWhereClause method
|
||||
// but strangely, mocking private methods is not supported in PHPUnit
|
||||
$node = NodeFactory::getInstance();
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('fetchValue')
|
||||
->with($query);
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$node->getPresence();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getPresence method when DisableIS is false and navigation tree
|
||||
* grouping disabled.
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testGetPresenceWithEnabledISAndGroupingDisabled()
|
||||
{
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = false;
|
||||
|
||||
$query = "SELECT COUNT(*) ";
|
||||
$query .= "FROM INFORMATION_SCHEMA.SCHEMATA ";
|
||||
$query .= "WHERE TRUE ";
|
||||
|
||||
$node = NodeFactory::getInstance();
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('fetchValue')
|
||||
->with($query);
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$node->getPresence();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getPresence method when DisableIS is true
|
||||
*
|
||||
* @return void
|
||||
* @test
|
||||
*/
|
||||
public function testGetPresenceWithDisabledIS()
|
||||
{
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = true;
|
||||
$GLOBALS['dbs_to_test'] = false;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = true;
|
||||
|
||||
$node = NodeFactory::getInstance();
|
||||
|
||||
// test with no search clause
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with("SHOW DATABASES WHERE TRUE ");
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$node->getPresence();
|
||||
|
||||
// test with a search clause
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with("SHOW DATABASES WHERE TRUE AND `Database` LIKE '%dbname%' ");
|
||||
$dbi->expects($this->any())->method('escapeString')
|
||||
->will($this->returnArgument(0));
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
$node->getPresence('', 'dbname');
|
||||
}
|
||||
}
|
52
#pma/test/classes/navigation/NodeTriggerContainerTest.php
Normal file
52
#pma/test/classes/navigation/NodeTriggerContainerTest.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeTrigger class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeTrigger class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeTriggerContainerTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeTriggerContainer');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_triggers.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('triggers', $parent->real_name);
|
||||
}
|
||||
}
|
51
#pma/test/classes/navigation/NodeTriggerTest.php
Normal file
51
#pma/test/classes/navigation/NodeTriggerTest.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeTrigger class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeTrigger class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeTriggerTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeTrigger');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_triggers.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
}
|
||||
}
|
57
#pma/test/classes/navigation/NodeViewContainerTest.php
Normal file
57
#pma/test/classes/navigation/NodeViewContainerTest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeViewContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeViewContainer class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeViewContainerTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['cfg']['NavigationTreeEnableGrouping'] = true;
|
||||
$GLOBALS['cfg']['NavigationTreeDbSeparator'] = '_';
|
||||
$GLOBALS['cfg']['NavigationTreeTableSeparator'] = '__';
|
||||
$GLOBALS['cfg']['NavigationTreeTableLevel'] = 1;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeViewContainer');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'db_structure.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertEquals('views', $parent->real_name);
|
||||
$this->assertContains('viewContainer', $parent->classes);
|
||||
}
|
||||
}
|
53
#pma/test/classes/navigation/NodeViewTest.php
Normal file
53
#pma/test/classes/navigation/NodeViewTest.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeView class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
use PMA\libraries\navigation\NodeFactory;
|
||||
use PMA\libraries\Theme;
|
||||
|
||||
require_once 'libraries/navigation/NodeFactory.php';
|
||||
require_once 'test/PMATestCase.php';
|
||||
|
||||
/**
|
||||
* Tests for PMA\libraries\navigation\nodes\NodeView class
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class NodeViewTest extends PMATestCase
|
||||
{
|
||||
/**
|
||||
* SetUp for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['server'] = 0;
|
||||
$_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for __construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$parent = NodeFactory::getInstance('NodeView');
|
||||
$this->assertArrayHasKey(
|
||||
'text',
|
||||
$parent->links
|
||||
);
|
||||
$this->assertContains(
|
||||
'sql.php',
|
||||
$parent->links['text']
|
||||
);
|
||||
$this->assertContains('b_props', $parent->icon);
|
||||
$this->assertContains('view', $parent->classes);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user