Skip to content

Commit 1883d63

Browse files
authored
Merge pull request #560 from greg0ire/prepare-phpunit-upgrade
Prepare phpunit upgrade
2 parents f795ec2 + 5bb8c81 commit 1883d63

File tree

8 files changed

+33
-28
lines changed

8 files changed

+33
-28
lines changed

phpunit.xml.dist

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
colors="true"
55
beStrictAboutOutputDuringTests="true"
6-
beStrictAboutTodoAnnotatedTests="true"
7-
bootstrap="vendor/autoload.php"
6+
displayDetailsOnTestsThatTriggerDeprecations="true"
7+
failOnDeprecation="true"
88
>
99
<testsuites>
1010
<testsuite name="Doctrine Data Fixtures Test Suite">
1111
<directory>./tests</directory>
1212
</testsuite>
1313
</testsuites>
1414

15-
<coverage>
15+
<php>
16+
<env name="DOCTRINE_DEPRECATIONS" value="trigger"/>
17+
</php>
18+
19+
<source ignoreSuppressionOfDeprecations="true">
1620
<include>
1721
<directory>./src</directory>
1822
</include>
19-
</coverage>
23+
</source>
2024
</phpunit>

tests/Common/DataFixtures/BaseTestCase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
use function method_exists;
1313

14-
/**
15-
* Base test class
16-
*/
1714
abstract class BaseTestCase extends TestCase
1815
{
1916
/**

tests/Common/DataFixtures/Executor/ORMExecutorSharedFixtureTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Doctrine\ORM\Tools\SchemaTool;
1111
use Doctrine\Tests\Common\DataFixtures\TestEntity\Role;
1212
use Doctrine\Tests\Common\DataFixtures\TestEntity\User;
13+
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
1314
use PHPUnit\Framework\MockObject\MockObject;
1415

1516
/**
@@ -20,6 +21,7 @@ class ORMExecutorSharedFixtureTest extends BaseTestCase
2021
public const TEST_ENTITY_ROLE = Role::class;
2122
public const TEST_ENTITY_USER = User::class;
2223

24+
#[IgnoreDeprecations]
2325
public function testFixtureExecution(): void
2426
{
2527
$em = $this->getMockSqliteEntityManager();
@@ -39,6 +41,7 @@ public function testFixtureExecution(): void
3941
$executor->execute([$fixture], true);
4042
}
4143

44+
#[IgnoreDeprecations]
4245
public function testSharedFixtures(): void
4346
{
4447
$em = $this->getMockSqliteEntityManager();

tests/Common/DataFixtures/Executor/PHPCRExecutorTest.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
use Doctrine\ODM\PHPCR\DocumentManager;
1111
use Doctrine\Tests\Common\DataFixtures\BaseTestCase;
1212
use Exception;
13+
use PHPUnit\Framework\Attributes\CoversClass;
1314
use PHPUnit\Framework\MockObject\MockObject;
1415
use Throwable;
1516

1617
use function class_exists;
1718

18-
/**
19-
* Tests for {@see \Doctrine\Common\DataFixtures\Executor\PHPCRExecutor}
20-
*
21-
* @covers \Doctrine\Common\DataFixtures\Executor\PHPCRExecutor
22-
*/
19+
#[CoversClass(PHPCRExecutor::class)]
2320
class PHPCRExecutorTest extends BaseTestCase
2421
{
2522
public function testExecuteSingleFixtureWithNoPurge(): void
@@ -33,9 +30,9 @@ public function testExecuteSingleFixtureWithNoPurge(): void
3330
->expects($this->once())
3431
->method('transactional')
3532
->with($this->isType('callable'))
36-
->will($this->returnCallback(static function ($callback) use ($dm) {
33+
->willReturnCallback(static function ($callback) use ($dm) {
3734
return $callback($dm);
38-
}));
35+
});
3936

4037
$executor->execute([$fixture], true);
4138
}
@@ -53,9 +50,9 @@ public function testExecuteMultipleFixturesWithNoPurge(): void
5350
->expects($this->once())
5451
->method('transactional')
5552
->with($this->isType('callable'))
56-
->will($this->returnCallback(static function ($callback) use ($dm) {
53+
->willReturnCallback(static function ($callback) use ($dm) {
5754
return $callback($dm);
58-
}));
55+
});
5956

6057
$executor->execute([$fixture1, $fixture2], true);
6158
}
@@ -72,9 +69,9 @@ public function testExecuteFixtureWithPurge(): void
7269
->expects($this->once())
7370
->method('transactional')
7471
->with($this->isType('callable'))
75-
->will($this->returnCallback(static function ($callback) use ($dm) {
72+
->willReturnCallback(static function ($callback) use ($dm) {
7673
return $callback($dm);
77-
}));
74+
});
7875
$purger->expects($this->once())->method('purge');
7976

8077
$executor->execute([$fixture], false);
@@ -92,9 +89,9 @@ public function testExecuteFixtureWithoutPurge(): void
9289
->expects($this->once())
9390
->method('transactional')
9491
->with($this->isType('callable'))
95-
->will($this->returnCallback(static function ($callback) use ($dm) {
92+
->willReturnCallback(static function ($callback) use ($dm) {
9693
return $callback($dm);
97-
}));
94+
});
9895
$purger->expects($this->never())->method('purge');
9996

10097
$executor->execute([$fixture], true);

tests/Common/DataFixtures/ProxyReferenceRepositoryTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
use Doctrine\Tests\Common\DataFixtures\TestEntity\Role;
1414
use Doctrine\Tests\Common\DataFixtures\TestTypes\UuidType;
1515
use Doctrine\Tests\Common\DataFixtures\TestValueObjects\Uuid;
16+
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
1617

17-
/**
18-
* Test ProxyReferenceRepository.
19-
*/
2018
class ProxyReferenceRepositoryTest extends BaseTestCase
2119
{
2220
public const TEST_ENTITY_ROLE = Role::class;
@@ -33,12 +31,15 @@ public static function setUpBeforeClass(): void
3331
Type::addType('uuid', UuidType::class);
3432
}
3533

34+
#[IgnoreDeprecations]
3635
public function testReferenceEntry(): void
3736
{
3837
$em = $this->getMockSqliteEntityManager();
3938
$role = new TestEntity\Role();
4039
$role->setName('admin');
4140
$meta = $em->getClassMetadata(self::TEST_ENTITY_ROLE);
41+
42+
// getPropertyAccessor() is not available with Doctrine < 3.4
4243
$meta->getReflectionProperty('id')->setValue($role, 1);
4344

4445
$referenceRepo = new ProxyReferenceRepository($em);
@@ -72,7 +73,7 @@ public function testReferenceIdentityPopulation(): void
7273

7374
$referenceRepository->expects($this->once())
7475
->method('getReferenceNames')
75-
->will($this->returnValue(['admin-role']));
76+
->willReturn(['admin-role']);
7677

7778
$referenceRepository->expects($this->once())
7879
->method('setReferenceIdentity')
@@ -131,6 +132,7 @@ public function testReferenceReconstruction(): void
131132
$this->assertInstanceOf(Proxy::class, $ref);
132133
}
133134

135+
#[IgnoreDeprecations]
134136
public function testReconstructionOfCustomTypedId(): void
135137
{
136138
$em = $this->getMockSqliteEntityManager();

tests/Common/DataFixtures/ReferenceRepositoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\Tests\Common\DataFixtures\TestEntity\User;
1616
use Doctrine\Tests\Mock\ForwardCompatibleEntityManager;
1717
use OutOfBoundsException;
18+
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
1819

1920
use function sprintf;
2021

@@ -131,7 +132,7 @@ public function testUndefinedReference(): void
131132
$referenceRepository->getReference('foo', Role::class);
132133
}
133134

134-
/** @group legacy */
135+
#[IgnoreDeprecations]
135136
public function testLegacyUndefinedReference(): void
136137
{
137138
$referenceRepository = new ReferenceRepository($this->getMockSqliteEntityManager());

tests/Common/DataFixtures/Sorter/TopologicalSorterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\Common\DataFixtures\Sorter\TopologicalSorter;
99
use Doctrine\ORM\Mapping\ClassMetadata;
1010
use Doctrine\Tests\Common\DataFixtures\BaseTestCase;
11+
use PHPUnit\Framework\Attributes\CoversClass;
1112
use RuntimeException;
1213

1314
/**
@@ -16,9 +17,8 @@
1617
* Note: When writing tests here consider that a lot of graph
1718
* constellations can have many valid orderings, so you may want to
1819
* build a graph that has only 1 valid order to simplify your tests
19-
*
20-
* @covers \Doctrine\Common\DataFixtures\Sorter\TopologicalSorter
2120
*/
21+
#[CoversClass(TopologicalSorter::class)]
2222
class TopologicalSorterTest extends BaseTestCase
2323
{
2424
public function testSuccessSortLinearDependency(): void

tests/Common/DataFixtures/Sorter/VertexTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
use Doctrine\Common\DataFixtures\Sorter\Vertex;
88
use Doctrine\ORM\Mapping\ClassMetadata;
99
use Doctrine\Tests\Common\DataFixtures\BaseTestCase;
10+
use PHPUnit\Framework\Attributes\CoversClass;
1011

11-
/** @covers \Doctrine\Common\DataFixtures\Sorter\Vertex */
12+
#[CoversClass(Vertex::class)]
1213
class VertexTest extends BaseTestCase
1314
{
1415
public function testNode(): void

0 commit comments

Comments
 (0)