Failed Conditions
Push — master ( b9670c...4ba57f )
by Zac
16:20 queued 37s
created

clickFirstGroupAddTestButton()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Overwatch\ExpectationBundle\Tests\E2E;
4
5
use Facebook\WebDriver\WebDriverBy;
6
use Facebook\WebDriver\WebDriverSelect;
7
use Overwatch\UserBundle\Tests\Base\WebDriverTestCase;
8
9
/**
10
 * ExpectationListTest
11
 * Tests that the frontend drop-down matches the list of expectations
12
 */
13
class ExpectationListTest extends WebDriverTestCase
14
{
15
    public function testExpectationListPopulates()
16
    {
17
        $this->logInAsUser('user-1');
18
        $this->clickFirstGroupAddTestButton();
19
20
        $this->waitForLoadingAnimation();
21
        $this->assertEquals([
22
            '',
23
            'toPing',
24
            'toResolveTo',
25
            'toRespondHttp',
26
            'toRespondWithMimeType',
27
            'toContainText',
28
        ], $this->getSelectOptionValues('#page > div > form > select'));
29
    }
30
31
    private function clickFirstGroupAddTestButton()
32
    {
33
        $this->waitForLoadingAnimation();
34
        $this->webDriver->findElement(
35
            WebDriverBy::cssSelector('.groups > li:nth-child(1) > ul:nth-child(2) > li:nth-child(3) > div:nth-child(1) > a:nth-child(2)')
36
        )->click();
37
    }
38
39
    private function getSelectOptionValues($select)
40
    {
41
        $select = new WebDriverSelect($this->webDriver->findElement(
42
            WebDriverBy::cssSelector($select)
43
        ));
44
45
        $options = [];
46
47
        foreach ($select->getOptions() as $option) {
48
            $options[] = $option->getText();
49
        }
50
51
        return $options;
52
    }
53
}
54