Visitar URL original
Fix some failing Selenium tests · phpmyadmin/phpmyadmin@aee2faf · GitHub
Skip to content

Commit aee2faf

Browse files
committed
Fix some failing Selenium tests
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 25e00f3 commit aee2faf

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

‎test/selenium/CreateRemoveUserTest.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace PhpMyAdmin\Tests\Selenium;
66

7+
use function bin2hex;
8+
use function random_bytes;
9+
710
/**
811
* @coversNothing
912
*/
@@ -37,7 +40,7 @@ protected function setUp(): void
3740
{
3841
parent::setUp();
3942
$this->skipIfNotSuperUser();
40-
$this->txtUsername = 'pma_user';
43+
$this->txtUsername = 'test_user_' . bin2hex(random_bytes(4));
4144
$this->txtPassword = 'abc_123';
4245
$this->login();
4346
}
@@ -102,7 +105,7 @@ public function testCreateRemoveUser(): void
102105
$this->byId('dropUsersDbCheckbox')->click();
103106

104107
$this->byId('buttonGo')->click();
105-
$this->waitForElement('cssSelector', 'button.submitOK')->click();
108+
$this->waitForElement('id', 'functionConfirmOkButton')->click();
106109
$this->acceptAlert();
107110

108111
$success = $this->waitForElement('cssSelector', '.alert-success');

‎test/selenium/Database/StructureTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testTruncateTable(): void
4949
{
5050
$this->byXPath("(//a[contains(., 'Empty')])[1]")->click();
5151

52-
$this->waitForElement('cssSelector', 'button.submitOK')->click();
52+
$this->waitForElement('id', 'functionConfirmOkButton')->click();
5353

5454
$this->assertNotNull(
5555
$this->waitForElement(

‎test/selenium/TestBase.php‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use PHPUnit\Framework\TestCase;
2222
use Throwable;
2323

24+
use function bin2hex;
2425
use function curl_close;
2526
use function curl_errno;
2627
use function curl_error;
@@ -36,12 +37,9 @@
3637
use function json_decode;
3738
use function json_encode;
3839
use function mb_strtolower;
39-
use function mb_substr;
40-
use function mt_getrandmax;
4140
use function preg_match;
42-
use function random_int;
41+
use function random_bytes;
4342
use function reset;
44-
use function sha1;
4543
use function sprintf;
4644
use function strlen;
4745
use function substr;
@@ -159,7 +157,7 @@ protected function setUp(): void
159157
*/
160158
protected function createDatabase(): void
161159
{
162-
$this->databaseName = $this->getDbPrefix() . mb_substr(sha1((string) random_int(0, mt_getrandmax())), 0, 7);
160+
$this->databaseName = $this->getDbPrefix() . bin2hex(random_bytes(4));
163161
$this->dbQuery(
164162
'CREATE DATABASE IF NOT EXISTS `' . $this->databaseName . '`; USE `' . $this->databaseName . '`;'
165163
);

0 commit comments

Comments
 (0)