Skip to content

Commit 5fbd0dc

Browse files
Merge branch '6.0' into 6.1
* 6.0: - - Fix merge Fix merge [HttpKernel] Guard against bad profile data Fix merge [FrameworkBundle] Fix resetting container between tests Fix deprecations on PHP 8.2
2 parents 88497f2 + a7e1a27 commit 5fbd0dc

File tree

31 files changed

+241
-109
lines changed

31 files changed

+241
-109
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- php: '8.1'
3030
mode: low-deps
3131
- php: '8.2'
32-
mode: experimental
32+
#mode: experimental
3333
fail-fast: false
3434

3535
runs-on: ubuntu-20.04

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
use Doctrine\Common\Collections\ArrayCollection;
1515
use Doctrine\DBAL\Types\Type;
16+
use Doctrine\ORM\Mapping\ClassMetadataInfo;
1617
use Doctrine\ORM\Tools\SchemaTool;
1718
use Doctrine\Persistence\ManagerRegistry;
18-
use Doctrine\Persistence\Mapping\ClassMetadata;
1919
use Doctrine\Persistence\ObjectManager;
2020
use Doctrine\Persistence\ObjectRepository;
2121
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
@@ -111,7 +111,7 @@ protected function createEntityManagerMock($repositoryMock)
111111
->willReturn($repositoryMock)
112112
;
113113

114-
$classMetadata = $this->createMock(ClassMetadata::class);
114+
$classMetadata = $this->createMock(ClassMetadataInfo::class);
115115
$classMetadata
116116
->expects($this->any())
117117
->method('hasField')

src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ public function testExtractEnum()
159159

160160
$validator = Validation::createValidatorBuilder()
161161
->addMethodMapping('loadValidatorMetadata')
162-
->enableAnnotationMapping()
162+
->enableAnnotationMapping(true)
163+
->addDefaultDoctrineAnnotationReader()
163164
->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), '{^Symfony\\\\Bridge\\\\Doctrine\\\\Tests\\\\Fixtures\\\\DoctrineLoader}'))
164165
->getValidator()
165166
;

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ function ($definition) {
185185
}
186186
}
187187

188+
#[\AllowDynamicProperties]
188189
final class DummyClass implements DummyInterface, SunnyInterface
189190
{
190191
private $ref;

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14+
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
1415
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617

@@ -28,14 +29,18 @@ public function process(ContainerBuilder $container)
2829
// "annotation_reader" at build time don't get any cache
2930
foreach ($container->findTaggedServiceIds('annotations.cached_reader') as $id => $tags) {
3031
$reader = $container->getDefinition($id);
32+
$reader->setPublic(false);
3133
$properties = $reader->getProperties();
3234

3335
if (isset($properties['cacheProviderBackup'])) {
3436
$provider = $properties['cacheProviderBackup']->getValues()[0];
3537
unset($properties['cacheProviderBackup']);
3638
$reader->setProperties($properties);
37-
$container->set($id, null);
38-
$container->setDefinition($id, $reader->replaceArgument(1, $provider));
39+
$reader->replaceArgument(1, $provider);
40+
} elseif (4 <= \count($arguments = $reader->getArguments()) && $arguments[3] instanceof ServiceClosureArgument) {
41+
$arguments[1] = $arguments[3]->getValues()[0];
42+
unset($arguments[3]);
43+
$reader->setArguments($arguments);
3944
}
4045
}
4146
}

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,9 +1610,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
16101610

16111611
$container
16121612
->getDefinition('annotations.cached_reader')
1613+
->setPublic(true) // set to false in AddAnnotationsCachedReaderPass
16131614
->replaceArgument(2, $config['debug'])
1614-
// temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
1615-
->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
1615+
// reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
1616+
->addArgument(new ServiceClosureArgument(new Reference($cacheService)))
16161617
->addTag('annotations.cached_reader')
16171618
;
16181619

src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Symfony\Component\HttpKernel\KernelInterface;
2323
use Symfony\Component\HttpKernel\Profiler\Profile as HttpProfile;
2424
use Symfony\Component\Security\Core\User\UserInterface;
25-
use Symfony\Contracts\Service\ResetInterface;
2625

