Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauricio@fauth.dev>2020-05-27 06:35:24 +0300
committerMaurício Meneghini Fauth <mauricio@fauth.dev>2020-05-27 06:35:24 +0300
commitf4582e083eff6033d0b2930b594554913136d8e0 (patch)
treefbccbff0fd01dd4457764dcac4fab843bd0f3d9d /test/selenium
parentbd979dd1ffa0f98a06dcda1b9921b954b87cde95 (diff)
Use early exit when possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test/selenium')
-rw-r--r--test/selenium/TestBase.php188
1 files changed, 101 insertions, 87 deletions
diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php
index 779cd1e8fc..b38c68653a 100644
--- a/test/selenium/TestBase.php
+++ b/test/selenium/TestBase.php
@@ -153,9 +153,11 @@ abstract class TestBase extends TestCase
$this->markTestSkipped('Failed to connect to MySQL (' . $e->getMessage() . ')');
}
- if ($this->_mysqli->connect_errno) {
- $this->markTestSkipped('Failed to connect to MySQL (' . $this->_mysqli->error . ')');
+ if (! $this->_mysqli->connect_errno) {
+ return;
}
+
+ $this->markTestSkipped('Failed to connect to MySQL (' . $this->_mysqli->error . ')');
}
private function getBrowserStackCredentials(): string
@@ -287,24 +289,26 @@ abstract class TestBase extends TestCase
$projectName = 'phpMyAdmin (Travis)';
}
- if ($buildLocal) {
- $capabilities->setCapability(
- 'bstack:options',
- [
- 'os' => 'Windows',
- 'osVersion' => '10',
- 'resolution' => '1920x1080',
- 'projectName' => $projectName,
- 'sessionName' => $testName,
- 'buildName' => $buildId,
- 'localIdentifier' => $buildId,
- 'local' => $buildLocal,
- 'debug' => false,
- 'consoleLogs' => 'verbose',
- 'networkLogs' => true,
- ]
- );
+ if (! $buildLocal) {
+ return;
}
+
+ $capabilities->setCapability(
+ 'bstack:options',
+ [
+ 'os' => 'Windows',
+ 'osVersion' => '10',
+ 'resolution' => '1920x1080',
+ 'projectName' => $projectName,
+ 'sessionName' => $testName,
+ 'buildName' => $buildId,
+ 'localIdentifier' => $buildId,
+ 'local' => $buildLocal,
+ 'debug' => false,
+ 'consoleLogs' => 'verbose',
+ 'networkLogs' => true,
+ ]
+ );
}
/**
@@ -410,9 +414,11 @@ abstract class TestBase extends TestCase
*/
protected function skipIfNotSuperUser()
{
- if (! $this->isSuperUser()) {
- $this->markTestSkipped('Test user is not a superuser.');
+ if ($this->isSuperUser()) {
+ return;
}
+
+ $this->markTestSkipped('Test user is not a superuser.');
}
/**
@@ -424,14 +430,16 @@ abstract class TestBase extends TestCase
{
$this->navigateTo('index.php?route=/check-relations');
$pageContent = $this->waitForElement('id', 'page_content');
- if (preg_match(
+ if (! preg_match(
'/Configuration of pmadb… not OK/i',
$pageContent->getText()
)) {
- $this->markTestSkipped(
- 'The phpMyAdmin configuration storage is not working.'
- );
+ return;
}
+
+ $this->markTestSkipped(
+ 'The phpMyAdmin configuration storage is not working.'
+ );
}
/**
@@ -626,9 +634,11 @@ abstract class TestBase extends TestCase
*/
public function logOutIfLoggedIn()
{
- if ($this->isLoggedIn()) {
- $this->byCssSelector('img.icon.ic_s_loggoff')->click();
+ if (! $this->isLoggedIn()) {
+ return;
}
+
+ $this->byCssSelector('img.icon.ic_s_loggoff')->click();
}
/**
@@ -819,11 +829,11 @@ abstract class TestBase extends TestCase
* Not supported in Safari Webdriver, see
* https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/4136
*/
- if ($this->isSafari()) {
- $this->markTestSkipped('Alerts not supported on Safari browser.');
- } else {
+ if (! $this->isSafari()) {
return $this->webDriver->switchTo()->alert()->getText();
}
+
+ $this->markTestSkipped('Alerts not supported on Safari browser.');
}
/**
@@ -1080,72 +1090,76 @@ abstract class TestBase extends TestCase
{
// If this is being run on Browerstack,
// mark the test on Browerstack as failure
- if ($this->hasBrowserstackConfig()) {
- $payload = json_encode(
- [
- 'status' => $status,
- 'reason' => $message,
- ]
- );
- /** @var resource $ch */
- $ch = curl_init();
- curl_setopt(
- $ch,
- CURLOPT_URL,
- self::SESSION_REST_URL . $this->sessionId . '.json'
- );
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
- curl_setopt(
- $ch,
- CURLOPT_USERPWD,
- $this->getBrowserStackCredentials()
- );
+ if (! $this->hasBrowserstackConfig()) {
+ return;
+ }
- $headers = [];
- $headers[] = 'Content-Type: application/json';
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ $payload = json_encode(
+ [
+ 'status' => $status,
+ 'reason' => $message,
+ ]
+ );
+ /** @var resource $ch */
+ $ch = curl_init();
+ curl_setopt(
+ $ch,
+ CURLOPT_URL,
+ self::SESSION_REST_URL . $this->sessionId . '.json'
+ );
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
+ curl_setopt(
+ $ch,
+ CURLOPT_USERPWD,
+ $this->getBrowserStackCredentials()
+ );
- curl_exec($ch);
- if ($ch !== false && curl_errno($ch)) {
- echo 'Error: ' . curl_error($ch) . PHP_EOL;
- }
- curl_close($ch);
+ $headers = [];
+ $headers[] = 'Content-Type: application/json';
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+
+ curl_exec($ch);
+ if ($ch !== false && curl_errno($ch)) {
+ echo 'Error: ' . curl_error($ch) . PHP_EOL;
}
+ curl_close($ch);
}
private function getErrorVideoUrl(): void
{
- if ($this->hasBrowserstackConfig()) {
- /** @var resource $ch */
- $ch = curl_init();
- curl_setopt(
- $ch,
- CURLOPT_URL,
- self::SESSION_REST_URL . $this->sessionId . '.json'
- );
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt(
- $ch,
- CURLOPT_USERPWD,
- $this->getBrowserStackCredentials()
- );
- $result = curl_exec($ch);
- if (is_bool($result)) {
- echo 'Error: ' . curl_error($ch) . PHP_EOL;
+ if (! $this->hasBrowserstackConfig()) {
+ return;
+ }
- 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);
+ /** @var resource $ch */
+ $ch = curl_init();
+ curl_setopt(
+ $ch,
+ CURLOPT_URL,
+ self::SESSION_REST_URL . $this->sessionId . '.json'
+ );
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt(
+ $ch,
+ CURLOPT_USERPWD,
+ $this->getBrowserStackCredentials()
+ );
+ $result = curl_exec($ch);
+ if (is_bool($result)) {
+ echo 'Error: ' . curl_error($ch) . PHP_EOL;
+
+ 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);
}
/**