Skip to content

Commit 3cc3095

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Messenger] Fix dealing with unexpected payload in Redis transport [Filesystem] Update some PHPDoc of the Path class [VarDumper] Fix dumping mysqli_driver instances Fix missing ReturnTypeWillChange attributes [Cache] Add missing log when saving namespace [HttpKernel] Reset services between requests performed by KernelBrowser [HttpKernel] Remove unused argument in ArgumentMetadataFactory [Stopwatch] Fix test expectation [SecurityBundle] fix autoconfiguring Monolog's ProcessorInterface KernelTestCase resets internal state on tearDown [Security/Http] Fix getting password-upgrader when user-loader is a closure [HttpKernel] Fix extracting controller name from closures [Intl] fix wrong offset timezone PHP 8.1 Fix type binding Remove duplicated test [Dotenv] Fix reading config for symfony/runtime when running dump command [Serializer] Remove unnecessary break [Runtime] Fix dotenv_overload with commands Make document type nodes ignorable Initialize Symfony\Component\Security\Core\Exception\AccountStatusException:: property
2 parents cedd17b + 59eda81 commit 3cc3095

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

KernelBrowser.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
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;
2526

2627
/**
2728
* Simulates a browser and makes requests to a Kernel object.
@@ -156,7 +157,12 @@ protected function doRequest(object $request): Response
156157
// avoid shutting down the Kernel if no request has been performed yet
157158
// WebTestCase::createClient() boots the Kernel but do not handle a request
158159
if ($this->hasPerformedRequest && $this->reboot) {
160+
$container = $this->kernel->getContainer();
159161
$this->kernel->shutdown();
162+
163+
if ($container instanceof ResetInterface) {
164+
$container->reset();
165+
}
160166
} else {
161167
$this->hasPerformedRequest = true;
162168
}
@@ -203,7 +209,7 @@ protected function getScript(object $request): string
203209

204210
$requires = '';
205211
foreach (get_declared_classes() as $class) {
206-
if (0 === strpos($class, 'ComposerAutoloaderInit')) {
212+
if (str_starts_with($class, 'ComposerAutoloaderInit')) {
207213
$r = new \ReflectionClass($class);
208214
$file = \dirname($r->getFileName(), 2).'/autoload.php';
209215
if (is_file($file)) {

Test/KernelTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ abstract class KernelTestCase extends TestCase
4040
protected function tearDown(): void
4141
{
4242
static::ensureKernelShutdown();
43+
static::$class = null;
4344
static::$kernel = null;
4445
static::$booted = false;
4546
}

Tests/Functional/TestServiceContainerTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,22 @@ public function testThatPrivateServicesAreAvailableIfTestConfigIsEnabled()
3939
$this->assertTrue(static::getContainer()->has('private_service'));
4040
$this->assertFalse(static::getContainer()->has(UnusedPrivateService::class));
4141
}
42+
43+
/**
44+
* @doesNotPerformAssertions
45+
*/
46+
public function testBootKernel()
47+
{
48+
static::bootKernel(['test_case' => 'TestServiceContainer']);
49+
}
50+
51+
/**
52+
* @depends testBootKernel
53+
*/
54+
public function testKernelIsNotInitialized()
55+
{
56+
self::assertNull(self::$class);
57+
self::assertNull(self::$kernel);
58+
self::assertFalse(self::$booted);
59+
}
4260
}

Tests/KernelBrowserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testEnableRebootKernel()
5454
private function getKernelMock()
5555
{
5656
$mock = $this->getMockBuilder($this->getKernelClass())
57-
->setMethods(['shutdown', 'boot', 'handle'])
57+
->setMethods(['shutdown', 'boot', 'handle', 'getContainer'])
5858
->disableOriginalConstructor()
5959
->getMock();
6060

0 commit comments

Comments
 (0)