-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathTestKernel.php
More file actions
73 lines (60 loc) · 2.04 KB
/
TestKernel.php
File metadata and controls
73 lines (60 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types=1);
namespace MakinaCorpus\DbToolsBundle\Test;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use MakinaCorpus\DbToolsBundle\DbToolsBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Kernel;
class TestKernel extends Kernel implements CompilerPassInterface
{
use MicroKernelTrait;
private string $testRootDir;
public function __construct(string $environment, bool $debug)
{
$this->testRootDir = sys_get_temp_dir().'/'.uniqid('db_tools_', true);
$filesystem = new Filesystem();
$filesystem->mkdir($this->testRootDir . '/vendor');
$filesystem->mkdir($this->testRootDir . '/var/cache');
$filesystem->mkdir($this->testRootDir . '/var/db_tools');
parent::__construct($environment, $debug);
}
#[\Override]
public function registerBundles(): iterable
{
return [
new FrameworkBundle(),
new DoctrineBundle(),
new DbToolsBundle(),
];
}
protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void
{
$containerBuilder->loadFromExtension('framework', [
'secret' => 123,
'php_errors' => [
'log' => true,
],
]);
$containerBuilder->loadFromExtension('doctrine', [
'dbal' => [
'url' => '%env(resolve:DATABASE_URL)%',
],
]);
}
#[\Override]
public function getProjectDir(): string
{
return $this->getRootDir();
}
public function getRootDir(): string
{
return $this->testRootDir;
}
#[\Override]
public function process(ContainerBuilder $container): void {}
}