Behat3SymfonyDriverFactory::buildDriver()   A
last analyzed

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
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
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\ServiceContainer\Behat3SymfonyExtension;
10
11
class Behat3SymfonyDriverFactory implements DriverFactory
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 1
    public function getDriverName()
17
    {
18 1
        return 'behat3Symfony';
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 1
    public function supportsJavascript()
25
    {
26 1
        return false;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 1
    public function configure(ArrayNodeDefinition $builder)
33
    {
34 1
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 1
    public function buildDriver(array $config)
40
    {
41
        // @codeCoverageIgnoreStart
42
        // Not possible to test
43
        if (!class_exists('Behat\Mink\Driver\BrowserKitDriver')) {
44
            throw new \RuntimeException(
45
                'Install MinkBrowserKitDriver in order to use the behat3Symfony driver.'
46
            );
47
        }
48
        // @codeCoverageIgnoreEnd
49
50 1
        return new Definition(
51 1
            BrowserKitDriver::class,
52
            [
53 1
                new Reference(Behat3SymfonyExtension::TEST_CLIENT_SERVICE_ID),
54 1
                '%mink.base_url%',
55
            ]
56 1
        );
57
    }
58
}
59