Skip to content

Commit c3ce14c

Browse files
authored
Merge pull request #2040 from greg0ire/phpunit-11
Phpunit 11
2 parents cb8a923 + c78a03b commit c3ce14c

File tree

4 files changed

+63
-13
lines changed

4 files changed

+63
-13
lines changed

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.1",
5353
"phpstan/phpstan-phpunit": "2.0.3",
5454
"phpstan/phpstan-strict-rules": "^2",
55-
"phpunit/phpunit": "^10.5.53",
55+
"phpunit/phpunit": "^10.5.53 || ^11.5.38",
5656
"psr/log": "^1.1.4 || ^2.0 || ^3.0",
5757
"symfony/doctrine-messenger": "^6.4 || ^7.0",
5858
"symfony/expression-language": "^6.4 || ^7.0",

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="tests/bootstrap.php"
34
colors="true"
45
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
56
displayDetailsOnTestsThatTriggerDeprecations="true"

tests/DependencyInjection/Compiler/CacheCompatibilityPassTest.php

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@
66
use Doctrine\Bundle\DoctrineBundle\Tests\TestCase;
77
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
88
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
9+
use Doctrine\ORM\Cache\CacheEntry;
10+
use Doctrine\ORM\Cache\CacheKey;
11+
use Doctrine\ORM\Cache\CollectionCacheEntry;
12+
use Doctrine\ORM\Cache\Lock;
913
use Doctrine\ORM\Cache\Region;
1014
use Doctrine\ORM\EntityManagerInterface;
1115
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
1216
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
17+
use RuntimeException;
1318
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1419
use Symfony\Component\Config\Loader\LoaderInterface;
1520
use Symfony\Component\DependencyInjection\ContainerBuilder;
1621
use Symfony\Component\DependencyInjection\Definition;
1722

18-
use function get_class;
1923
use function interface_exists;
2024

2125
class CacheCompatibilityPassTest extends TestCase
@@ -33,18 +37,11 @@ public static function setUpBeforeClass(): void
3337

3438
public function testCacheConfigUsingServiceDefinedByApplication(): void
3539
{
36-
$customRegionClass = get_class($this->createMock(Region::class));
37-
38-
(new class ($customRegionClass) extends TestKernel {
39-
public function __construct(private readonly string $regionClass)
40-
{
41-
parent::__construct(false);
42-
}
43-
40+
(new class (false) extends TestKernel {
4441
public function registerContainerConfiguration(LoaderInterface $loader): void
4542
{
4643
parent::registerContainerConfiguration($loader);
47-
$loader->load(function (ContainerBuilder $containerBuilder): void {
44+
$loader->load(static function (ContainerBuilder $containerBuilder): void {
4845
$containerBuilder->loadFromExtension('framework', [
4946
'cache' => [
5047
'pools' => [
@@ -64,13 +61,16 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
6461
'regions' => [
6562
'filelock' => ['type' => 'filelock', 'lifetime' => 0, 'cache_driver' => ['type' => 'pool', 'pool' => 'doctrine.system_cache_pool']],
6663
'lifelong' => ['lifetime' => 0, 'cache_driver' => ['type' => 'pool', 'pool' => 'doctrine.system_cache_pool']],
67-
'entity_cache_region' => ['type' => 'service', 'service' => $this->regionClass],
64+
'entity_cache_region' => [
65+
'type' => 'service',
66+
'service' => TestRegion::class,
67+
],
6868
],
6969
],
7070
],
7171
],
7272
);
73-
$containerBuilder->register($this->regionClass, $this->regionClass);
73+
$containerBuilder->register(TestRegion::class, TestRegion::class);
7474
$containerBuilder->setDefinition(
7575
'custom_cache_service',
7676
new Definition(ArrayAdapter::class),
@@ -132,3 +132,45 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
132132
})->boot();
133133
}
134134
}
135+
136+
if (! interface_exists(Region::class)) {
137+
return;
138+
}
139+
140+
final class TestRegion implements Region
141+
{
142+
public function getName(): string
143+
{
144+
return 'test_region';
145+
}
146+
147+
public function contains(CacheKey $key): bool
148+
{
149+
throw new RuntimeException('Not implemented');
150+
}
151+
152+
public function get(CacheKey $key): CacheEntry|null
153+
{
154+
throw new RuntimeException('Not implemented');
155+
}
156+
157+
public function getMultiple(CollectionCacheEntry $collection): array|null
158+
{
159+
throw new RuntimeException('Not implemented');
160+
}
161+
162+
public function put(CacheKey $key, CacheEntry $entry, Lock|null $lock = null): bool
163+
{
164+
throw new RuntimeException('Not implemented');
165+
}
166+
167+
public function evict(CacheKey $key): bool
168+
{
169+
throw new RuntimeException('Not implemented');
170+
}
171+
172+
public function evictAll(): bool
173+
{
174+
throw new RuntimeException('Not implemented');
175+
}
176+
}

tests/bootstrap.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Symfony\Component\ErrorHandler\ErrorHandler;
6+
7+
ErrorHandler::register(null, false);

0 commit comments

Comments
 (0)