Skip to content

Commit cd91b8f

Browse files
committed
minor #24385 [FrameworkBundle] Register a NullLogger from test kernels (ogizanagi)
This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle] Register a NullLogger from test kernels | Q | A | ------------- | --- | Branch? | 3.4 <!-- see comment below --> | Bug fix? | no | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Relates to #24300 This will avoid unnecessary output on Travis or when running FrameworkBundle tests locally: - before: https://travis-ci.org/symfony/symfony/jobs/281624658#L3594-L3635 - after: https://travis-ci.org/symfony/symfony/jobs/281643868#L3599-L3617 but also needed for anyone running functional tests on their project and using the default logger, in order to not get garbage output. Do we need to find a more generic solution (like exposing a `framework.default_logger` option so users can set it to false for test)? Or just documenting this? Commits ------- c109dcd [FrameworkBundle] Register a NullLogger from test kernels
2 parents a2ae9a4 + c109dcd commit cd91b8f

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php

+7
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand\Fixture;
1313

14+
use Psr\Log\NullLogger;
1415
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1516
use Symfony\Component\Config\Loader\LoaderInterface;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1618
use Symfony\Component\HttpKernel\Kernel;
1719

1820
class TestAppKernel extends Kernel
@@ -33,4 +35,9 @@ public function registerContainerConfiguration(LoaderInterface $loader)
3335
{
3436
$loader->load(__DIR__.DIRECTORY_SEPARATOR.'config.yml');
3537
}
38+
39+
protected function build(ContainerBuilder $container)
40+
{
41+
$container->register('logger', NullLogger::class);
42+
}
3643
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php

+7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app;
1313

14+
use Psr\Log\NullLogger;
1415
use Symfony\Component\Config\Loader\LoaderInterface;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1517
use Symfony\Component\Filesystem\Filesystem;
1618
use Symfony\Component\HttpKernel\Kernel;
1719

@@ -72,6 +74,11 @@ public function registerContainerConfiguration(LoaderInterface $loader)
7274
$loader->load($this->rootConfig);
7375
}
7476

77+
protected function build(ContainerBuilder $container)
78+
{
79+
$container->register('logger', NullLogger::class);
80+
}
81+
7582
public function serialize()
7683
{
7784
return serialize(array($this->varDir, $this->testCase, $this->rootConfig, $this->getEnvironment(), $this->isDebug()));

src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Kernel;
1313

14+
use Psr\Log\NullLogger;
1415
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
1516
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1617
use Symfony\Component\Config\Loader\LoaderInterface;
@@ -77,6 +78,7 @@ protected function configureRoutes(RouteCollectionBuilder $routes)
7778

7879
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
7980
{
81+
$c->register('logger', NullLogger::class);
8082
$c->loadFromExtension('framework', array(
8183
'secret' => '$ecret',
8284
));

0 commit comments

Comments
 (0)