diff --git a/composer.json b/composer.json index 0900dd462c..9a3ce40736 100644 --- a/composer.json +++ b/composer.json @@ -99,7 +99,7 @@ "symfony/finder": "^5.2.3", "symfony/twig-bridge": "^5.2.3", "tecnickcom/tcpdf": "^6.4.1", - "vimeo/psalm": "^4.8.0" + "vimeo/psalm": "^4.8.1" }, "extra": { "branch-alias": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2391c81d72..3e3b35f86c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1915,28 +1915,3 @@ parameters: count: 1 path: test/classes/TrackingTest.php - - - message: "#^Parameter \\#1 \\$element of method PhpMyAdmin\\\\Tests\\\\Selenium\\\\TestBase\\:\\:moveto\\(\\) expects Facebook\\\\WebDriver\\\\Remote\\\\RemoteWebElement, Facebook\\\\WebDriver\\\\WebDriverElement given\\.$#" - count: 1 - path: test/selenium/CreateRemoveUserTest.php - - - - message: "#^Parameter \\#1 \\$element of method PhpMyAdmin\\\\Tests\\\\Selenium\\\\TestBase\\:\\:moveto\\(\\) expects Facebook\\\\WebDriver\\\\Remote\\\\RemoteWebElement, Facebook\\\\WebDriver\\\\WebDriverElement given\\.$#" - count: 2 - path: test/selenium/ServerSettingsTest.php - - - - message: "#^Parameter \\#1 \\$element of method PhpMyAdmin\\\\Tests\\\\Selenium\\\\TestBase\\:\\:moveto\\(\\) expects Facebook\\\\WebDriver\\\\Remote\\\\RemoteWebElement, Facebook\\\\WebDriver\\\\WebDriverElement given\\.$#" - count: 4 - path: test/selenium/Table/BrowseTest.php - - - - message: "#^Parameter \\#1 \\$element of method PhpMyAdmin\\\\Tests\\\\Selenium\\\\TestBase\\:\\:moveto\\(\\) expects Facebook\\\\WebDriver\\\\Remote\\\\RemoteWebElement, Facebook\\\\WebDriver\\\\WebDriverElement given\\.$#" - count: 1 - path: test/selenium/Table/CreateTest.php - - - - message: "#^Parameter \\#1 \\$element of method PhpMyAdmin\\\\Tests\\\\Selenium\\\\TestBase\\:\\:moveto\\(\\) expects Facebook\\\\WebDriver\\\\Remote\\\\RemoteWebElement, Facebook\\\\WebDriver\\\\WebDriverElement given\\.$#" - count: 1 - path: test/selenium/TrackingTest.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index f4ace83453..f7d9131b69 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2858,52 +2858,9 @@ testGetLatestCompatibleVersionWithNewPHPVersion - - - toString - toString - toString - - - - - $ele - - - - - $ele - $ele - - - - - $ele - $ele - $elem - $element - - - - - $ele - - getName - - getenv('GITHUB_ACTION') - getenv('TESTSUITE_BROWSERSTACK_KEY') - getenv('TESTSUITE_BROWSERSTACK_USER') - getenv('TESTSUITE_SELENIUM_HOST') - getenv('TESTSUITE_SELENIUM_PORT') - - - - - $ele - diff --git a/test/classes/Plugins/Auth/AuthenticationCookieTest.php b/test/classes/Plugins/Auth/AuthenticationCookieTest.php index 7e547031cd..248f51c6b6 100644 --- a/test/classes/Plugins/Auth/AuthenticationCookieTest.php +++ b/test/classes/Plugins/Auth/AuthenticationCookieTest.php @@ -9,6 +9,7 @@ use PhpMyAdmin\ErrorHandler; use PhpMyAdmin\Footer; use PhpMyAdmin\Header; use PhpMyAdmin\Plugins\Auth\AuthenticationCookie; +use PhpMyAdmin\Response; use PhpMyAdmin\Tests\AbstractNetworkTestCase; use ReflectionException; use ReflectionMethod; @@ -176,6 +177,9 @@ class AuthenticationCookieTest extends AbstractNetworkTestCase */ public function testAuthError(): void { + $_REQUEST = []; + Response::getInstance()->setAjax(false); + $_REQUEST['old_usr'] = ''; $GLOBALS['cfg']['LoginCookieRecall'] = true; $GLOBALS['cfg']['blowfish_secret'] = 'secret'; diff --git a/test/selenium/ChangePasswordTest.php b/test/selenium/ChangePasswordTest.php index e590c11481..75c4da4e77 100644 --- a/test/selenium/ChangePasswordTest.php +++ b/test/selenium/ChangePasswordTest.php @@ -52,21 +52,21 @@ class ChangePasswordTest extends TestBase $ele = $this->waitForElement('name', 'pma_pw'); $this->assertEquals('', $ele->getAttribute('value')); } catch (AssertionFailedError $e) { - array_push($this->verificationErrors, $e->toString()); + 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->toString()); + array_push($this->verificationErrors, $e->getMessage()); } try { $ele = $this->waitForElement('name', 'generated_pw'); $this->assertEquals('', $ele->getAttribute('value')); } catch (AssertionFailedError $e) { - array_push($this->verificationErrors, $e->toString()); + array_push($this->verificationErrors, $e->getMessage()); } $this->byId('button_generate_password')->click(); diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php index 0477b7a434..7fcc44508d 100644 --- a/test/selenium/TestBase.php +++ b/test/selenium/TestBase.php @@ -189,7 +189,7 @@ abstract class TestBase extends TestCase private function getBrowserStackCredentials(): string { - return getenv('TESTSUITE_BROWSERSTACK_USER') . ':' . getenv('TESTSUITE_BROWSERSTACK_KEY'); + return (string) getenv('TESTSUITE_BROWSERSTACK_USER') . ':' . (string) getenv('TESTSUITE_BROWSERSTACK_KEY'); } protected function getTestSuiteUserLogin(): string @@ -257,8 +257,8 @@ abstract class TestBase extends TestCase if ($this->hasSeleniumConfig()) { return 'http://' - . getenv('TESTSUITE_SELENIUM_HOST') . ':' - . getenv('TESTSUITE_SELENIUM_PORT') . '/wd/hub'; + . (string) getenv('TESTSUITE_SELENIUM_HOST') . ':' + . (string) getenv('TESTSUITE_SELENIUM_PORT') . '/wd/hub'; } return ''; @@ -310,13 +310,15 @@ abstract class TestBase extends TestCase $buildLocal = true; $buildId = 'Manual'; $projectName = 'phpMyAdmin'; + $buildTagEnv = getenv('BUILD_TAG'); + $githubActionEnv = getenv('GITHUB_ACTION'); - if (getenv('BUILD_TAG')) { - $buildId = getenv('BUILD_TAG'); + if ($buildTagEnv) { + $buildId = $buildTagEnv; $buildLocal = false; $projectName = 'phpMyAdmin (Jenkins)'; - } elseif (getenv('GITHUB_ACTION')) { - $buildId = 'github-' . getenv('GITHUB_ACTION'); + } elseif ($githubActionEnv) { + $buildId = 'github-' . $githubActionEnv; $buildLocal = true; $projectName = 'phpMyAdmin (GitHub - Actions)'; } @@ -536,7 +538,7 @@ abstract class TestBase extends TestCase * * @param string $id The element ID */ - public function byId(string $id): WebDriverElement + public function byId(string $id): RemoteWebElement { return $this->webDriver->findElement(WebDriverBy::id($id)); } @@ -546,7 +548,7 @@ abstract class TestBase extends TestCase * * @param string $selector The element css selector */ - public function byCssSelector(string $selector): WebDriverElement + public function byCssSelector(string $selector): RemoteWebElement { return $this->webDriver->findElement(WebDriverBy::cssSelector($selector)); } @@ -556,7 +558,7 @@ abstract class TestBase extends TestCase * * @param string $xpath The xpath */ - public function byXPath(string $xpath): WebDriverElement + public function byXPath(string $xpath): RemoteWebElement { return $this->webDriver->findElement(WebDriverBy::xpath($xpath)); } @@ -566,7 +568,7 @@ abstract class TestBase extends TestCase * * @param string $linkText The link text */ - public function byLinkText(string $linkText): WebDriverElement + public function byLinkText(string $linkText): RemoteWebElement { return $this->webDriver->findElement(WebDriverBy::linkText($linkText)); } @@ -592,7 +594,7 @@ abstract class TestBase extends TestCase * * @param string $partialLinkText The partial link text */ - public function byPartialLinkText(string $partialLinkText): WebDriverElement + public function byPartialLinkText(string $partialLinkText): RemoteWebElement { return $this->webDriver->findElement(WebDriverBy::partialLinkText($partialLinkText)); } @@ -610,7 +612,7 @@ abstract class TestBase extends TestCase * * @param string $name The name */ - public function byName(string $name): WebDriverElement + public function byName(string $name): RemoteWebElement { return $this->webDriver->findElement(WebDriverBy::name($name)); } @@ -764,10 +766,8 @@ abstract class TestBase extends TestCase * * @param string $func Locate using - cssSelector, xpath, tagName, partialLinkText, linkText, name, id, className * @param string $arg Selector - * - * @return WebDriverElement Element waited for */ - public function waitForElement(string $func, string $arg): WebDriverElement + public function waitForElement(string $func, string $arg): RemoteWebElement { return $this->webDriver->wait(30, 500)->until( WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::$func($arg)) @@ -781,7 +781,7 @@ abstract class TestBase extends TestCase * @param string $arg Selector * @param int $timeout Timeout in seconds */ - public function waitUntilElementIsPresent(string $func, string $arg, int $timeout): WebDriverElement + public function waitUntilElementIsPresent(string $func, string $arg, int $timeout): RemoteWebElement { return $this->webDriver->wait($timeout, 500)->until( WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::$func($arg))