CoreInitializationPass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
3
namespace SilverStripe\BehatExtension\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
8
/**
9
 * Loads SilverStripe core. Required to initialize autoloading.
10
 */
11
class CoreInitializationPass implements CompilerPassInterface
12
{
13
    /**
14
     * Loads kernel file.
15
     *
16
     * @param ContainerBuilder $container
17
     */
18
    public function process(ContainerBuilder $container)
19
    {
20
        // Connect to database and build manifest
21
        $frameworkPath = $container->getParameter('behat.silverstripe_extension.framework_path');
22
        $_GET['flush'] = 1;
23
        require_once $frameworkPath . '/core/Core.php';
24
        
25
        if (class_exists('TestRunner')) {
26
            // 3.x compat
27
            \TestRunner::use_test_manifest();
28
        } else {
29
            \SapphireTest::use_test_manifest();
30
        }
31
32
        unset($_GET['flush']);
33
34
        // Remove the error handler so that PHPUnit can add its own
35
        restore_error_handler();
36
    }
37
}
38