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:
-rw-r--r--phpstan-baseline.neon45
-rw-r--r--psalm-baseline.xml24
-rw-r--r--test/selenium/ChangePasswordTest.php35
-rw-r--r--test/selenium/ExportTest.php15
-rw-r--r--test/selenium/TestBase.php20
5 files changed, 31 insertions, 108 deletions
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 8c1ed5ce26..23e7698e45 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -10335,48 +10335,3 @@ parameters:
count: 1
path: test/classes/ZipExtensionTest.php
- -
- message: "#^Property PhpMyAdmin\\\\Tests\\\\Selenium\\\\ChangePasswordTest\\:\\:\\$verificationErrors is never written, only read\\.$#"
- count: 1
- path: test/selenium/ChangePasswordTest.php
-
- -
- message: "#^Method PhpMyAdmin\\\\Tests\\\\Selenium\\\\ExportTest\\:\\:exportDataProvider\\(\\) return type has no value type specified in iterable type array\\.$#"
- count: 1
- path: test/selenium/ExportTest.php
-
- -
- message: "#^Method PhpMyAdmin\\\\Tests\\\\Selenium\\\\ExportTest\\:\\:testDbExport\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#"
- count: 1
- path: test/selenium/ExportTest.php
-
- -
- message: "#^Method PhpMyAdmin\\\\Tests\\\\Selenium\\\\ExportTest\\:\\:testServerExport\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#"
- count: 1
- path: test/selenium/ExportTest.php
-
- -
- message: "#^Method PhpMyAdmin\\\\Tests\\\\Selenium\\\\ExportTest\\:\\:testTableExport\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#"
- count: 1
- path: test/selenium/ExportTest.php
-
- -
- message: "#^Cannot access property \\$automation_session on mixed\\.$#"
- count: 1
- path: test/selenium/TestBase.php
-
- -
- message: "#^Method PhpMyAdmin\\\\Tests\\\\Selenium\\\\TestBase\\:\\:waitForElement\\(\\) should return Facebook\\\\WebDriver\\\\Remote\\\\RemoteWebElement but returns mixed\\.$#"
- count: 1
- path: test/selenium/TestBase.php
-
- -
- message: "#^Method PhpMyAdmin\\\\Tests\\\\Selenium\\\\TestBase\\:\\:waitUntilElementIsPresent\\(\\) should return Facebook\\\\WebDriver\\\\Remote\\\\RemoteWebElement but returns mixed\\.$#"
- count: 1
- path: test/selenium/TestBase.php
-
- -
- message: "#^Method PhpMyAdmin\\\\Tests\\\\Selenium\\\\TestBase\\:\\:waitUntilElementIsVisible\\(\\) should return Facebook\\\\WebDriver\\\\WebDriverElement but returns mixed\\.$#"
- count: 1
- path: test/selenium/TestBase.php
-
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index cd6404002a..6121d61b2c 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -16151,21 +16151,6 @@
<code>$sqlMode</code>
</MixedReturnStatement>
</file>
- <file src="test/selenium/ExportTest.php">
- <MixedArgument occurrences="3">
- <code>$str</code>
- <code>$str</code>
- <code>$str</code>
- </MixedArgument>
- <MixedAssignment occurrences="3">
- <code>$str</code>
- <code>$str</code>
- <code>$str</code>
- </MixedAssignment>
- <MixedInferredReturnType occurrences="1">
- <code>array</code>
- </MixedInferredReturnType>
- </file>
<file src="test/selenium/TestBase.php">
<DocblockTypeContradiction occurrences="1">
<code>$this-&gt;webDriver === null</code>
@@ -16189,20 +16174,13 @@
<code>$proj</code>
<code>$this-&gt;sqlWindowHandle</code>
</MixedAssignment>
- <MixedInferredReturnType occurrences="3">
- <code>RemoteWebElement</code>
- <code>RemoteWebElement</code>
- <code>WebDriverElement</code>
- </MixedInferredReturnType>
<MixedOperand occurrences="2">
<code>$ajax_message_count</code>
<code>$proj-&gt;automation_session-&gt;public_url</code>
</MixedOperand>
- <MixedPropertyFetch occurrences="2">
- <code>$proj-&gt;automation_session</code>
+ <MixedPropertyFetch occurrences="1">
<code>$proj-&gt;automation_session-&gt;public_url</code>
</MixedPropertyFetch>
- <MixedReturnStatement occurrences="3"/>
<RedundantConditionGivenDocblockType occurrences="5">
<code>$text &amp;&amp; is_string($text)</code>
<code>$text &amp;&amp; is_string($text)</code>
diff --git a/test/selenium/ChangePasswordTest.php b/test/selenium/ChangePasswordTest.php
index f04a7690f4..2319f5ce8d 100644
--- a/test/selenium/ChangePasswordTest.php
+++ b/test/selenium/ChangePasswordTest.php
@@ -4,9 +4,6 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests\Selenium;
-use PHPUnit\Framework\AssertionFailedError;
-
-use function array_push;
use function trim;
/**
@@ -22,13 +19,6 @@ class ChangePasswordTest extends TestBase
protected static $createDatabase = false;
/**
- * Array of AssertionFailedError->toString
- *
- * @var string[]
- */
- private $verificationErrors;
-
- /**
* Tests the changing of the password
*
* @group large
@@ -43,26 +33,15 @@ class ChangePasswordTest extends TestBase
$this->waitAjax();
$this->waitForElement('xpath', "//span[contains(., 'Change password')]");
- try {
- $ele = $this->waitForElement('name', 'pma_pw');
- $this->assertEquals('', $ele->getAttribute('value'));
- } catch (AssertionFailedError $e) {
- array_push($this->verificationErrors, $e->getMessage());
- }
- try {
- $ele = $this->waitForElement('name', 'pma_pw2');
- $this->assertEquals('', $ele->getAttribute('value'));
- } catch (AssertionFailedError $e) {
- array_push($this->verificationErrors, $e->getMessage());
- }
+ $ele = $this->waitForElement('name', 'pma_pw');
+ $this->assertEquals('', $ele->getAttribute('value'));
- try {
- $ele = $this->waitForElement('name', 'generated_pw');
- $this->assertEquals('', $ele->getAttribute('value'));
- } catch (AssertionFailedError $e) {
- array_push($this->verificationErrors, $e->getMessage());
- }
+ $ele = $this->waitForElement('name', 'pma_pw2');
+ $this->assertEquals('', $ele->getAttribute('value'));
+
+ $ele = $this->waitForElement('name', 'generated_pw');
+ $this->assertEquals('', $ele->getAttribute('value'));
$this->byId('button_generate_password')->click();
$this->assertNotEquals('', $this->byName('pma_pw')->getAttribute('value'));
diff --git a/test/selenium/ExportTest.php b/test/selenium/ExportTest.php
index 94aca69911..5493feea7e 100644
--- a/test/selenium/ExportTest.php
+++ b/test/selenium/ExportTest.php
@@ -33,8 +33,8 @@ class ExportTest extends TestBase
/**
* Test for server level export
*
- * @param string $plugin Export format
- * @param array $expected Array of expected strings
+ * @param string $plugin Export format
+ * @param string[] $expected Array of expected strings
*
* @dataProvider exportDataProvider
* @group large
@@ -51,8 +51,8 @@ class ExportTest extends TestBase
/**
* Test for db level export
*
- * @param string $plugin Export format
- * @param array $expected Array of expected strings
+ * @param string $plugin Export format
+ * @param string[] $expected Array of expected strings
*
* @dataProvider exportDataProvider
* @group large
@@ -71,8 +71,8 @@ class ExportTest extends TestBase
/**
* Test for table level export
*
- * @param string $plugin Export format
- * @param array $expected Array of expected strings
+ * @param string $plugin Export format
+ * @param string[] $expected Array of expected strings
*
* @dataProvider exportDataProvider
* @group large
@@ -91,7 +91,8 @@ class ExportTest extends TestBase
}
/**
- * Data provider for testServerExport
+ * @return array<int, array<int, string|array<int, string>>>
+ * @psalm-return array<int, array{string, string[]}>
*/
public function exportDataProvider(): array
{
diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php
index 3689609224..1a1e54dd2a 100644
--- a/test/selenium/TestBase.php
+++ b/test/selenium/TestBase.php
@@ -33,11 +33,13 @@ use function end;
use function file_put_contents;
use function getenv;
use function is_bool;
+use function is_object;
use function is_string;
use function json_decode;
use function json_encode;
use function mb_strtolower;
use function preg_match;
+use function property_exists;
use function random_bytes;
use function reset;
use function sprintf;
@@ -732,9 +734,12 @@ abstract class TestBase extends TestCase
*/
public function waitForElement(string $func, string $arg): RemoteWebElement
{
- return $this->webDriver->wait(30, 500)->until(
+ $element = $this->webDriver->wait(30, 500)->until(
WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::$func($arg))
);
+ $this->assertInstanceOf(RemoteWebElement::class, $element);
+
+ return $element;
}
/**
@@ -746,9 +751,12 @@ abstract class TestBase extends TestCase
*/
public function waitUntilElementIsPresent(string $func, string $arg, int $timeout): RemoteWebElement
{
- return $this->webDriver->wait($timeout, 500)->until(
+ $element = $this->webDriver->wait($timeout, 500)->until(
WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::$func($arg))
);
+ $this->assertInstanceOf(RemoteWebElement::class, $element);
+
+ return $element;
}
/**
@@ -760,9 +768,12 @@ abstract class TestBase extends TestCase
*/
public function waitUntilElementIsVisible(string $func, string $arg, int $timeout): WebDriverElement
{
- return $this->webDriver->wait($timeout, 500)->until(
+ $element = $this->webDriver->wait($timeout, 500)->until(
WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::$func($arg))
);
+ $this->assertInstanceOf(WebDriverElement::class, $element);
+
+ return $element;
}
/**
@@ -1181,8 +1192,7 @@ JS;
}
$proj = json_decode($result);
- // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
- if (isset($proj->automation_session)) {
+ if (is_object($proj) && property_exists($proj, 'automation_session')) {
// phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
echo 'Test failed, get more information here: ' . $proj->automation_session->public_url . PHP_EOL;
}