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

ExpectationListTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 6
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testExpectationListPopulates() 0 15 1
A clickFirstGroupAddTestButton() 0 7 1
A getSelectOptionValues() 0 14 2
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