KernelForTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\Tests\Fixtures;
  11. use Symfony\Component\Config\Loader\LoaderInterface;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\HttpKernel\Bundle\BundleInterface;
  14. use Symfony\Component\HttpKernel\Kernel;
  15. class KernelForTest extends Kernel
  16. {
  17. private $fakeContainer;
  18. public function __construct(string $environment, bool $debug, bool $fakeContainer = true)
  19. {
  20. parent::__construct($environment, $debug);
  21. $this->fakeContainer = $fakeContainer;
  22. }
  23. public function getBundleMap()
  24. {
  25. return [];
  26. }
  27. public function registerBundles(): iterable
  28. {
  29. return [];
  30. }
  31. public function registerContainerConfiguration(LoaderInterface $loader)
  32. {
  33. }
  34. public function isBooted()
  35. {
  36. return $this->booted;
  37. }
  38. public function getProjectDir(): string
  39. {
  40. return __DIR__;
  41. }
  42. protected function initializeContainer()
  43. {
  44. if ($this->fakeContainer) {
  45. $this->container = new ContainerBuilder();
  46. } else {
  47. parent::initializeContainer();
  48. }
  49. }
  50. }