Completed
Push — master ( e5e74e...13adb5 )
by Yo
02:16
created

Behat3SymfonyFactory::buildDriver()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
namespace Yoanm\Behat3SymfonyExtension\ServiceContainer\DriverFactory;
3
4
use Behat\Mink\Driver\BrowserKitDriver;
5
use Behat\MinkExtension\ServiceContainer\Driver\DriverFactory;
6
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
use Yoanm\Behat3SymfonyExtension\Driver\KernelDriver;
10
use Yoanm\Behat3SymfonyExtension\ServiceContainer\Behat3SymfonyExtension;
11
12
class Behat3SymfonyFactory implements DriverFactory
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 1
    public function getDriverName()
18
    {
19 1
        return 'behat3Symfony';
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 1
    public function supportsJavascript()
26
    {
27 1
        return false;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 1
    public function configure(ArrayNodeDefinition $builder)
34
    {
35 1
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function buildDriver(array $config)
41
    {
42
        // @codeCoverageIgnoreStart
43
        // Not possible to test
44
        if (!class_exists('Behat\Mink\Driver\BrowserKitDriver')) {
45
            throw new \RuntimeException(
46
                'Install MinkBrowserKitDriver in order to use the behat3Symfony driver.'
47
            );
48
        }
49
        // @codeCoverageIgnoreEnd
50
51 1
        return new Definition(
52 1
            BrowserKitDriver::class,
53
            [
54 1
                new Reference(Behat3SymfonyExtension::TEST_CLIENT_SERVICE_ID),
55 1
                '%mink.base_url%',
56
            ]
57 1
        );
58
    }
59
}
60