Skip to content

Commit d2aed19

Browse files
authored
PHPUnit 10.5.9 (#6266)
This PR upgrades PHPUnit to 10.5.9. ~~Apparently, the build is broken by a couple of warnings that PHPUnit collected. I've pushed a commit that makes them visible. We should investigate those warnings.~~ Warnings have been addressed.
1 parent d98a279 commit d2aed19

File tree

6 files changed

+75
-37
lines changed

6 files changed

+75
-37
lines changed

ci/github/phpunit/oci8-21.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
beStrictAboutTodoAnnotatedTests="true"
77
failOnRisky="true"
88
failOnWarning="true"
9-
convertDeprecationsToExceptions="true"
109
>
1110
<php>
1211
<ini name="error_reporting" value="-1" />
@@ -31,9 +30,9 @@
3130
</testsuite>
3231
</testsuites>
3332

34-
<coverage>
33+
<source>
3534
<include>
36-
<directory suffix=".php">../../../src</directory>
35+
<directory>../../../src</directory>
3736
</include>
38-
</coverage>
37+
</source>
3938
</phpunit>

ci/github/phpunit/pdo_oci-21.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
beStrictAboutTodoAnnotatedTests="true"
77
failOnRisky="true"
88
failOnWarning="true"
9-
convertDeprecationsToExceptions="true"
109
>
1110
<php>
1211
<ini name="error_reporting" value="-1" />
@@ -31,9 +30,9 @@
3130
</testsuite>
3231
</testsuites>
3332

34-
<coverage>
33+
<source>
3534
<include>
36-
<directory suffix=".php">../../../src</directory>
35+
<directory>../../../src</directory>
3736
</include>
38-
</coverage>
37+
</source>
3938
</phpunit>

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"phpstan/phpstan": "1.10.56",
4444
"phpstan/phpstan-phpunit": "1.3.15",
4545
"phpstan/phpstan-strict-rules": "^1.5",
46-
"phpunit/phpunit": "10.4.2",
46+
"phpunit/phpunit": "10.5.9",
4747
"psalm/plugin-phpunit": "0.18.4",
4848
"slevomat/coding-standard": "8.13.1",
4949
"squizlabs/php_codesniffer": "3.8.1",

tests/Functional/Driver/OCI8/ResultTest.php

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
use Doctrine\DBAL\Tests\TestUtil;
1010
use Generator;
1111

12+
use function func_get_args;
1213
use function ini_get;
14+
use function restore_error_handler;
15+
use function set_error_handler;
1316
use function sprintf;
14-
15-
use const E_ALL;
16-
use const E_WARNING;
17+
use function str_contains;
1718

1819
/** @requires extension oci8 */
1920
class ResultTest extends FunctionalTestCase
@@ -56,9 +57,6 @@ public function testTruncatedFetch(
5657
bool $invalidateDataMidFetch,
5758
): void {
5859
if ($invalidateDataMidFetch) {
59-
// prevent the PHPUnit error handler from handling the warnings that oci_*() functions may trigger
60-
$this->iniSet('error_reporting', (string) (E_ALL & ~E_WARNING));
61-
6260
$this->expectException(DriverException::class);
6361
$this->expectExceptionCode(4068);
6462
}
@@ -88,22 +86,37 @@ public function testTruncatedFetch(
8886
// Invalidate the original dataset by changing the pipelined function
8987
// after the initial prefetch that caches locally the first X results
9088
$this->createOrReplacePipelinedFunction($expectedTotalRowCount + 10);
89+
90+
$previous = null;
91+
$previous = set_error_handler(static function (int $errno, string $errstr) use (&$previous): bool {
92+
if (str_contains($errstr, 'ORA-04061')) {
93+
return true;
94+
}
95+
96+
return $previous !== null && $previous(...func_get_args());
97+
});
9198
}
9299

93-
while ($result->fetchOne()) {
94-
// Attempt to access all remaining rows from the original fetch
95-
// The rows locally cached from the default prefetch will first be used
96-
// but when the result attempts to get the remaining 10 rows beyond
97-
// the first prefetch, nothing will be returned
98-
//
99-
// PHP oci8 oci_fetch_array will issue a PHP E_WARNING when the 2nd prefetch occurs
100-
// oci_fetch_array(): ORA-04068: existing state of packages has been discarded
101-
// ORA-04061: existing state of function "ROOT.TEST_ORACLE_FETCH_FAILURE" has been invalidated
102-
// ORA-04065: not executed, altered or dropped function "ROOT.TEST_ORACLE_FETCH_FAILURE"
103-
//
104-
// If there was no issue, this should have returned rows totalling 10
105-
// higher than the oci8 default prefetch
106-
continue;
100+
try {
101+
while ($result->fetchOne()) {
102+
// Attempt to access all remaining rows from the original fetch
103+
// The rows locally cached from the default prefetch will first be used
104+
// but when the result attempts to get the remaining 10 rows beyond
105+
// the first prefetch, nothing will be returned
106+
//
107+
// PHP oci8 oci_fetch_array will issue a PHP E_WARNING when the 2nd prefetch occurs
108+
// oci_fetch_array(): ORA-04068: existing state of packages has been discarded
109+
// ORA-04061: existing state of function "ROOT.TEST_ORACLE_FETCH_FAILURE" has been invalidated
110+
// ORA-04065: not executed, altered or dropped function "ROOT.TEST_ORACLE_FETCH_FAILURE"
111+
//
112+
// If there was no issue, this should have returned rows totalling 10
113+
// higher than the oci8 default prefetch
114+
continue;
115+
}
116+
} finally {
117+
if ($invalidateDataMidFetch) {
118+
restore_error_handler();
119+
}
107120
}
108121

109122
self::assertEquals(

tests/Functional/ExceptionTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
use function exec;
1919
use function extension_loaded;
2020
use function file_exists;
21+
use function func_get_args;
2122
use function posix_geteuid;
23+
use function restore_error_handler;
24+
use function set_error_handler;
2225
use function sprintf;
2326
use function sys_get_temp_dir;
2427
use function touch;
2528
use function unlink;
2629

27-
use const E_ALL;
2830
use const E_WARNING;
2931
use const PHP_OS_FAMILY;
3032

@@ -82,11 +84,23 @@ public function testInvalidFieldNameException(): void
8284
$table->addColumn('id', Types::INTEGER, []);
8385
$this->dropAndCreateTable($table);
8486

87+
$this->expectException(Exception\InvalidFieldNameException::class);
88+
8589
// prevent the PHPUnit error handler from handling the warning that db2_bind_param() may trigger
86-
$this->iniSet('error_reporting', (string) (E_ALL & ~E_WARNING));
90+
$previous = null;
91+
$previous = set_error_handler(static function (int $errno) use (&$previous): bool {
92+
if (($errno & ~E_WARNING) === 0) {
93+
return true;
94+
}
8795

88-
$this->expectException(Exception\InvalidFieldNameException::class);
89-
$this->connection->insert('bad_columnname_table', ['name' => 5]);
96+
return $previous !== null && $previous(...func_get_args());
97+
});
98+
99+
try {
100+
$this->connection->insert('bad_columnname_table', ['name' => 5]);
101+
} finally {
102+
restore_error_handler();
103+
}
90104
}
91105

92106
public function testNonUniqueFieldNameException(): void

tests/Functional/TransactionTest.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
1111
use Doctrine\DBAL\Tests\FunctionalTestCase;
1212

13+
use function func_get_args;
14+
use function restore_error_handler;
15+
use function set_error_handler;
1316
use function sleep;
1417

15-
use const E_ALL;
1618
use const E_WARNING;
1719
use const PHP_VERSION_ID;
1820

@@ -53,10 +55,21 @@ private function expectConnectionLoss(callable $scenario): void
5355
// during the sleep MySQL will close the connection
5456
sleep(2);
5557

58+
$this->expectException(ConnectionLost::class);
59+
5660
// prevent the PHPUnit error handler from handling the "MySQL server has gone away" warning
57-
$this->iniSet('error_reporting', (string) (E_ALL & ~E_WARNING));
61+
$previous = null;
62+
$previous = set_error_handler(static function (int $errno) use (&$previous): bool {
63+
if (($errno & ~E_WARNING) === 0) {
64+
return true;
65+
}
5866

59-
$this->expectException(ConnectionLost::class);
60-
$scenario($this->connection);
67+
return $previous !== null && $previous(...func_get_args());
68+
});
69+
try {
70+
$scenario($this->connection);
71+
} finally {
72+
restore_error_handler();
73+
}
6174
}
6275
}

0 commit comments

Comments
 (0)