Allow PHPUnit 12

It will make it easier to address deprecations because it comes with an
argument for --stop-on-deprecations that allows to show the stack trace.
This commit is contained in:
Grégoire Paris
2025-10-12 17:13:08 +02:00
parent 92f09c013b
commit 22cfffb0c4
8 changed files with 26 additions and 20 deletions

View File

@@ -33,7 +33,7 @@
"doctrine/orm": "^2.14 || ^3",
"fig/log-test": "^1",
"phpstan/phpstan": "2.1.30",
"phpunit/phpunit": "^9.6.13 || 10.5.45",
"phpunit/phpunit": "^9.6.13 || ^12.4",
"psr/log": "^1.1 || ^2 || ^3",
"symfony/cache": "^5.4 || ^6.3 || ^7",
"symfony/var-exporter": "^5.4 || ^6.3 || ^7"

View File

@@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Doctrine Data Fixtures Test Suite">

View File

@@ -10,6 +10,7 @@ use Doctrine\Common\DataFixtures\SharedFixtureInterface;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\Common\DataFixtures\TestEntity\Role;
use Doctrine\Tests\Common\DataFixtures\TestEntity\User;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\MockObject\MockObject;
/**
@@ -20,6 +21,7 @@ class ORMExecutorSharedFixtureTest extends BaseTestCase
public const TEST_ENTITY_ROLE = Role::class;
public const TEST_ENTITY_USER = User::class;
#[IgnoreDeprecations]
public function testFixtureExecution(): void
{
$em = $this->getMockSqliteEntityManager();
@@ -39,6 +41,7 @@ class ORMExecutorSharedFixtureTest extends BaseTestCase
$executor->execute([$fixture], true);
}
#[IgnoreDeprecations]
public function testSharedFixtures(): void
{
$em = $this->getMockSqliteEntityManager();

View File

@@ -11,16 +11,13 @@ use Doctrine\ODM\PHPCR\DocumentManager;
use Doctrine\Tests\Common\DataFixtures\BaseTestCase;
use Doctrine\Tests\Mock\PHPCRDocumentManager;
use Exception;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use Throwable;
use function class_exists;
/**
* Tests for {@see \Doctrine\Common\DataFixtures\Executor\PHPCRExecutor}
*
* @covers \Doctrine\Common\DataFixtures\Executor\PHPCRExecutor
*/
#[CoversClass(PHPCRExecutor::class)]
class PHPCRExecutorTest extends BaseTestCase
{
public function testExecuteSingleFixtureWithNoPurge(): void
@@ -34,9 +31,9 @@ class PHPCRExecutorTest extends BaseTestCase
->expects($this->once())
->method('transactional')
->with($this->isType('callable'))
->will($this->returnCallback(static function ($callback) use ($dm) {
->willReturnCallback(static function ($callback) use ($dm) {
return $callback($dm);
}));
});
$executor->execute([$fixture], true);
}
@@ -54,9 +51,9 @@ class PHPCRExecutorTest extends BaseTestCase
->expects($this->once())
->method('transactional')
->with($this->isType('callable'))
->will($this->returnCallback(static function ($callback) use ($dm) {
->willReturnCallback(static function ($callback) use ($dm) {
return $callback($dm);
}));
});
$executor->execute([$fixture1, $fixture2], true);
}
@@ -73,9 +70,9 @@ class PHPCRExecutorTest extends BaseTestCase
->expects($this->once())
->method('transactional')
->with($this->isType('callable'))
->will($this->returnCallback(static function ($callback) use ($dm) {
->willReturnCallback(static function ($callback) use ($dm) {
return $callback($dm);
}));
});
$purger->expects($this->once())->method('purge');
$executor->execute([$fixture], false);
@@ -93,9 +90,9 @@ class PHPCRExecutorTest extends BaseTestCase
->expects($this->once())
->method('transactional')
->with($this->isType('callable'))
->will($this->returnCallback(static function ($callback) use ($dm) {
->willReturnCallback(static function ($callback) use ($dm) {
return $callback($dm);
}));
});
$purger->expects($this->never())->method('purge');
$executor->execute([$fixture], true);

View File

@@ -13,6 +13,7 @@ use Doctrine\Tests\Common\DataFixtures\TestEntity\Link;
use Doctrine\Tests\Common\DataFixtures\TestEntity\Role;
use Doctrine\Tests\Common\DataFixtures\TestTypes\UuidType;
use Doctrine\Tests\Common\DataFixtures\TestValueObjects\Uuid;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
/**
* Test ProxyReferenceRepository.
@@ -33,12 +34,15 @@ class ProxyReferenceRepositoryTest extends BaseTestCase
Type::addType('uuid', UuidType::class);
}
#[IgnoreDeprecations]
public function testReferenceEntry(): void
{
$em = $this->getMockSqliteEntityManager();
$role = new TestEntity\Role();
$role->setName('admin');
$meta = $em->getClassMetadata(self::TEST_ENTITY_ROLE);
// getPropertyAccessor() is not available with ORM < 3.4
$meta->getReflectionProperty('id')->setValue($role, 1);
$referenceRepo = new ProxyReferenceRepository($em);
@@ -91,7 +95,7 @@ class ProxyReferenceRepositoryTest extends BaseTestCase
$referenceRepository->expects($this->once())
->method('getReferenceNames')
->will($this->returnValue(['admin-role']));
->willReturn(['admin-role']);
$referenceRepository->expects($this->once())
->method('setReferenceIdentity')
@@ -150,6 +154,7 @@ class ProxyReferenceRepositoryTest extends BaseTestCase
$this->assertInstanceOf(Proxy::class, $ref);
}
#[IgnoreDeprecations]
public function testReconstructionOfCustomTypedId(): void
{
$em = $this->getMockSqliteEntityManager();

View File

@@ -14,6 +14,7 @@ use Doctrine\Persistence\Proxy;
use Doctrine\Tests\Common\DataFixtures\TestEntity\Role;
use Doctrine\Tests\Mock\ForwardCompatibleEntityManager;
use OutOfBoundsException;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use function sprintf;
@@ -152,7 +153,7 @@ class ReferenceRepositoryTest extends BaseTestCase
$referenceRepository->getReference('foo', Role::class);
}
/** @group legacy */
#[IgnoreDeprecations]
public function testLegacyUndefinedReference(): void
{
$referenceRepository = new ReferenceRepository($this->getMockSqliteEntityManager());

View File

@@ -8,6 +8,7 @@ use Doctrine\Common\DataFixtures\Exception\CircularReferenceException;
use Doctrine\Common\DataFixtures\Sorter\TopologicalSorter;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Tests\Common\DataFixtures\BaseTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use RuntimeException;
/**
@@ -16,9 +17,8 @@ use RuntimeException;
* Note: When writing tests here consider that a lot of graph
* constellations can have many valid orderings, so you may want to
* build a graph that has only 1 valid order to simplify your tests
*
* @covers \Doctrine\Common\DataFixtures\Sorter\TopologicalSorter
*/
#[CoversClass(TopologicalSorter::class)]
class TopologicalSorterTest extends BaseTestCase
{
public function testSuccessSortLinearDependency(): void

View File

@@ -7,8 +7,9 @@ namespace Doctrine\Test\DataFixtures\Sorter;
use Doctrine\Common\DataFixtures\Sorter\Vertex;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Tests\Common\DataFixtures\BaseTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
/** @covers \Doctrine\Common\DataFixtures\Sorter\Vertex */
#[CoversClass(Vertex::class)]
class VertexTest extends BaseTestCase
{
public function testNode(): void