10000 test: Fix for older KernelTestCase · SymfonyTest/symfony-bundle-test@fe6e9c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit fe6e9c5

Browse files
committed
test: Fix for older KernelTestCase
1 parent e44d67c commit fe6e9c5

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Readme.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ class BundleInitializationTest extends KernelTestCase
4949
public function testInitBundle()
5050
{
5151
// Boot the kernel.
52-
self::bootKernel();
52+
$kernel = self::bootKernel();
5353

5454
// Get the container
55-
$container = self::getContainer();
55+
$container = $kernel->getContainer();
56+
57+
// Or for FrameworkBundle@^5.3.6 to access private services without the PublicCompilerPass
58+
// $container = self::getContainer();
5659

5760
// Test if you services exists
5861
$this->assertTrue($container->has('acme.foo'));
@@ -108,7 +111,7 @@ class BundleInitializationTest extends KernelTestCase
108111
return $kernel;
109112
}
110113

111-
protected function setUp(): void
114+
protected function setUp()
112115
{
113116
parent::setUp();
114117

tests/Functional/BundleConfigurationTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ function (ContainerBuilder $container) {
5353
*/
5454
public function testBundleWithDifferentConfigurationFormats($config)
5555
{
56-
self::bootKernel(['configFiles' => [$config]]);
57-
58-
$container = self::getContainer();
56+
$kernel = self::bootKernel(['configFiles' => [$config]]);
57+
$container = $kernel->getContainer();
5958

6059
$this->assertEquals('val1', $container->getParameter('app.foo'));
6160
$this->assertEquals(['val2', 'val3'], $container->getParameter('app.bar'));

tests/Functional/BundleInitializationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ protected static function createKernel(array $options = [])
2626

2727
public function testRegisterBundle()
2828
{
29-
self::bootKernel();
30-
$container = self::getContainer();
29+
$kernel = self::bootKernel();
30+
$container = $kernel->getContainer();
3131
$this->assertTrue($container->has('kernel'));
3232
}
3333
}

0 commit comments

Comments
 (0)
0