SeleniumFactory::supportsJavascript()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Behat MinkExtension.
5
 * (c) Konstantin Kudryashov <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Behat\MinkExtension\ServiceContainer\Driver;
12
13
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
14
use Symfony\Component\DependencyInjection\Definition;
15
16
class SeleniumFactory implements DriverFactory
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function getDriverName()
22
    {
23
        return 'selenium';
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function supportsJavascript()
30
    {
31
        return true;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function configure(ArrayNodeDefinition $builder)
38
    {
39
        $builder
40
            ->children()
41
                ->scalarNode('host')->defaultValue('127.0.0.1')->end()
42
                ->scalarNode('port')->defaultValue(4444)->end()
43
                ->scalarNode('browser')->defaultValue('*%mink.browser_name%')->end()
44
            ->end()
45
        ;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function buildDriver(array $config)
52
    {
53
        if (!class_exists('Behat\Mink\Driver\SeleniumDriver')) {
54
            throw new \RuntimeException(
55
                'Install MinkSeleniumDriver in order to activate selenium session.'
56
            );
57
        }
58
59
        return new Definition('Behat\Mink\Driver\SeleniumDriver', array(
60
            $config['browser'],
61
            '%mink.base_url%',
62
            new Definition('Selenium\Client', array(
63
                $config['host'],
64
                $config['port'],
65
            )),
66
        ));
67
    }
68
}
69