Completed
Pull Request — master (#24)
by Quentin
03:03
created

WebTestCase::createKernel()   B

Complexity

Conditions 5
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 8.8571
cc 5
eloc 9
nc 2
nop 1
1
<?php
2
3
namespace Majora\Bundle\FrameworkExtraBundle\Tests\Functional;
4
5
use Majora\Bundle\FrameworkExtraBundle\Tests\Functional\app\AppKernel;
6
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
7
use Symfony\Component\Filesystem\Filesystem;
8
use Symfony\Component\HttpKernel\Kernel;
9
10
class WebTestCase extends BaseWebTestCase
11
{
12
    protected function deleteTmpDir($testCase)
13
    {
14
        if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/'.$testCase)) {
15
            return;
16
        }
17
18
        $fs = new Filesystem();
19
        $fs->remove($dir);
20
    }
21
22
    protected static function getKernelClass()
23
    {
24
        require_once __DIR__.'/app/AppKernel.php';
25
26
        return AppKernel::class;
27
    }
28
29
    protected static function createKernel(array $options = [])
30
    {
31
        $class = self::getKernelClass();
32
33
        if (!isset($options['test_case'])) {
34
            throw new \InvalidArgumentException('The option "test_case" must be set.');
35
        }
36
37
        return new $class(
38
            $options['test_case'],
39
            isset($options['root_config']) ? $options['root_config'] : 'config.yml',
40
            isset($options['environment']) ? $options['environment'] : 'majoraframeworkextrabundletest'.strtolower($options['test_case']),
41
            isset($options['debug']) ? $options['debug'] : true
42
        );
43
    }
44
}
45