2726
/**
2827
* Simulates a browser and makes requests to a Kernel object.
@@ -157,12 +156,8 @@ protected function doRequest(object $request): Response
157156
// avoid shutting down the Kernel if no request has been performed yet
158157
// WebTestCase::createClient() boots the Kernel but do not handle a request
159158
if ($this->hasPerformedRequest && $this->reboot) {
160-
$container = $this->kernel->getContainer();
159+
$this->kernel->boot();
161160
$this->kernel->shutdown();
162-
163-
if ($container instanceof ResetInterface) {
164-
$container->reset();
165-
}
166161
} else {
167162
$this->hasPerformedRequest = true;
168163
}

src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\DependencyInjection\ContainerInterface;
1616
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
1717
use Symfony\Component\HttpKernel\KernelInterface;
18-
use Symfony\Contracts\Service\ResetInterface;
1918

2019
/**
2120
* KernelTestCase is the base class for tests needing a Kernel.
@@ -35,8 +34,6 @@ abstract class KernelTestCase extends TestCase
3534

3635
protected static $booted = false;
3736

38-
private static ?ContainerInterface $kernelContainer = null;
39-
4037
protected function tearDown(): void
4138
{
4239
static::ensureKernelShutdown();
@@ -69,12 +66,11 @@ protected static function bootKernel(array $options = []): KernelInterface
6966
{
7067
static::ensureKernelShutdown();
7168

72-
static::$kernel = static::createKernel($options);
73-
static::$kernel->boot();
69+
$kernel = static::createKernel($options);
70+
$kernel->boot();
71+
self::$kernel = $kernel;
7472
static::$booted = true;
7573

76-
self::$kernelContainer = static::$kernel->getContainer();
77-
7874
return static::$kernel;
7975
}
8076

@@ -95,7 +91,7 @@ protected static function getContainer(): ContainerInterface
9591
}
9692

9793
try {
98-
return self::$kernelContainer->get('test.service_container');
94+
return self::$kernel->getContainer()->get('test.service_container');
9995
} catch (ServiceNotFoundException $e) {
10096
throw new \LogicException('Could not find service "test.service_container". Try updating the "framework.test" config to "true".', 0, $e);
10197
}
@@ -144,14 +140,9 @@ protected static function createKernel(array $options = []): KernelInterface
144140
protected static function ensureKernelShutdown()
145141
{
146142
if (null !== static::$kernel) {
143+
static::$kernel->boot();
147144
static::$kernel->shutdown();
148145
static::$booted = false;
149146
}
150-
151-
if (self::$kernelContainer instanceof ResetInterface) {
152-
self::$kernelContainer->reset();
153-
}
154-
155-
self::$kernelContainer = null;
156147
}
157148
}

src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ public function testEnableRebootKernel()
5151
$client->request('GET', '/');
5252
}
5353

54+
public function testRequestAfterKernelShutdownAndPerformedRequest()
55+
{
56+
$this->expectNotToPerformAssertions();
57+
58+
$client = static::createClient(['test_case' => 'TestServiceContainer']);
59+
$client->request('GET', '/');
60+
static::ensureKernelShutdown();
61+
$client->request('GET', '/');
62+
}
63+
5464
private function getKernelMock()
5565
{
5666
$mock = $this->getMockBuilder($this->getKernelClass())

src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,16 @@ public function testPrune()
5454
public function testKnownTagVersionsTtl()
5555
{
5656
$itemsPool = new FilesystemAdapter('', 10);
57-
$tagsPool = $this->createMock(AdapterInterface::class);
57+
$tagsPool = new ArrayAdapter();
5858

5959
$pool = new TagAwareAdapter($itemsPool, $tagsPool, 10);
6060

6161
$item = $pool->getItem('foo');
6262
$item->tag(['baz']);
6363
$item->expiresAfter(100);
6464

65-
$tag = $this->createMock(CacheItemInterface::class);
66-
$tag->expects(self::exactly(2))->method('get')->willReturn(10);
67-
$tag->expects(self::exactly(2))->method('set')->willReturn($tag);
68-
69-
$tagsPool->expects(self::exactly(2))->method('getItems')->willReturn(new \ArrayIterator([
70-
'baz'.TagAwareAdapter::TAGS_PREFIX => $tag,
71-
]));
65+
$tag = $tagsPool->getItem('baz'.TagAwareAdapter::TAGS_PREFIX);
66+
$tagsPool->save($tag->set(10));
7267

7368
$pool->save($item);
7469
$this->assertTrue($pool->getItem('foo')->isHit());

0 commit comments

Comments
 (0)