Skip to content

Commit d878021

Browse files
ensure kernel is available and booted (#186)
1 parent d8e60e4 commit d878021

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Functional/BaseTestCase.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,24 @@ public function getClient()
7474
*/
7575
public function getContainer()
7676
{
77-
return self::$kernel->getContainer();
77+
return $this->getKernel()->getContainer();
78+
}
79+
80+
/**
81+
* Ensures the kernel is available.
82+
*
83+
* @return \Symfony\Component\HttpKernel\KernelInterface
84+
*/
85+
public function getKernel()
86+
{
87+
if (null === self::$kernel) {
88+
self::$kernel = parent::bootKernel();
89+
}
90+
if (!self::$kernel->getContainer()) {
91+
self::$kernel->boot();
92+
}
93+
94+
return self::$kernel;
7895
}
7996

8097
/**

tests/Functional/BaseTestCaseTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public function testGetContainer()
6161
$this->assertEquals($this->container, $this->testCase->getContainer());
6262
}
6363

64+
public function testGetKernel()
65+
{
66+
$this->assertInstanceOf(KernelInterface::class, $this->testCase->getKernel());
67+
}
68+
6469
public function provideTestDb()
6570
{
6671
return [

0 commit comments

Comments
 (0)