Skip to content

Commit 23caef2

Browse files
committed
Upgrade to PHPUnit 11 for PHP >= 8.2 and check deprecation messages
1 parent 5acb54f commit 23caef2

File tree

8 files changed

+17
-9
lines changed

8 files changed

+17
-9
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ jobs:
190190
topology: ${{ matrix.topology }}
191191

192192
- name: "Run PHPUnit"
193-
run: "vendor/bin/phpunit --exclude-group=atlas ${{ matrix.dependencies == 'lowest' && '--do-not-fail-on-deprecation --do-not-fail-on-warning --do-not-fail-on-notice' || '' }}"
193+
run: |
194+
vendor/bin/phpunit --exclude-group=atlas \
195+
${{ matrix.dependencies == 'lowest' && '--do-not-fail-on-deprecation --do-not-fail-on-warning --do-not-fail-on-notice' || '' }} \
196+
${{ matrix.proxy == 'native' && matrix.dependencies != 'lowest' && '--do-not-fail-on-deprecation' || '' }}
194197
env:
195198
DOCTRINE_MONGODB_SERVER: ${{ steps.setup-mongodb.outputs.cluster-uri }}
196199
USE_LAZY_GHOST_OBJECT: ${{ matrix.proxy == 'lazy-ghost' && '1' || '0' }}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"phpstan/phpstan": "^2.1",
5353
"phpstan/phpstan-deprecation-rules": "^2.0",
5454
"phpstan/phpstan-phpunit": "^2.0",
55-
"phpunit/phpunit": "^10.5.58",
55+
"phpunit/phpunit": "^10.5.58|^11.5.43",
5656
"squizlabs/php_codesniffer": "^4",
5757
"symfony/cache": "^5.4 || ^6.0 || ^7.0 || ^8.0",
5858
"symfony/uid": "^5.4 || ^6.0 || ^7.0 || ^8.0"

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
55
bootstrap="tests/bootstrap.php"
66
cacheDirectory=".phpunit.cache"
77
displayDetailsOnAllIssues="true"

tests/Tests/BaseTestCase.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,11 @@ protected static function getConfiguration(): Configuration
105105
$config->setPersistentCollectionNamespace('PersistentCollections');
106106
$config->setDefaultDB(DOCTRINE_MONGODB_DATABASE);
107107
$config->setMetadataDriverImpl(static::createMetadataDriverImpl());
108-
if ($_ENV['USE_LAZY_GHOST_OBJECT']) {
109-
$config->setUseLazyGhostObject(true);
110-
}
111108

112109
if ($_ENV['USE_NATIVE_LAZY_OBJECT']) {
113110
$config->setUseNativeLazyObject(true);
111+
} elseif ($_ENV['USE_LAZY_GHOST_OBJECT']) {
112+
$config->setUseLazyGhostObject(true);
114113
}
115114

116115
if ($config->isNativeLazyObjectEnabled()) {

tests/Tests/ConfigurationTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionGenerator;
1212
use LogicException;
1313
use MongoDB\Driver\Manager;
14+
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
1415
use PHPUnit\Framework\Attributes\RequiresPhp;
1516
use PHPUnit\Framework\Attributes\TestWith;
1617
use PHPUnit\Framework\TestCase;
@@ -37,6 +38,7 @@ public function testUseNativeLazyObjectBeforePHP84(): void
3738
$c->setUseNativeLazyObject(true);
3839
}
3940

41+
#[IgnoreDeprecations]
4042
public function testUseLazyGhostObject(): void
4143
{
4244
$c = new Configuration();
@@ -74,6 +76,7 @@ public function testUseLazyGhostObjectWithSymfony8(): void
7476
$c->setUseLazyGhostObject(true);
7577
}
7678

79+
#[IgnoreDeprecations]
7780
public function testNativeLazyObjectDeprecatedByDefault(): void
7881
{
7982
$c = new Configuration();

tests/Tests/Functional/ShardKeyTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ public function setUp(): void
3535

3636
public function tearDown(): void
3737
{
38-
$this->logger->unregister();
38+
if (isset($this->logger)) {
39+
$this->logger->unregister();
40+
}
3941

4042
parent::tearDown();
4143
}

tests/Tests/Functional/TargetDocumentTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
88
use Doctrine\ODM\MongoDB\Mapping\MappingException;
99
use Doctrine\ODM\MongoDB\Tests\BaseTestCase;
10+
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
1011
use stdClass;
1112

1213
class TargetDocumentTest extends BaseTestCase
1314
{
14-
/** @doesNotPerformAssertions */
15+
#[DoesNotPerformAssertions]
1516
public function testMappedSuperClassAsTargetDocument(): void
1617
{
1718
$test = new TargetDocumentTestDocument();

tests/Tests/QueryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ public function testFindWithHint(): void
508508
$collection->expects($this->once())
509509
->method('find')
510510
->with(['foo' => 'bar'], ['hint' => 'foo'])
511-
->will($this->returnValue($cursor));
511+
->willReturn($cursor);
512512

513513
// Using QueryBuilder->find adds hint to the query array
514514
$queryArray = [

0 commit comments

Comments
 (0)