Visitar URL original
Merge pull request #19406 from kamil-tekiela/PHPUnit-fixes · phpmyadmin/phpmyadmin@a1e99f9 · GitHub
Skip to content

Commit a1e99f9

Browse files
Merge pull request #19406 from kamil-tekiela/PHPUnit-fixes
PHPUnit fixes
2 parents 4ba5cf1 + 8df3619 commit a1e99f9

41 files changed

Lines changed: 180 additions & 194 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎phpstan-baseline.neon‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14229,12 +14229,6 @@ parameters:
1422914229
count: 2
1423014230
path: src/Plugins/Export/Helpers/Pdf.php
1423114231

14232-
-
14233-
message: '#^Cannot cast mixed to string\.$#'
14234-
identifier: cast.string
14235-
count: 6
14236-
path: src/Plugins/Export/Helpers/TableProperty.php
14237-
1423814232
-
1423914233
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
1424014234
identifier: foreach.nonIterable
@@ -22341,6 +22335,12 @@ parameters:
2234122335
count: 2
2234222336
path: tests/unit/IpAllowDenyTest.php
2234322337

22338+
-
22339+
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertSame\(\) with array\{\} and array\{\000PhpMyAdmin\\ListDatabase\000dbi\: PhpMyAdmin\\DatabaseInterface, \000PhpMyAdmin\\ListDatabase\000config\: PhpMyAdmin\\Config, \000PhpMyAdmin\\ListDatabase\000userPrivilegesFactory\: PhpMyAdmin\\UserPrivilegesFactory\} will always evaluate to false\.$#'
22340+
identifier: staticMethod.impossibleType
22341+
count: 1
22342+
path: tests/unit/ListDatabaseTest.php
22343+
2234422344
-
2234522345
message: '''
2234622346
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:

‎src/Config.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function checkClient(): void
228228
$this->set('PMA_USR_BROWSER_VER', $logVersion[2]);
229229
$this->set('PMA_USR_BROWSER_AGENT', 'IE');
230230
} elseif (preg_match('@Trident/(7)\.0@', $httpUserAgent, $logVersion) === 1) {
231-
$this->set('PMA_USR_BROWSER_VER', (int) $logVersion[1] + 4);
231+
$this->set('PMA_USR_BROWSER_VER', (string) ((int) $logVersion[1] + 4));
232232
$this->set('PMA_USR_BROWSER_AGENT', 'IE');
233233
} elseif (preg_match('@OmniWeb/([0-9]{1,3})@', $httpUserAgent, $logVersion) === 1) {
234234
$this->set('PMA_USR_BROWSER_VER', $logVersion[1]);

‎src/Plugins/Export/Helpers/TableProperty.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class TableProperty
5050
*/
5151
public string $ext;
5252

53-
/** @param mixed[] $row table row */
53+
/** @param list<string|null> $row table row */
5454
public function __construct(array $row)
5555
{
5656
$this->name = trim((string) $row[0]);

‎tests/end-to-end/ChangePasswordTest.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ public function testChangePassword(): void
3333
$this->waitForElement('xpath', "//span[contains(., 'Change password')]");
3434

3535
$ele = $this->waitForElement('name', 'pma_pw');
36-
self::assertEquals('', $ele->getAttribute('value'));
36+
self::assertSame('', $ele->getAttribute('value'));
3737

3838
$ele = $this->waitForElement('name', 'pma_pw2');
39-
self::assertEquals('', $ele->getAttribute('value'));
39+
self::assertSame('', $ele->getAttribute('value'));
4040

4141
$ele = $this->waitForElement('name', 'generated_pw');
42-
self::assertEquals('', $ele->getAttribute('value'));
42+
self::assertSame('', $ele->getAttribute('value'));
4343

4444
$this->byId('button_generate_password')->click();
45-
self::assertNotEquals('', $this->byName('pma_pw')->getAttribute('value'));
46-
self::assertNotEquals('', $this->byName('pma_pw2')->getAttribute('value'));
47-
self::assertNotEquals('', $this->byName('generated_pw')->getAttribute('value'));
45+
self::assertNotSame('', $this->byName('pma_pw')->getAttribute('value'));
46+
self::assertNotSame('', $this->byName('pma_pw2')->getAttribute('value'));
47+
self::assertNotSame('', $this->byName('generated_pw')->getAttribute('value'));
4848

4949
if ($this->getTestSuiteUserPassword() !== '') {
5050
$this->byName('pma_pw')->clear();
@@ -59,7 +59,7 @@ public function testChangePassword(): void
5959

6060
$this->byId('changePasswordGoButton')->click();
6161
$ele = $this->waitForElement('cssSelector', '.alert-success');
62-
self::assertEquals(
62+
self::assertSame(
6363
'The profile has been updated.',
6464
trim($ele->getText()),
6565
);

‎tests/end-to-end/CreateDropDatabaseTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testCreateDropDatabase(): void
4545
'SHOW DATABASES LIKE \'' . $this->databaseName . '\';',
4646
function (): void {
4747
self::assertTrue($this->isElementPresent('className', 'table_results'));
48-
self::assertEquals($this->databaseName, $this->getCellByTableClass('table_results', 1, 1));
48+
self::assertSame($this->databaseName, $this->getCellByTableClass('table_results', 1, 1));
4949
},
5050
);
5151

‎tests/end-to-end/CreateRemoveUserTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function testCreateRemoveUser(): void
6868
$genButton = $this->waitForElement('id', 'button_generate_password');
6969
$genButton->click();
7070

71-
self::assertNotEquals('', $this->byId('text_pma_pw')->getAttribute('value'));
72-
self::assertNotEquals('', $this->byId('text_pma_pw2')->getAttribute('value'));
73-
self::assertNotEquals('', $this->byId('generated_pw')->getAttribute('value'));
71+
self::assertNotSame('', $this->byId('text_pma_pw')->getAttribute('value'));
72+
self::assertNotSame('', $this->byId('text_pma_pw2')->getAttribute('value'));
73+
self::assertNotSame('', $this->byId('generated_pw')->getAttribute('value'));
7474

7575
$this->byId('text_pma_pw')->sendKeys($this->txtPassword);
7676
$this->byId('text_pma_pw2')->sendKeys($this->txtPassword);

‎tests/end-to-end/Database/EventsTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ public function testAddEvent(): void
137137
. 'SHOW EVENTS WHERE Db=\'' . $this->databaseName . '\' AND Name=\'test_event\';',
138138
function (): void {
139139
self::assertTrue($this->isElementPresent('className', 'table_results'));
140-
self::assertEquals($this->databaseName, $this->getCellByTableClass('table_results', 1, 1));
141-
self::assertEquals('test_event', $this->getCellByTableClass('table_results', 1, 2));
142-
self::assertEquals('RECURRING', $this->getCellByTableClass('table_results', 1, 5));
140+
self::assertSame($this->databaseName, $this->getCellByTableClass('table_results', 1, 1));
141+
self::assertSame('test_event', $this->getCellByTableClass('table_results', 1, 2));
142+
self::assertSame('RECURRING', $this->getCellByTableClass('table_results', 1, 5));
143143
},
144144
);
145145

‎tests/end-to-end/Database/OperationsTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testRenameDB(): void
6969
'SHOW DATABASES LIKE \'' . $newDbName . '\'',
7070
function () use ($newDbName): void {
7171
self::assertTrue($this->isElementPresent('className', 'table_results'));
72-
self::assertEquals($newDbName, $this->getCellByTableClass('table_results', 1, 1));
72+
self::assertSame($newDbName, $this->getCellByTableClass('table_results', 1, 1));
7373
},
7474
);
7575

@@ -111,7 +111,7 @@ public function testCopyDb(): void
111111
'SHOW DATABASES LIKE \'' . $newDbName . '\'',
112112
function () use ($newDbName): void {
113113
self::assertTrue($this->isElementPresent('className', 'table_results'));
114-
self::assertEquals($newDbName, $this->getCellByTableClass('table_results', 1, 1));
114+
self::assertSame($newDbName, $this->getCellByTableClass('table_results', 1, 1));
115115
},
116116
);
117117

‎tests/end-to-end/Database/ProceduresTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function tearDown(): void
8484
{
8585
if ($this->originalSqlMode !== '') {
8686
$this->dbQuery("SET GLOBAL sql_mode = '" . $this->originalSqlMode . "';");
87-
self::assertEquals(
87+
self::assertSame(
8888
$this->originalSqlMode,
8989
$this->getSqlMode(),
9090
);
@@ -162,7 +162,7 @@ public function testAddProcedure(): void
162162
"SHOW PROCEDURE STATUS WHERE Db='" . $this->databaseName . "'",
163163
function (): void {
164164
self::assertTrue($this->isElementPresent('className', 'table_results'));
165-
self::assertEquals($this->databaseName, $this->getCellByTableClass('table_results', 1, 1));
165+
self::assertSame($this->databaseName, $this->getCellByTableClass('table_results', 1, 1));
166166
},
167167
);
168168

@@ -236,6 +236,6 @@ private function executeProcedure(string $text, int $length): void
236236
$this->waitUntilElementIsVisible('cssSelector', 'span#PMA_slidingMessage', 30);
237237
sleep(2);// Give more chances to the JS effect to finish
238238
$head = $this->byCssSelector('span#PMA_slidingMessage table tbody')->getText();
239-
self::assertEquals("outp\n" . $length, $head);
239+
self::assertSame("outp\n" . $length, $head);
240240
}
241241
}

‎tests/end-to-end/Database/StructureTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testTruncateTable(): void
5959
function (): void {
6060
self::assertTrue($this->isElementPresent('className', 'table_results'));
6161
// [ ] | Edit | Copy | Delete | 1 | 5
62-
self::assertEquals('Count: 0', $this->getCellByTableClass('table_results', 1, 1));
62+
self::assertSame('Count: 0', $this->getCellByTableClass('table_results', 1, 1));
6363
},
6464
);
6565
}

0 commit comments

Comments
 (0)