Files
#jpgraph
#pma
doc
examples
js
libraries
locale
setup
sql
templates
test
classes
_data
config
controllers
dbi
engines
gis
navigation
NavigationTest.php
NavigationTreeTest.php
NodeColumnContainerTest.php
NodeColumnTest.php
NodeDatabaseChildTest.php
NodeDatabaseTest.php
NodeEventContainerTest.php
NodeEventTest.php
NodeFactoryTest.php
NodeFunctionContainerTest.php
NodeFunctionTest.php
NodeIndexContainerTest.php
NodeIndexTest.php
NodeProcedureContainerTest.php
NodeProcedureTest.php
NodeTableContainerTest.php
NodeTableTest.php
NodeTest.php
NodeTriggerContainerTest.php
NodeTriggerTest.php
NodeViewContainerTest.php
NodeViewTest.php
plugin
properties
schema
AdvisorTest.php
ConfigGeneratorTest.php
ConfigTest.php
DatabaseInterfaceTest.php
DbQbeTest.php
DbSearchTest.php
DisplayResultsTest.php
ErrorHandlerTest.php
ErrorTest.php
FileTest.php
FontTest.php
FooterTest.php
HeaderTest.php
IndexTest.php
LanguageTest.php
LinterTest.php
ListDatabaseTest.php
MenuTest.php
MessageTest.php
PDFTest.php
ScriptsTest.php
ServerStatusDataTest.php
StorageEngineTest.php
SystemDatabaseTest.php
TableTest.php
TemplateTest.php
ThemeManagerTest.php
ThemeTest.php
TrackerTest.php
TypesMySQLTest.php
TypesTest.php
UtilTest.php
VersionInformationTest.php
ZipFileTest.php
libraries
selenium
test_data
.htaccess
AllSeleniumTests.php
Environment_test.php
PMATestCase.php
README.rst
bootstrap-dist.php
install-browserstack
install-runkit
php-noprofile.ini
php-runkit.ini
start-local-server
theme.php
wui.php
themes
CONTRIBUTING.md
ChangeLog
DCO
LICENSE
README
RELEASE-DATE-4.6.5.2
browse_foreigners.php
build.xml
changelog.php
chk_rel.php
composer.json
config.inc.php
config.sample.inc.php
db_central_columns.php
db_datadict.php
db_designer.php
db_events.php
db_export.php
db_import.php
db_operations.php
db_qbe.php
db_routines.php
db_search.php
db_sql.php
db_sql_autocomplete.php
db_sql_format.php
db_structure.php
db_tracking.php
db_triggers.php
error_report.php
export.php
favicon.ico
file_echo.php
gis_data_editor.php
import.php
import_status.php
index.php
license.php
lint.php
logout.php
navigation.php
normalization.php
phpmyadmin.css.php
phpunit.xml.dist
phpunit.xml.hhvm
phpunit.xml.nocoverage
prefs_forms.php
prefs_manage.php
print.css
robots.txt
schema_export.php
server_binlog.php
server_collations.php
server_databases.php
server_engines.php
server_export.php
server_import.php
server_plugins.php
server_privileges.php
server_replication.php
server_sql.php
server_status.php
server_status_advisor.php
server_status_monitor.php
server_status_processes.php
server_status_queries.php
server_status_variables.php
server_user_groups.php
server_variables.php
show_config_errors.php
sql.php
tbl_addfield.php
tbl_change.php
tbl_chart.php
tbl_create.php
tbl_export.php
tbl_find_replace.php
tbl_get_field.php
tbl_gis_visualization.php
tbl_import.php
tbl_indexes.php
tbl_operations.php
tbl_recent_favorite.php
tbl_relation.php
tbl_replace.php
tbl_row_action.php
tbl_select.php
tbl_sql.php
tbl_structure.php
tbl_tracking.php
tbl_triggers.php
tbl_zoom_select.php
themes.php
transformation_overview.php
transformation_wrapper.php
url.php
user_password.php
version_check.php
view_create.php
view_operations.php
CKEditor_4.6.1
Date
backup
bibelpopup
classes
config
fetch_bibel
fetch_chorbuch
html2pdf-master
html2pdf_v4.03
images
jpgraph
kalender
language
lib
lieder
livesearch
msd
overlib
pma
templates
templates_c
test
validation
++ Umstellung Luther 2017.sql
.gitattributes
.htaccess
MyOOS-Dumper-master.zip
Version8_bugs.txt
ajax.js_20170928
ansicht.php
ansicht.php_20200212
ansicht.php_20200915
ansicht.php_lut84_20180219
ansicht2.php
ansicht2.php_20200212
ansicht2.php_20200915
ansicht2.php_lut84_20180219
ausgabe.php
bes_gd.php
bibellookup.php_lut84_20180219
bibellookup_1984.php
bibellookup_2017.php
bibellookup_2017.php_20200212
changelog.php
config.inc.php
copy.js
faq_text.php
faq_text_ber.php
favicon.ico
fetch_data.php
ftp_ansicht.php
ftp_ansicht.php_20181214
func_agent.php
func_ansicht.php
func_ansicht.php_20200212
func_ansicht.php_20200915
func_ansicht.php_lut84_20180219
func_genUser.php
func_highlight.php
func_htmlclean.php
func_make_knk.php
func_make_knk_fa.php
func_make_knk_fa.php_lut84_20180219
func_make_reference_fa.php
func_make_reference_fa.php_lut84_20180219
func_rollenrechte.php
func_rollenrechte_20220202.php
func_write_lue_kat.php
further_publication.php
getSubCat.php
graph.php
graph_einzel.php
graph_hauptframe.php
graph_user.php
graph_user_hauptframe.php
hauptframe.php
hello.cgi
hello.pl
hilfe.php
historie.php
index.php
index2.php
indexframe.php
info.php
job_mail_delete_neue_user.php
job_mail_inaktiv.php
job_user_delete_neue_user.php
job_user_inaktiv.php
jquery.min.js
kat_cont.php
kat_cont.php_20201230
kat_cont.php_20221013
kat_cont_fa.php
kat_main.php
kat_main.php_lut84_20180219
kat_main_fa.php
kat_main_fa.php_lut84_20180219
katechismus.php
katechismus_fa.php
lesung.php
lieder.php
lieder.zip
livesearch.php
livestat.js
livestat.php
livestat2.php
login_log.php
logininfo.php
logout_admin.php
lue_ansicht.php
lue_bearbeiten.php
lue_erfassen.php
lue_inhalt.php
lue_inhalt.php_20200915
lue_inhalt.php_lut84_20180219
lue_notizen.php
lue_suche.php
lue_wahl.php
mail.php
make_ical.php
menuframe.php
nachsenden.php
notizen.php
outlook.php
outlook.php_20200212
outlook_ics.php
outlook_vcs.php
passwort_switch.php
pdf_gen.php
pdf_gen.php_20200915
pdf_gen.php_lut84_20180219
preview.php
profil.php
rollen.php
search_note.php
stichworte.php
suche.php
suche.php_20170928
suche_change.php
suche_simp.php
systemmail.php
test.php
test2.php
testmail.php
testmail2.php
topframe.php
upload.php
user_anlegen.php
user_bearbeiten.php
useronline.php
verweise.php
wort_bearbeiten.php
wort_bearbeiten.php_20170928
wort_erfassen.php
wort_erfassen.php_20170928
wort_exegese.php
wort_wahl.php
Leitgedanken/#pma/test/classes/navigation/NavigationTest.php
2022-11-21 09:47:28 +01:00

167 lines
4.9 KiB
PHP

<?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
);
}
}