BrowserStackFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 5
dl 0
loc 57
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDriverName() 0 4 1
A configure() 0 11 1
A buildDriver() 0 6 1
A getCapabilitiesNode() 0 21 1
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
15
class BrowserStackFactory extends Selenium2Factory
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function getDriverName()
21
    {
22
        return 'browser_stack';
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function configure(ArrayNodeDefinition $builder)
29
    {
30
        $builder
31
            ->children()
32
                ->scalarNode('username')->defaultValue(getenv('BROWSERSTACK_USERNAME'))->end()
33
                ->scalarNode('access_key')->defaultValue(getenv('BROWSERSTACK_ACCESS_KEY'))->end()
34
                ->scalarNode('browser')->defaultValue('firefox')->end()
35
                ->append($this->getCapabilitiesNode())
36
            ->end()
37
        ;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function buildDriver(array $config)
44
    {
45
        $config['wd_host'] = sprintf('%s:%[email protected]/wd/hub', $config['username'], $config['access_key']);
46
47
        return parent::buildDriver($config);
48
    }
49
50
    protected function getCapabilitiesNode()
51
    {
52
        $node = parent::getCapabilitiesNode();
53
54
        $node
55
            ->children()
56
                ->scalarNode('project')->end()
57
                ->scalarNode('resolution')->end()
58
                ->scalarNode('build')->info('will be set automatically based on the TRAVIS_JOB_NUMBER environment variable if available')->end()
59
                ->scalarNode('os')->end()
60
                ->scalarNode('os_version')->end()
61
                ->scalarNode('device')->end()
62
                ->booleanNode('browserstack-debug')->end()
63
                ->booleanNode('browserstack-tunnel')->end()
64
                ->booleanNode('emulator')->end()
65
                ->booleanNode('acceptSslCert')->end()
66
            ->end()
67
        ;
68
69
        return $node;
70
    }
71
}
72