1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenstruck\Foundry\Tests\Fixtures; |
4
|
|
|
|
5
|
|
|
use DAMA\DoctrineTestBundle\DAMADoctrineTestBundle; |
6
|
|
|
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; |
7
|
|
|
use Psr\Log\NullLogger; |
8
|
|
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; |
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
10
|
|
|
use Symfony\Bundle\MakerBundle\MakerBundle; |
11
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
12
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
13
|
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
14
|
|
|
use Symfony\Component\Routing\RouteCollectionBuilder; |
15
|
|
|
use Zenstruck\Foundry\Tests\Fixtures\Factories\CategoryFactory; |
16
|
|
|
use Zenstruck\Foundry\Tests\Fixtures\Factories\CategoryServiceFactory; |
17
|
|
|
use Zenstruck\Foundry\Tests\Fixtures\Stories\ServiceStory; |
18
|
|
|
use Zenstruck\Foundry\ZenstruckFoundryBundle; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Kevin Bond <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class Kernel extends BaseKernel |
24
|
|
|
{ |
25
|
|
|
use MicroKernelTrait; |
|
|
|
|
26
|
|
|
|
27
|
|
|
public function registerBundles(): iterable |
28
|
|
|
{ |
29
|
|
|
yield new FrameworkBundle(); |
|
|
|
|
30
|
|
|
yield new DoctrineBundle(); |
31
|
|
|
yield new MakerBundle(); |
32
|
|
|
|
33
|
|
|
if (\getenv('USE_FOUNDRY_BUNDLE')) { |
34
|
|
|
yield new ZenstruckFoundryBundle(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
if (\getenv('USE_DAMA_DOCTRINE_TEST_BUNDLE')) { |
38
|
|
|
yield new DAMADoctrineTestBundle(); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader): void |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
$c->register('logger', NullLogger::class); |
45
|
|
|
|
46
|
|
|
$c->register(Service::class); |
47
|
|
|
$c->register(ServiceStory::class) |
48
|
|
|
->setAutoconfigured(true) |
49
|
|
|
->setAutowired(true) |
50
|
|
|
; |
51
|
|
|
$c->register(CategoryFactory::class) |
52
|
|
|
->setAutoconfigured(true) |
53
|
|
|
->setAutowired(true) |
54
|
|
|
; |
55
|
|
|
$c->register(CategoryServiceFactory::class) |
56
|
|
|
->setAutoconfigured(true) |
57
|
|
|
->setAutowired(true) |
58
|
|
|
; |
59
|
|
|
|
60
|
|
|
$c->loadFromExtension('framework', [ |
61
|
|
|
'secret' => 'S3CRET', |
62
|
|
|
'test' => true, |
63
|
|
|
]); |
64
|
|
|
|
65
|
|
|
$c->loadFromExtension('doctrine', [ |
66
|
|
|
'dbal' => ['url' => '%env(resolve:DATABASE_URL)%'], |
67
|
|
|
'orm' => [ |
68
|
|
|
'auto_generate_proxy_classes' => true, |
69
|
|
|
'auto_mapping' => true, |
70
|
|
|
'mappings' => [ |
71
|
|
|
'Test' => [ |
72
|
|
|
'is_bundle' => false, |
73
|
|
|
'type' => 'annotation', |
74
|
|
|
'dir' => '%kernel.project_dir%/tests/Fixtures/Entity', |
75
|
|
|
'prefix' => 'Zenstruck\Foundry\Tests\Fixtures\Entity', |
76
|
|
|
'alias' => 'Test', |
77
|
|
|
], |
78
|
|
|
], |
79
|
|
|
], |
80
|
|
|
]); |
81
|
|
|
|
82
|
|
|
if (\getenv('USE_FOUNDRY_BUNDLE')) { |
83
|
|
|
$c->loadFromExtension('zenstruck_foundry', [ |
84
|
|
|
'auto_refresh_proxies' => false, |
85
|
|
|
]); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
protected function configureRoutes(RouteCollectionBuilder $routes): void |
|
|
|
|
90
|
|
|
{ |
91
|
|
|
// noop |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|