Skip to content

Commit

Permalink
Upgrade to PHPUnit 11 (#575)
Browse files Browse the repository at this point in the history
* Remove unneeded trait

* Upgrade to PHPUnit 11

The use of listeners is no longer possible, but we can replace the
deprecation detection functionality with native PHPUnit features.
  • Loading branch information
greg0ire authored Jan 12, 2025
1 parent d90e9f0 commit c223806
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"require-dev": {
"composer/semver": "^3.0",
"phpunit/phpunit": "^9.6.22",
"phpunit/phpunit": "^10.5.40 || ^11.5",
"doctrine/coding-standard": "^12",
"phpstan/phpstan": "^2",
"phpstan/phpstan-deprecation-rules": "^2",
Expand All @@ -37,8 +37,6 @@
"phpstan/phpstan-symfony": "^2",
"doctrine/orm": "^2.6 || ^3",
"doctrine/persistence": "^2.0 || ^3 ",
"symfony/console": "^6.4.17 || ^7.0",
"symfony/phpunit-bridge": "^7",
"symfony/var-exporter": "^6 || ^7"
},
"autoload": {
Expand Down
22 changes: 14 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true" bootstrap="vendor/autoload.php">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
displayDetailsOnTestsThatTriggerDeprecations="true"
>
<testsuites>
<testsuite name="DoctrineMigrationsBundle for the Symfony Framework">
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<source ignoreSuppressionOfDeprecations="true">
<include>
<directory>src</directory>
</whitelist>
</filter>
</include>
</source>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
<php>
<server name="DOCTRINE_DEPRECATIONS" value="trigger"/>
</php>
</phpunit>
10 changes: 4 additions & 6 deletions tests/DependencyInjection/DoctrineCommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Doctrine\Migrations\Tools\Console\Command\SyncMetadataCommand;
use Doctrine\Migrations\Tools\Console\Command\UpToDateCommand;
use Doctrine\Migrations\Tools\Console\Command\VersionCommand;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
Expand All @@ -34,11 +35,8 @@

class DoctrineCommandsTest extends TestCase
{
/**
* @param class-string<DoctrineCommand> $instance
*
* @dataProvider getCommands
*/
/** @param class-string<DoctrineCommand> $instance */
#[DataProvider('getCommands')]
public function testCommandRegistered(string $name, string $instance): void
{
$command = $this->getApplication()->find($name);
Expand All @@ -53,7 +51,7 @@ public function testCommandRegistered(string $name, string $instance): void
* @return string[][]
* @phpstan-return list<array{string, class-string<DoctrineCommand>}>
*/
public function getCommands(): array
public static function getCommands(): array
{
return [
['doctrine:migrations:diff', DiffCommand::class],
Expand Down
3 changes: 0 additions & 3 deletions tests/DependencyInjection/DoctrineMigrationsExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Alias;
Expand All @@ -40,8 +39,6 @@

class DoctrineMigrationsExtensionTest extends TestCase
{
use ExpectDeprecationTrait;

public function testXmlConfigs(): void
{
$container = $this->getContainerBuilder();
Expand Down

0 comments on commit c223806

Please sign in to comment.