|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony MakerBundle package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Bundle\MakerBundle\Test; |
| 13 | + |
| 14 | +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; |
| 15 | +use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
| 16 | +use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\MakeCommandRegistrationPass; |
| 17 | +use Symfony\Bundle\MakerBundle\MakerBundle; |
| 18 | +use Symfony\Component\Config\Loader\LoaderInterface; |
| 19 | +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
| 20 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 21 | +use Symfony\Component\HttpKernel\Kernel; |
| 22 | +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; |
| 23 | +use Symfony\Component\Routing\RouteCollectionBuilder; |
| 24 | + |
| 25 | +class MakerTestKernel extends Kernel implements CompilerPassInterface |
| 26 | +{ |
| 27 | + use MicroKernelTrait; |
| 28 | + |
| 29 | + private $testRootDir; |
| 30 | + |
| 31 | + public function __construct(string $environment, bool $debug) |
| 32 | + { |
| 33 | + $this->testRootDir = sys_get_temp_dir().'/'.uniqid('sf_maker_', true); |
| 34 | + |
| 35 | + parent::__construct($environment, $debug); |
| 36 | + } |
| 37 | + |
| 38 | + public function registerBundles() |
| 39 | + { |
| 40 | + return [ |
| 41 | + new FrameworkBundle(), |
| 42 | + new MakerBundle(), |
| 43 | + ]; |
| 44 | + } |
| 45 | + |
| 46 | + protected function configureRoutes(RouteCollectionBuilder $routes) |
| 47 | + { |
| 48 | + } |
| 49 | + |
| 50 | + protected function configureRouting(RoutingConfigurator $routes) |
| 51 | + { |
| 52 | + } |
| 53 | + |
| 54 | + protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) |
| 55 | + { |
| 56 | + $c->setParameter('kernel.secret', 123); |
| 57 | + } |
| 58 | + |
| 59 | + public function getProjectDir() |
| 60 | + { |
| 61 | + return $this->getRootDir(); |
| 62 | + } |
| 63 | + |
| 64 | + public function getRootDir() |
| 65 | + { |
| 66 | + return $this->testRootDir; |
| 67 | + } |
| 68 | + |
| 69 | + public function process(ContainerBuilder $container) |
| 70 | + { |
| 71 | + // makes all makers public to help the tests |
| 72 | + foreach ($container->findTaggedServiceIds(MakeCommandRegistrationPass::MAKER_TAG) as $id => $tags) { |
| 73 | + $defn = $container->getDefinition($id); |
| 74 | + $defn->setPublic(true); |
| 75 | + } |
| 76 | + } |
| 77 | +} |
0 commit comments