Skip to content

Commit

Permalink
PHPUnit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Mar 2, 2023
1 parent 4444a29 commit 6e55e68
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 95 deletions.
11 changes: 5 additions & 6 deletions ci/github/phpunit/mysqli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -28,11 +27,11 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">../../../lib/Doctrine</directory>
</whitelist>
</filter>
</include>
</coverage>

<groups>
<exclude>
Expand Down
12 changes: 5 additions & 7 deletions ci/github/phpunit/pdo_mysql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -28,12 +27,11 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">../../../lib/Doctrine</directory>
</whitelist>
</filter>

</include>
</coverage>

<groups>
<exclude>
Expand Down
11 changes: 5 additions & 6 deletions ci/github/phpunit/pdo_pgsql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -25,11 +24,11 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">../../../lib/Doctrine</directory>
</whitelist>
</filter>
</include>
</coverage>

<groups>
<exclude>
Expand Down
11 changes: 5 additions & 6 deletions ci/github/phpunit/pdo_sqlite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -23,11 +22,11 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">../../../lib/Doctrine</directory>
</whitelist>
</filter>
</include>
</coverage>

<groups>
<exclude>
Expand Down
11 changes: 5 additions & 6 deletions ci/github/phpunit/pgsql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -25,11 +24,11 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">../../../lib/Doctrine</directory>
</whitelist>
</filter>
</include>
</coverage>

<groups>
<exclude>
Expand Down
11 changes: 5 additions & 6 deletions ci/github/phpunit/sqlite3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
convertDeprecationsToExceptions="true"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="error_reporting" value="-1" />
Expand All @@ -23,11 +22,11 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">../../../lib/Doctrine</directory>
</whitelist>
</filter>
</include>
</coverage>

<groups>
<exclude>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"doctrine/coding-standard": "^11.0",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "1.10.3",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^10.0.14",
"psr/log": "^1 || ^2 || ^3",
"squizlabs/php_codesniffer": "3.7.2",
"symfony/cache": "^5.4 || ^6.0",
Expand Down
67 changes: 31 additions & 36 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
verbose="false"
failOnRisky="true"
convertDeprecationsToExceptions="true"
bootstrap="./tests/Doctrine/Tests/TestInit.php"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="Doctrine ORM Test Suite">
Expand All @@ -31,42 +30,38 @@
<group>locking_functional</group>
</exclude>
</groups>
<php>
<ini name="error_reporting" value="-1"/>
<!-- "Real" test database -->
<var name="db_driver" value="pdo_sqlite"/>
<var name="db_memory" value="true"/>
<!-- to use another database driver / credentials, provide them like so:
<var name="db_driver" value="pdo_mysql"/>
<var name="db_host" value="localhost" />
<var name="db_user" value="root" />
<var name="db_password" value="" />
<var name="db_dbname" value="doctrine_tests" />
<var name="db_port" value="3306"/>-->
<!--<var name="db_event_subscribers" value="Doctrine\DBAL\Event\Listeners\OracleSessionInit">-->
<!--
At the start of each test run, we will drop and recreate the test database.
<php>
<ini name="error_reporting" value="-1" />
<!-- "Real" test database -->
<var name="db_driver" value="pdo_sqlite"/>
<var name="db_memory" value="true"/>
<!-- to use another database driver / credentials, provide them like so:
<var name="db_driver" value="pdo_mysql"/>
<var name="db_host" value="localhost" />
<var name="db_user" value="root" />
<var name="db_password" value="" />
<var name="db_dbname" value="doctrine_tests" />
<var name="db_port" value="3306"/>-->
<!--<var name="db_event_subscribers" value="Doctrine\DBAL\Event\Listeners\OracleSessionInit">-->
By default we assume that the `db_` config above has unrestricted access to the provided database
platform.
<!--
At the start of each test run, we will drop and recreate the test database.
If you prefer, you can provide a restricted user above and a separate `privileged_db` config
block to provide details of a privileged connection to use for the setup / teardown actions.
By default we assume that the `db_` config above has unrestricted access to the provided database
platform.
If you prefer, you can provide a restricted user above and a separate `privileged_db` config
block to provide details of a privileged connection to use for the setup / teardown actions.
Note that these configurations are not merged - if you specify a `privileged_db_driver` then
you must also specify all the other options that your driver requires.
<var name="privileged_db_driver" value="pdo_mysql"/>
<var name="privileged_db_host" value="localhost" />
<var name="privileged_db_user" value="root" />
<var name="privileged_db_password" value="" />
<var name="privileged_db_dbname" value="doctrine_tests_tmp" />
<var name="privileged_db_port" value="3306"/>
-->

<env name="COLUMNS" value="120"/>
</php>
Note that these configurations are not merged - if you specify a `privileged_db_driver` then
you must also specify all the other options that your driver requires.
<var name="privileged_db_driver" value="pdo_mysql"/>
<var name="privileged_db_host" value="localhost" />
<var name="privileged_db_user" value="root" />
<var name="privileged_db_password" value="" />
<var name="privileged_db_dbname" value="doctrine_tests_tmp" />
<var name="privileged_db_port" value="3306"/>
-->
<env name="COLUMNS" value="120"/>
</php>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Doctrine\Tests\OrmTestCase;
use ReflectionMethod;

use function array_slice;

class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase
{
protected BasicEntityPersister $persister;
Expand Down Expand Up @@ -190,21 +192,28 @@ public function testDeleteManyToManyUsesTypeValuesSQL(): void
$entityManager->getUnitOfWork()->registerManaged($parent, ['id' => 1], []);
$entityManager->getUnitOfWork()->registerManaged($friend, ['id' => 2], []);

$connection->expects($this->atLeast(2))
->method('delete')
->withConsecutive(
[
'customtype_parent_friends',
['friend_customtypeparent_id' => 1],
['integer'],
],
[
'customtype_parent_friends',
['customtypeparent_id' => 1],
['integer'],
],
);
$deleteCalls = [];

$connection->method('delete')
->willReturnCallback(static function (...$args) use (&$deleteCalls): int {
$deleteCalls[] = $args;

return 1;
});

$persister->delete($parent);

self::assertSame([
[
'customtype_parent_friends',
['friend_customtypeparent_id' => 1],
['integer'],
],
[
'customtype_parent_friends',
['customtypeparent_id' => 1],
['integer'],
],
], array_slice($deleteCalls, 0, 2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public function testItPrintsTheSql(): void
/** @dataProvider getCasesForWarningMessageFromCompleteOption */
public function testWarningMessageFromCompleteOption(string|null $name, string $expectedMessage): void
{
if (! method_exists(SchemaDiff::class, 'toSaveSql')) {
self::markTestSkipped('This test requires DBAL 3');
}

$tester = $this->getCommandTester(UpdateCommand::class, $name);
$tester->execute(
[],
Expand All @@ -41,10 +45,6 @@ public function testWarningMessageFromCompleteOption(string|null $name, string $

public static function getCasesForWarningMessageFromCompleteOption(): iterable
{
if (! method_exists(SchemaDiff::class, 'toSaveSql')) {
self::markTestSkipped('This test requires DBAL 3');
}

yield 'default_name' => [
null,
'[WARNING] Not passing the "--complete" option to "orm:schema-tool:update" is deprecated',
Expand Down
5 changes: 2 additions & 3 deletions tests/Doctrine/Tests/OrmFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@
use Exception;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Constraint\Count;
use PHPUnit\Framework\Warning;
use Psr\Cache\CacheItemPoolInterface;
use RuntimeException;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
Expand Down Expand Up @@ -980,9 +979,9 @@ final protected function createSchemaManager(): AbstractSchemaManager
}

/** @throws Throwable */
protected function onNotSuccessfulTest(Throwable $e): void
protected function onNotSuccessfulTest(Throwable $e): never
{
if ($e instanceof AssertionFailedError || $e instanceof Warning) {
if ($e instanceof AssertionFailedError) {
throw $e;
}

Expand Down

0 comments on commit 6e55e68

Please sign in to comment.