Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29a08ee

Browse files
committed
[DI] throw an exception when the kernel has been booted twices
1 parent9f6cbaa commit29a08ee

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Deprecated the`$parser` argument of`ControllerResolver::__construct()` and`DelegatingLoader::__construct()`
99
* Deprecated the`controller_name_converter` and`resolve_controller_name_subscriber` services
1010
* The`ControllerResolver` and`DelegatingLoader` classes have been marked as`final`
11+
* Deprecated booting the kernel before running`WebTestCase::createClient()`
1112

1213
4.3.0
1314
-----

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ abstract class KernelTestCase extends TestCase
3737
*/
3838
protectedstatic$container;
3939

40+
protectedstatic$booted;
41+
4042
protectedfunctiondoTearDown():void
4143
{
4244
static::ensureKernelShutdown();
@@ -72,6 +74,7 @@ protected static function bootKernel(array $options = [])
7274

7375
static::$kernel =static::createKernel($options);
7476
static::$kernel->boot();
77+
static::$booted =true;
7578

7679
$container =static::$kernel->getContainer();
7780
static::$container =$container->has('test.service_container') ?$container->get('test.service_container') :$container;
@@ -126,6 +129,7 @@ protected static function ensureKernelShutdown()
126129
if (null !==static::$kernel) {
127130
$container =static::$kernel->getContainer();
128131
static::$kernel->shutdown();
132+
static::$booted =false;
129133
if ($containerinstanceof ResetInterface) {
130134
$container->reset();
131135
}

‎src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ protected function doTearDown(): void
3939
*/
4040
protectedstaticfunctioncreateClient(array$options = [],array$server = [])
4141
{
42+
if (true ===static::$booted) {
43+
@trigger_error(sprintf('Booting the kernel before calling %s::%s is deprecated and will throw in Symfony 5.0, the kernel should only be booted once.',__CLASS__,__METHOD__),E_USER_DEPRECATED);
44+
}
45+
4246
$kernel =static::bootKernel($options);
4347

4448
try {

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function testFlash($config, $insulate)
7070
}
7171

7272
/**
73+
*
7374
* See if two separate insulated clients can run without
7475
* polluting eachother's session data.
7576
*
@@ -82,7 +83,7 @@ public function testTwoClients($config, $insulate)
8283
if ($insulate) {
8384
$client1->insulate();
8485
}
85-
86+
$this->ensureKernelShutdown();
8687
// start second client
8788
$client2 =$this->createClient(['test_case' =>'Session','root_config' =>$config]);
8889
if ($insulate) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp