Completed
Push — master ( 3f74db...61022b )
by Vincent
15s queued 11s
created

AppKernel::getProjectDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\NotificationBundle\Tests\App;
15
16
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
17
use FOS\RestBundle\FOSRestBundle;
18
use JMS\SerializerBundle\JMSSerializerBundle;
19
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
20
use Sonata\Doctrine\Bridge\Symfony\SonataDoctrineBundle;
21
use Sonata\NotificationBundle\SonataNotificationBundle;
22
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
23
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
24
use Symfony\Bundle\SecurityBundle\SecurityBundle;
25
use Symfony\Bundle\TwigBundle\TwigBundle;
26
use Symfony\Component\Config\Loader\LoaderInterface;
27
use Symfony\Component\DependencyInjection\ContainerBuilder;
28
use Symfony\Component\HttpKernel\Kernel;
29
use Symfony\Component\Routing\RouteCollectionBuilder;
30
31
final class AppKernel extends Kernel
32
{
33
    use MicroKernelTrait;
34
35
    public function __construct()
36
    {
37
        parent::__construct('test', false);
38
    }
39
40
    public function registerBundles()
41
    {
42
        return [
43
            new FrameworkBundle(),
44
            new SecurityBundle(),
45
            new TwigBundle(),
46
            new FOSRestBundle(),
47
            new SonataDoctrineBundle(),
48
            new SonataNotificationBundle(),
49
            new JMSSerializerBundle(),
50
            new DoctrineBundle(),
51
            new NelmioApiDocBundle(),
52
        ];
53
    }
54
55
    public function getCacheDir(): string
56
    {
57
        return $this->getBaseDir().'cache';
58
    }
59
60
    public function getLogDir(): string
61
    {
62
        return $this->getBaseDir().'log';
63
    }
64
65
    public function getProjectDir(): string
66
    {
67
        return __DIR__;
68
    }
69
70
    protected function configureRoutes(RouteCollectionBuilder $routes)
71
    {
72
        $routes->import($this->getProjectDir().'/config/routes.yaml');
73
    }
74
75
    protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void
0 ignored issues
show
Unused Code introduced by
The parameter $loader is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
    {
77
        $containerBuilder->register('templating')->setSynthetic(true);
78
        $containerBuilder->register('templating.locator')->setSynthetic(true);
79
        $containerBuilder->register('templating.name_parser')->setSynthetic(true);
80
        $containerBuilder->register('mailer')->setSynthetic(true);
81
82
        $containerBuilder->loadFromExtension('framework', [
83
            'secret' => '50n474.U53r',
84
            'session' => [
85
                'handler_id' => 'session.handler.native_file',
86
                'storage_id' => 'session.storage.mock_file',
87
                'name' => 'MOCKSESSID',
88
            ],
89
            'translator' => null,
90
            'validation' => [
91
                'enabled' => true,
92
            ],
93
            'form' => [
94
                'enabled' => true,
95
            ],
96
            'assets' => null,
97
            'test' => true,
98
            'profiler' => [
99
                'enabled' => true,
100
                'collect' => false,
101
            ],
102
        ]);
103
104
        $containerBuilder->loadFromExtension('security', [
105
            'firewalls' => ['api' => ['anonymous' => true]],
106
            'providers' => ['in_memory' => ['memory' => null]],
107
        ]);
108
109
        $containerBuilder->loadFromExtension('twig', [
110
            'strict_variables' => '%kernel.debug%',
111
            'exception_controller' => null,
112
        ]);
113
114
        $containerBuilder->loadFromExtension('doctrine', [
115
            'dbal' => [
116
                'connections' => [
117
                    'default' => [
118
                        'driver' => 'pdo_sqlite',
119
                    ],
120
                ],
121
            ],
122
            'orm' => [
123
                'default_entity_manager' => 'default',
124
            ],
125
        ]);
126
127
        $containerBuilder->loadFromExtension('fos_rest', [
128
            'param_fetcher_listener' => true,
129
        ]);
130
    }
131
132
    private function getBaseDir(): string
133
    {
134
        return sys_get_temp_dir().'/sonata-notification-bundle/var/';
135
    }
136
}
137