Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #31522 Added more tests for WebProfilerBundle (javiereguiluz)
This PR was merged into the 3.4 branch. Discussion ---------- Added more tests for WebProfilerBundle | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | - <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | - Thanks to @jpauli Code Coverage info about Symfony (http://cov.jpauli.tech/) I found that WebProfiler's controllers are pretty badly covered: ![image](https://user-images.githubusercontent.com/73419/57919817-ec390500-7899-11e9-81b7-763a0b35d0ec.png) This PR focuses on testing the main controller class: ![image](https://user-images.githubusercontent.com/73419/57919877-04108900-789a-11e9-8a93-3466b672d873.png) Commits ------- 2f7a820 Added more tests for WebProfilerBundle
- Loading branch information
Showing
3 changed files
with
270 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\WebProfilerBundle\Tests\Functional; | ||
|
||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Bundle\TwigBundle\TwigBundle; | ||
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Kernel; | ||
use Symfony\Component\Routing\RouteCollectionBuilder; | ||
|
||
class WebProfilerBundleKernel extends Kernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('test', false); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
if (null === $this->name) { | ||
$this->name = parent::getName().substr(md5(__CLASS__), -16); | ||
} | ||
|
||
return $this->name; | ||
} | ||
|
||
public function registerBundles() | ||
{ | ||
return [ | ||
new FrameworkBundle(), | ||
new TwigBundle(), | ||
new WebProfilerBundle(), | ||
]; | ||
} | ||
|
||
protected function configureRoutes(RouteCollectionBuilder $routes) | ||
{ | ||
$routes->import(__DIR__.'/../../Resources/config/routing/profiler.xml', '/_profiler'); | ||
$routes->import(__DIR__.'/../../Resources/config/routing/wdt.xml', '/_wdt'); | ||
$routes->add('/', 'kernel:homepageController'); | ||
} | ||
|
||
protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader) | ||
{ | ||
$containerBuilder->loadFromExtension('framework', [ | ||
'secret' => 'foo-secret', | ||
'profiler' => ['only_exceptions' => false], | ||
'session' => ['storage_id' => 'session.storage.mock_file'], | ||
]); | ||
|
||
$containerBuilder->loadFromExtension('web_profiler', [ | ||
'toolbar' => true, | ||
'intercept_redirects' => false, | ||
]); | ||
} | ||
|
||
public function getCacheDir() | ||
{ | ||
return sys_get_temp_dir().'/cache-'.spl_object_hash($this); | ||
} | ||
|
||
public function getLogDir() | ||
{ | ||
return sys_get_temp_dir().'/log-'.spl_object_hash($this); | ||
} | ||
|
||
public function homepageController() | ||
{ | ||
return new Response('<html><head></head><body>Homepage Controller.</body></html>'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters