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

Commit25f9522

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

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

‎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
/**
4143
* @return string The Kernel class name
4244
*
@@ -67,6 +69,7 @@ protected static function bootKernel(array $options = [])
6769

6870
static::$kernel =static::createKernel($options);
6971
static::$kernel->boot();
72+
static::$booted =true;
7073

7174
$container =static::$kernel->getContainer();
7275
static::$container =$container->has('test.service_container') ?$container->get('test.service_container') :$container;
@@ -125,6 +128,7 @@ protected static function ensureKernelShutdown()
125128
$container->reset();
126129
}
127130
}
131+
static::$booted =false;
128132
static::$container =null;
129133
}
130134
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ abstract class WebTestCase extends KernelTestCase
3131
*/
3232
protectedstaticfunctioncreateClient(array$options = [],array$server = [])
3333
{
34+
if (true ===static::$booted) {
35+
thrownew \LogicException(sprintf('You should not boot the kernel before calling %s::%s, the kernel should only be booted once.',__CLASS__,__METHOD__));
36+
}
37+
3438
$kernel =static::bootKernel($options);
3539

3640
try {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp