Skip to content

Commit

Permalink
ensure kernel is available and booted (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectricMaxxx authored Aug 11, 2018
1 parent d8e60e4 commit d878021
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Functional/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,24 @@ public function getClient()
*/
public function getContainer()
{
return self::$kernel->getContainer();
return $this->getKernel()->getContainer();
}

/**
* Ensures the kernel is available.
*
* @return \Symfony\Component\HttpKernel\KernelInterface
*/
public function getKernel()
{
if (null === self::$kernel) {
self::$kernel = parent::bootKernel();
}
if (!self::$kernel->getContainer()) {
self::$kernel->boot();
}

return self::$kernel;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/Functional/BaseTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public function testGetContainer()
$this->assertEquals($this->container, $this->testCase->getContainer());
}

public function testGetKernel()
{
$this->assertInstanceOf(KernelInterface::class, $this->testCase->getKernel());
}

public function provideTestDb()
{
return [
Expand Down

0 comments on commit d878021

Please sign in to comment.