Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit 10.5.9 #6266

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ci/github/phpunit/oci8-21.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
convertDeprecationsToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -31,9 +30,9 @@
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory suffix=".php">../../../src</directory>
<directory>../../../src</directory>
</include>
</coverage>
</source>
</phpunit>
7 changes: 3 additions & 4 deletions ci/github/phpunit/pdo_oci-21.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
convertDeprecationsToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -31,9 +30,9 @@
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory suffix=".php">../../../src</directory>
<directory>../../../src</directory>
</include>
</coverage>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"phpstan/phpstan": "1.10.56",
"phpstan/phpstan-phpunit": "1.3.15",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "10.4.2",
"phpunit/phpunit": "10.5.9",
"psalm/plugin-phpunit": "0.18.4",
"slevomat/coding-standard": "8.13.1",
"squizlabs/php_codesniffer": "3.8.1",
Expand Down
53 changes: 33 additions & 20 deletions tests/Functional/Driver/OCI8/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
use Doctrine\DBAL\Tests\TestUtil;
use Generator;

use function func_get_args;
use function ini_get;
use function restore_error_handler;
use function set_error_handler;
use function sprintf;

use const E_ALL;
use const E_WARNING;
use function str_contains;

/** @requires extension oci8 */
class ResultTest extends FunctionalTestCase
Expand Down Expand Up @@ -56,9 +57,6 @@ public function testTruncatedFetch(
bool $invalidateDataMidFetch,
): void {
if ($invalidateDataMidFetch) {
// prevent the PHPUnit error handler from handling the warnings that oci_*() functions may trigger
$this->iniSet('error_reporting', (string) (E_ALL & ~E_WARNING));

$this->expectException(DriverException::class);
$this->expectExceptionCode(4068);
}
Expand Down Expand Up @@ -88,22 +86,37 @@ public function testTruncatedFetch(
// Invalidate the original dataset by changing the pipelined function
// after the initial prefetch that caches locally the first X results
$this->createOrReplacePipelinedFunction($expectedTotalRowCount + 10);

$previous = null;
$previous = set_error_handler(static function (int $errno, string $errstr) use (&$previous): bool {
if (str_contains($errstr, 'ORA-04061')) {
return true;
}

return $previous !== null && $previous(...func_get_args());
});
}

while ($result->fetchOne()) {
// Attempt to access all remaining rows from the original fetch
// The rows locally cached from the default prefetch will first be used
// but when the result attempts to get the remaining 10 rows beyond
// the first prefetch, nothing will be returned
//
// PHP oci8 oci_fetch_array will issue a PHP E_WARNING when the 2nd prefetch occurs
// oci_fetch_array(): ORA-04068: existing state of packages has been discarded
// ORA-04061: existing state of function "ROOT.TEST_ORACLE_FETCH_FAILURE" has been invalidated
// ORA-04065: not executed, altered or dropped function "ROOT.TEST_ORACLE_FETCH_FAILURE"
//
// If there was no issue, this should have returned rows totalling 10
// higher than the oci8 default prefetch
continue;
try {
while ($result->fetchOne()) {
// Attempt to access all remaining rows from the original fetch
// The rows locally cached from the default prefetch will first be used
// but when the result attempts to get the remaining 10 rows beyond
// the first prefetch, nothing will be returned
//
// PHP oci8 oci_fetch_array will issue a PHP E_WARNING when the 2nd prefetch occurs
// oci_fetch_array(): ORA-04068: existing state of packages has been discarded
// ORA-04061: existing state of function "ROOT.TEST_ORACLE_FETCH_FAILURE" has been invalidated
// ORA-04065: not executed, altered or dropped function "ROOT.TEST_ORACLE_FETCH_FAILURE"
//
// If there was no issue, this should have returned rows totalling 10
// higher than the oci8 default prefetch
continue;
}
} finally {
if ($invalidateDataMidFetch) {
restore_error_handler();
}
}

self::assertEquals(
Expand Down
22 changes: 18 additions & 4 deletions tests/Functional/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
use function exec;
use function extension_loaded;
use function file_exists;
use function func_get_args;
use function posix_geteuid;
use function restore_error_handler;
use function set_error_handler;
use function sprintf;
use function sys_get_temp_dir;
use function touch;
use function unlink;

use const E_ALL;
use const E_WARNING;
use const PHP_OS_FAMILY;

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

$this->expectException(Exception\InvalidFieldNameException::class);

// prevent the PHPUnit error handler from handling the warning that db2_bind_param() may trigger
$this->iniSet('error_reporting', (string) (E_ALL & ~E_WARNING));
$previous = null;
$previous = set_error_handler(static function (int $errno) use (&$previous): bool {
if (($errno & ~E_WARNING) === 0) {
return true;
}

$this->expectException(Exception\InvalidFieldNameException::class);
$this->connection->insert('bad_columnname_table', ['name' => 5]);
return $previous !== null && $previous(...func_get_args());
});

try {
$this->connection->insert('bad_columnname_table', ['name' => 5]);
} finally {
restore_error_handler();
}
}

public function testNonUniqueFieldNameException(): void
Expand Down
21 changes: 17 additions & 4 deletions tests/Functional/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Tests\FunctionalTestCase;

use function func_get_args;
use function restore_error_handler;
use function set_error_handler;
use function sleep;

use const E_ALL;
use const E_WARNING;
use const PHP_VERSION_ID;

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

$this->expectException(ConnectionLost::class);

// prevent the PHPUnit error handler from handling the "MySQL server has gone away" warning
$this->iniSet('error_reporting', (string) (E_ALL & ~E_WARNING));
$previous = null;
$previous = set_error_handler(static function (int $errno) use (&$previous): bool {
if (($errno & ~E_WARNING) === 0) {
return true;
}

$this->expectException(ConnectionLost::class);
$scenario($this->connection);
return $previous !== null && $previous(...func_get_args());
});
try {
$scenario($this->connection);
} finally {
restore_error_handler();
}
}
}
Loading