Test Setup Failed
Push — master ( 8278d0...9aa730 )
by Elijah
02:39
created

TestKernel::getLogDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the EloyekunlePermissionsBundle package.
5
 *
6
 * (c) Elijah Oyekunle <https://elijahoyekunle.com/>
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 Eloyekunle\PermissionsBundle\Tests\Functional;
13
14
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
15
use Eloyekunle\PermissionsBundle\Doctrine\RoleManager;
16
use Eloyekunle\PermissionsBundle\EloyekunlePermissionsBundle;
17
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
18
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
19
use Symfony\Component\Config\Loader\LoaderInterface;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\HttpKernel\Kernel;
22
23
class DependencyInjectionTest extends KernelTestCase
24
{
25
    public function testBundleLoaded()
26
    {
27
        self::bootKernel();
28
        $container = self::$kernel->getContainer();
29
30
        $this->assertInstanceOf(RoleManager::class, $container->get('eloyekunle_permissions.role_manager'));
31
    }
32
33
    protected static function getKernelClass()
34
    {
35
        return TestKernel::class;
36
    }
37
}
38
39
class TestKernel extends Kernel
40
{
41
    public function registerBundles()
42
    {
43
        return [
44
            new FrameworkBundle(),
45
            new DoctrineBundle(),
46
            new EloyekunlePermissionsBundle(),
47
        ];
48
    }
49
50
    public function registerContainerConfiguration(LoaderInterface $loader)
51
    {
52
        $loader->load(function (ContainerBuilder $container) {
53
            $container->loadFromExtension('framework', [
54
                'secret' => 'test',
55
                'router' => array(
56
                    'resource' => '%kernel.root_dir%/config/routing.yml',
57
                ),
58
            ]);
59
            $container->loadFromExtension('eloyekunle_permissions', [
60
                'db_driver' => 'orm',
61
                'role_class' => 'Eloyekunle\PermissionsBundle\Tests\TestRole',
62
            ]);
63
            $container->loadFromExtension('doctrine', [
64
                'dbal' => [
65
                    'driver' => 'pdo_sqlite',
66
                    'path' => $this->getCacheDir().'/testing.db',
67
                ],
68
                'orm' => [],
69
            ]);
70
        });
71
    }
72
73
    public function getCacheDir()
74
    {
75
        return sys_get_temp_dir().'/'.str_replace('\\', '-', get_class($this)).'/cache/'.$this->environment;
76
    }
77
78
    public function getLogDir()
79
    {
80
        return sys_get_temp_dir().'/'.str_replace('\\', '-', get_class($this)).'/log/'.$this->environment;
81
    }
82
}
83