diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2021-03-05 21:27:03 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2021-03-05 21:27:03 +0300 |
commit | d83abf63e773a6f5e227d1cc6b3108ee1e8599f1 (patch) | |
tree | 21763faa9ec24a9bed5a0dd268eacebe2ba124a6 /test/selenium | |
parent | 0b8edc5bde3e0c553d4c83c6148dd1ff894564be (diff) |
Use PSR-12 for control structures spacing
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test/selenium')
-rw-r--r-- | test/selenium/ChangePasswordTest.php | 3 | ||||
-rw-r--r-- | test/selenium/Database/ProceduresTest.php | 1 | ||||
-rw-r--r-- | test/selenium/Table/InsertTest.php | 1 | ||||
-rw-r--r-- | test/selenium/TestBase.php | 37 | ||||
-rw-r--r-- | test/selenium/XssTest.php | 1 |
5 files changed, 36 insertions, 7 deletions
diff --git a/test/selenium/ChangePasswordTest.php b/test/selenium/ChangePasswordTest.php index db082e095f..e590c11481 100644 --- a/test/selenium/ChangePasswordTest.php +++ b/test/selenium/ChangePasswordTest.php @@ -54,18 +54,21 @@ class ChangePasswordTest extends TestBase } catch (AssertionFailedError $e) { array_push($this->verificationErrors, $e->toString()); } + try { $ele = $this->waitForElement('name', 'pma_pw2'); $this->assertEquals('', $ele->getAttribute('value')); } catch (AssertionFailedError $e) { array_push($this->verificationErrors, $e->toString()); } + try { $ele = $this->waitForElement('name', 'generated_pw'); $this->assertEquals('', $ele->getAttribute('value')); } catch (AssertionFailedError $e) { array_push($this->verificationErrors, $e->toString()); } + $this->byId('button_generate_password')->click(); $this->assertNotEquals('', $this->byName('pma_pw')->getAttribute('value')); $this->assertNotEquals('', $this->byName('pma_pw2')->getAttribute('value')); diff --git a/test/selenium/Database/ProceduresTest.php b/test/selenium/Database/ProceduresTest.php index b807c1f3a8..029e3ea682 100644 --- a/test/selenium/Database/ProceduresTest.php +++ b/test/selenium/Database/ProceduresTest.php @@ -99,6 +99,7 @@ class ProceduresTest extends TestBase $this->getSqlMode() ); } + parent::tearDown(); } diff --git a/test/selenium/Table/InsertTest.php b/test/selenium/Table/InsertTest.php index 0230f0f444..1e61df0bf6 100644 --- a/test/selenium/Table/InsertTest.php +++ b/test/selenium/Table/InsertTest.php @@ -48,6 +48,7 @@ class InsertTest extends TestBase /* TODO: this should be fixed, but the cause is unclear to me */ $this->markTestIncomplete('Fails with Safari'); } + $this->waitAjax(); $this->expandMore(); diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php index c4171fce9e..0d8d8b8ece 100644 --- a/test/selenium/TestBase.php +++ b/test/selenium/TestBase.php @@ -275,6 +275,7 @@ abstract class TestBase extends TestCase if ($suiteUrl === false) { $suiteUrl = ''; } + if (substr($suiteUrl, -1) === '/') { $url = $suiteUrl . $url; } else { @@ -382,6 +383,7 @@ abstract class TestBase extends TestCase } return $capabilities; + case 'safari': $capabilities = DesiredCapabilities::safari(); if ($this->hasCIConfig() && $this->hasBrowserstackConfig()) { @@ -400,6 +402,7 @@ abstract class TestBase extends TestCase } return $capabilities; + case 'edge': $capabilities = DesiredCapabilities::microsoftEdge(); if ($this->hasCIConfig() && $this->hasBrowserstackConfig()) { @@ -466,10 +469,12 @@ abstract class TestBase extends TestCase { $this->navigateTo('index.php?route=/check-relations'); $pageContent = $this->waitForElement('id', 'page_content'); - if (! preg_match( - '/Configuration of pmadb… not OK/i', - $pageContent->getText() - )) { + if ( + ! preg_match( + '/Configuration of pmadb… not OK/i', + $pageContent->getText() + ) + ) { return; } @@ -478,6 +483,7 @@ abstract class TestBase extends TestCase 'The phpMyAdmin configuration storage is not working.' ); } + // If it failed the code already has exited with markTestSkipped $this->hadStorageDatabaseInstall = true; } @@ -494,14 +500,18 @@ abstract class TestBase extends TestCase if ($username === '') { $username = $this->getTestSuiteUserLogin(); } + if ($password === '') { $password = $this->getTestSuiteUserPassword(); } + $this->navigateTo(''); /* Wait while page */ - while ($this->webDriver->executeScript( - 'return document.readyState !== "complete";' - )) { + while ( + $this->webDriver->executeScript( + 'return document.readyState !== "complete";' + ) + ) { usleep(5000); } @@ -669,6 +679,7 @@ abstract class TestBase extends TestCase return false; } + $this->byXPath('//*[contains(@class,"nav-item") and contains(., "SQL")]')->click(); $this->waitAjax(); $this->typeInTextArea($query); @@ -676,6 +687,7 @@ abstract class TestBase extends TestCase if ($afterSubmit !== null) { $afterSubmit->call($this); } + $this->waitAjax(); $this->waitForElement('className', 'result_query'); // If present then @@ -703,6 +715,7 @@ abstract class TestBase extends TestCase if ($this->webDriver === null) { return; } + $key = time(); // This call will also create the file path @@ -802,6 +815,7 @@ abstract class TestBase extends TestCase if (! $this->isElementPresent($func, $arg)) { return; } + usleep(5000); } } @@ -971,6 +985,7 @@ abstract class TestBase extends TestCase if ($this->isElementPresent('cssSelector', 'li.nav-item.dropdown.d-none')) { return; } + // Not found, searching for another alternative try { $ele = $this->waitForElement('cssSelector', 'li.dropdown > a'); @@ -1159,12 +1174,15 @@ abstract class TestBase extends TestCase if (static::$createDatabase) { $this->dbQuery('DROP DATABASE IF EXISTS `' . $this->databaseName . '`;'); } + if ($this->hadStorageDatabaseInstall) { $this->dbQuery('DROP DATABASE IF EXISTS `phpmyadmin`;'); } + if (! $this->hasFailed()) { $this->markTestAs('passed', ''); } + $this->sqlWindowHandle = null; $this->webDriver->quit(); } @@ -1213,6 +1231,7 @@ abstract class TestBase extends TestCase if ($ch !== false && curl_errno($ch)) { echo 'Error: ' . curl_error($ch) . PHP_EOL; } + curl_close($ch); } @@ -1241,13 +1260,16 @@ abstract class TestBase extends TestCase return; } + $proj = json_decode($result); if (isset($proj->automation_session)) { echo 'Test failed, get more information here: ' . $proj->automation_session->public_url . PHP_EOL; } + if ($ch !== false && curl_errno($ch)) { echo 'Error: ' . curl_error($ch) . PHP_EOL; } + curl_close($ch); } @@ -1264,6 +1286,7 @@ abstract class TestBase extends TestCase if ($this->webDriver !== null) { $this->webDriver->quit(); } + $this->sqlWindowHandle = null; $this->getErrorVideoUrl(); diff --git a/test/selenium/XssTest.php b/test/selenium/XssTest.php index 4335b7fac6..b18627f1f7 100644 --- a/test/selenium/XssTest.php +++ b/test/selenium/XssTest.php @@ -37,6 +37,7 @@ class XssTest extends TestBase if ($this->isSafari()) { $this->markTestSkipped('Alerts not supported on Safari browser.'); } + $this->waitForElement('partialLinkText', 'SQL')->click(); $this->waitAjax(); |