1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Incenteev\TranslationCheckerBundle\Tests\FixtureApp; |
4
|
|
|
|
5
|
|
|
use Composer\InstalledVersions; |
6
|
|
|
use Incenteev\TranslationCheckerBundle\IncenteevTranslationCheckerBundle; |
7
|
|
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; |
8
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
9
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
10
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
11
|
|
|
|
12
|
|
|
class TestKernel extends Kernel |
13
|
|
|
{ |
14
|
|
|
public function registerBundles(): iterable |
15
|
|
|
{ |
16
|
|
|
return array( |
17
|
|
|
new FrameworkBundle(), |
18
|
|
|
new IncenteevTranslationCheckerBundle(), |
19
|
|
|
); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader): void |
23
|
|
|
{ |
24
|
|
|
$loader->load(function (ContainerBuilder $container) { |
25
|
|
|
$container->loadFromExtension('framework', array( |
26
|
|
|
'translator' => array('fallback' => 'en'), |
27
|
|
|
'secret' => 'test', |
28
|
|
|
'http_method_override' => false, |
29
|
|
|
'php_errors' => ['log' => false], |
30
|
|
|
)); |
31
|
|
|
if (version_compare(InstalledVersions::getVersion('symfony/framework-bundle') ?? '2.0.0', '6.2.0', '>=')) { |
32
|
|
|
$container->loadFromExtension('framework', [ |
33
|
|
|
'handle_all_throwables' => true, |
34
|
|
|
]); |
35
|
|
|
} |
36
|
|
|
// Register a NullLogger to avoid getting the stderr default logger of FrameworkBundle |
37
|
|
|
$container->register('logger', 'Psr\Log\NullLogger'); |
38
|
|
|
}); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function getProjectDir(): string |
42
|
|
|
{ |
43
|
|
|
// Fake implementation so that the old root_dir/Resources/translations and the new project_dir/translations both |
44
|
|
|
// map to the same folder in our fixture app to avoid getting a deprecation warning when running tests with 4.2+ |
45
|
|
|
// but keeping compat with running tests on 3.4. |
46
|
|
|
return __DIR__.'/Resources'; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getCacheDir(): string |
50
|
|
|
{ |
51
|
|
|
return sys_get_temp_dir().'/incenteev_translation_checker'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getLogDir(): string |
55
|
|
|
{ |
56
|
|
|
return $this->getCacheDir(); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|