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

WebTestCase   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 35
rs 10
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