Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Feb 17, 2021
2 parents f8e8fc2 + cf608f8 commit 0c4595b
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 34 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test-selenium.yml
Expand Up @@ -87,13 +87,13 @@ jobs:
- name: Install modules
run: yarn install --non-interactive --production
- name: Install nginx and php-fpm
run: sudo apt-get install -y nginx php-fpm
run: sudo apt-get install -y nginx php7.1-fpm
- name: Copy the config
run: cp test/config.e2e.inc.php config.inc.php
- name: Start server
env:
CI_MODE: selenium
FPM_PATH: php-fpm8.0
FPM_PATH: php-fpm7.1
SKIP_STANDALONE: 1
run: |
./test/start-local-server
Expand All @@ -110,8 +110,6 @@ jobs:
TESTSUITE_DATABASE_PREFIX: "selenium"
TESTSUITE_SELENIUM_HOST: "127.0.0.1"
TESTSUITE_SELENIUM_PORT: "4444"
# Allowed errors: https://github.com/phpmyadmin/phpmyadmin/issues/16479
continue-on-error: true
run: ./vendor/bin/phpunit --group selenium --verbose --debug --no-coverage
- name: Output logs and stop server
env:
Expand Down
Expand Up @@ -50,9 +50,8 @@ public function index(): void
$savedSearchList = [];
$savedSearch = null;
$currentSearchId = null;
$this->addScriptFiles(['database/qbe.js']);
if ($cfgRelation['savedsearcheswork']) {
$this->addScriptFiles(['database/qbe.js']);

//Get saved search list.
$savedSearch = new SavedSearches($GLOBALS, $this->relation);
$savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])
Expand Down
13 changes: 8 additions & 5 deletions libraries/classes/Menu.php
Expand Up @@ -98,12 +98,15 @@ private function getMenu(): string
{
$url_params = [];

if (strlen((string) $this->table) > 0) {
$hasDbArg = strlen($this->db) > 0;

// The URL will not work if the table is defined without a database
if (strlen((string) $this->table) > 0 && $hasDbArg) {
$tabs = $this->getTableTabs();
$url_params['db'] = $this->db;
$url_params['table'] = $this->table;
$level = 'table';
} elseif (strlen($this->db) > 0) {
} elseif ($hasDbArg) {
$tabs = $this->getDbTabs();
$url_params['db'] = $this->db;
$level = 'db';
Expand Down Expand Up @@ -195,20 +198,20 @@ private function getBreadcrumbs(): string
? $cfg['Server']['verbose'] : $cfg['Server']['host'];
$server['name'] .= empty($cfg['Server']['port'])
? '' : ':' . $cfg['Server']['port'];
$server['url'] = Util::getScriptNameForOption(
$server['url'] = Util::getUrlForOption(
$cfg['DefaultTabServer'],
'server'
);

if (strlen($this->db) > 0) {
$database['name'] = $this->db;
$database['url'] = Util::getScriptNameForOption(
$database['url'] = Util::getUrlForOption(
$cfg['DefaultTabDatabase'],
'database'
);
if (strlen((string) $this->table) > 0) {
$table['name'] = $this->table;
$table['url'] = Util::getScriptNameForOption(
$table['url'] = Util::getUrlForOption(
$cfg['DefaultTabTable'],
'table'
);
Expand Down
55 changes: 39 additions & 16 deletions libraries/classes/Util.php
Expand Up @@ -1738,53 +1738,76 @@ public static function getTitleForTarget($target)
*
* @return string script name corresponding to the config word
*/
public static function getScriptNameForOption($target, $location)
public static function getScriptNameForOption($target, string $location): string
{
$url = self::getUrlForOption($target, $location);
if ($url === null) {
return '/';
}

return Url::getFromRoute($url);
}

/**
* Get the URL corresponding to a plain English config word
* in order to append in links on navigation and main panel
*
* @param string $target a valid value for
* $cfg['NavigationTreeDefaultTabTable'],
* $cfg['NavigationTreeDefaultTabTable2'],
* $cfg['DefaultTabTable'], $cfg['DefaultTabDatabase'] or
* $cfg['DefaultTabServer']
* @param string $location one out of 'server', 'table', 'database'
*
* @return string The URL corresponding to the config word or null if nothing was found
*/
public static function getUrlForOption($target, string $location): ?string
{
if ($location === 'server') {
// Values for $cfg['DefaultTabServer']
switch ($target) {
case 'welcome':
return Url::getFromRoute('/');
return '/';
case 'databases':
return Url::getFromRoute('/server/databases');
return '/server/databases';
case 'status':
return Url::getFromRoute('/server/status');
return '/server/status';
case 'variables':
return Url::getFromRoute('/server/variables');
return '/server/variables';
case 'privileges':
return Url::getFromRoute('/server/privileges');
return '/server/privileges';
}
} elseif ($location === 'database') {
// Values for $cfg['DefaultTabDatabase']
switch ($target) {
case 'structure':
return Url::getFromRoute('/database/structure');
return '/database/structure';
case 'sql':
return Url::getFromRoute('/database/sql');
return '/database/sql';
case 'search':
return Url::getFromRoute('/database/search');
return '/database/search';
case 'operations':
return Url::getFromRoute('/database/operations');
return '/database/operations';
}
} elseif ($location === 'table') {
// Values for $cfg['DefaultTabTable'],
// $cfg['NavigationTreeDefaultTabTable'] and
// $cfg['NavigationTreeDefaultTabTable2']
switch ($target) {
case 'structure':
return Url::getFromRoute('/table/structure');
return '/table/structure';
case 'sql':
return Url::getFromRoute('/table/sql');
return '/table/sql';
case 'search':
return Url::getFromRoute('/table/search');
return '/table/search';
case 'insert':
return Url::getFromRoute('/table/change');
return '/table/change';
case 'browse':
return Url::getFromRoute('/sql');
return '/sql';
}
}

return $target;
return null;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions templates/menu/breadcrumbs.twig
Expand Up @@ -3,7 +3,7 @@
<ol class="breadcrumb">
<li class="breadcrumb-item">
{{ show_icons('TabsMode') ? get_image('s_host') }}
<a href="{{ server.url }}">
<a href="{{ url(server.url) }}">
{% if show_text('TabsMode') %}{% trans 'Server:' %}{% endif %}
{{ server.name }}
</a>
Expand All @@ -12,7 +12,7 @@
{% if database is not empty %}
<li class="breadcrumb-item">
{{ show_icons('TabsMode') ? get_image('s_db') }}
<a href="{{ database.url }}{{ get_common({'db': database.name}, '&') }}">
<a href="{{ url(database.url, {'db': database.name}) }}">
{% if show_text('TabsMode') %}{% trans 'Database:' %}{% endif %}
{{ database.name }}
</a>
Expand All @@ -21,7 +21,7 @@
{% if table is not empty %}
<li class="breadcrumb-item">
{{ show_icons('TabsMode') ? get_image(table.is_view ? 'b_views' : 's_tbl') }}
<a href="{{ table.url }}{{ get_common({'db': database.name, 'table': table.name}, '&') }}">
<a href="{{ url(table.url, {'db': database.name, 'table': table.name}) }}">
{% if show_text('TabsMode') %}
{% if table.is_view %}
{% trans 'View:' %}
Expand Down
2 changes: 1 addition & 1 deletion test/selenium/Database/TriggersTest.php
Expand Up @@ -225,7 +225,7 @@ function (): void {
$this->dbQuery(
'SHOW TRIGGERS FROM `' . $this->databaseName . '`;',
function (): void {
$this->assertfalse($this->isElementPresent('className', 'table_results'));
$this->assertFalse($this->isElementPresent('className', 'table_results'));
}
);
}
Expand Down
6 changes: 3 additions & 3 deletions test/selenium/Table/InsertTest.php
Expand Up @@ -57,14 +57,14 @@ public function testAddData(): void

// shorter date to prevent error,
// automatically gets appended with 00:00:00
$this->byId('field_3_3')->click()->sendKeys('2011-01-2');
$this->byId('field_3_3')->click()->clear()->sendKeys('2011-01-2');

$this->byId('field_1_3')->sendKeys('1');
$this->byId('field_2_3')->sendKeys('abcd');

// shorter date to prevent error,
// automatically gets appended with 00:00:00
$this->byId('field_6_3')->click()->sendKeys('2012-01-2');
$this->byId('field_6_3')->click()->clear()->sendKeys('2012-01-2');

$this->byId('field_5_3')->sendKeys('foo');

Expand All @@ -82,7 +82,7 @@ public function testAddData(): void

// shorter date to prevent error,
// automatically gets appended with 00:00:00
$this->byId('field_3_3')->click()->sendKeys('2013-01-2');
$this->byId('field_3_3')->click()->clear()->sendKeys('2013-01-2');

$this->byId('field_2_3')->sendKeys('Abcd');

Expand Down

0 comments on commit 0c4595b

Please sign in to comment.