Completed
Pull Request — master (#148)
by
unknown
15:51 queued 29s
created

MyAccountTest::clickApiKeyAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Overwatch\UserBundle\Tests\E2E;
4
5
use Facebook\WebDriver\WebDriverBy;
6
use Overwatch\UserBundle\DataFixtures\ORM\UserFixtures;
7
use Overwatch\UserBundle\Tests\Base\WebDriverTestCase;
8
9
/**
10
 * MyAccountTest
11
 *
12
 * @author Zac Sturgess <[email protected]>
13
 */
14
class MyAccountTest extends WebDriverTestCase
15
{
16 View Code Duplication
    public function setUp()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18
        parent::setUp();
19
20
        $this->logInAsUser('user-1');
21
        $this->waitForLoadingAnimation();
22
23
        $this->webDriver->findElement(
24
            WebDriverBy::cssSelector('.header-nav .nav-profile')
25
        )->click();
26
27
        $this->webDriver->findElement(
28
            WebDriverBy::cssSelector('.header-nav .nav-profile .sub-menu li.first a')
29
        )->click();
30
        $this->waitForLoadingAnimation();
31
    }
32
33
    public function testProfileDetails()
34
    {
35
        $newDetails = [
36
            'telephoneNumber' => '+4401628813588'
37
        ];
38
39
        $profileItems = $this->webDriver->findElements(
40
            WebDriverBy::cssSelector('.profile-details input')
41
        );
42
43
        $this->assertEquals(
44
            UserFixtures::$users['user-1']->getTelephoneNumber(),
45
            $profileItems[0]->getAttribute('value')
46
        );
47
48
        $profileItems[0]->clear();
49
        $profileItems[0]->sendKeys($newDetails['telephoneNumber']);
50
51
        $profileItems[count($profileItems) - 1]->click();
52
        $this->waitForLoadingAnimation();
53
54
        $this->assertEquals($newDetails['telephoneNumber'], $profileItems[0]->getAttribute('value'));
55
    }
56
57
    public function testApiKeyHidden()
58
    {
59
        $this->assertEquals(
60
            'password',
61
            $this->getApiKeyField()->getAttribute('type')
62
        );
63
    }
64
65
    public function testApiKeyVisibilityCanBeToggled()
66
    {
67
        $this->webDriver->findElement(
68
            WebDriverBy::cssSelector(".password-toggle .toggle-btn")
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal .password-toggle .toggle-btn does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
69
        )->click();
70
        $this->assertEquals(
71
            'text',
72
            $this->getApiKeyField()->getAttribute('type')
73
        );
74
75
        $this->webDriver->findElement(
76
            WebDriverBy::cssSelector(".password-toggle .toggle-btn")
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal .password-toggle .toggle-btn does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
77
        )->click();
78
        $this->assertEquals(
79
            'password',
80
            $this->getApiKeyField()->getAttribute('type')
81
        );
82
    }
83
84
    public function testApiKeyCanBeReset()
85
    {
86
        $value = $this->getApiKeyField()->getAttribute('value');
87
88
        $this->webDriver->findElement(
89
            WebDriverBy::cssSelector(".reset-api .btn-warning")
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal .reset-api .btn-warning does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
90
        )->click();
91
        $this->waitForLoadingAnimation();
92
93
        $this->assertNotEquals(
94
            $this->getApiKeyField()->getAttribute('value'),
95
            $value
96
        );
97
    }
98
99
    private function getApiKeyField()
100
    {
101
        return $this->webDriver->findElement(
102
            WebDriverBy::id('api-key')
103
        );
104
    }
105
}
106