Completed
Push — feature/policy_unit_tests ( d5ef00...d52f0a )
by Grant
28:44 queued 13:27
created

DuskTestCase::driver()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 16
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Tests;
4
5
use Laravel\Dusk\TestCase as BaseTestCase;
6
use Facebook\WebDriver\Chrome\ChromeOptions;
7
use Facebook\WebDriver\Remote\RemoteWebDriver;
8
use Facebook\WebDriver\Remote\DesiredCapabilities;
9
10
abstract class DuskTestCase extends BaseTestCase
11
{
12
    use CreatesApplication;
13
14
    /**
15
     * Prepare for Dusk test execution.
16
     *
17
     * @beforeClass
18
     * @return void
19
     */
20
    public static function prepare()
21
    {
22
        static::startChromeDriver();
23
    }
24
25
    /**
26
     * Create the RemoteWebDriver instance.
27
     *
28
     * @return \Facebook\WebDriver\Remote\RemoteWebDriver
29
     */
30
    protected function driver()
31
    {
32
        $options = (new ChromeOptions)->addArguments([
0 ignored issues
show
Unused Code introduced by
The assignment to $options is dead and can be removed.
Loading history...
33
            '--disable-gpu',
34
            '--headless'
35
        ]);
36
37
        // Run tests inside Docker container
38
        switch (config('dusk.driver')) {
39
        case 'container':
40
            return RemoteWebDriver::create(
41
                'http://selenium:4444/wd/hub', DesiredCapabilities::chrome()
42
            );
43
        default: // local
44
            return RemoteWebDriver::create(
45
                'http://localhost:9515', DesiredCapabilities::chrome()
46
            );
47
        }
48
    }
49
}
50