GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( c903c8...24a7f8 )
by Kevin
06:19 queued 03:16
created

BillingAddress::preExecute()   C

Complexity

Conditions 7
Paths 16

Size

Total Lines 23
Code Lines 12

Duplication

Lines 8
Ratio 34.78 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 23
rs 6.7272
cc 7
eloc 12
nc 16
nop 0
1
<?php
2
3
namespace Magium\Magento\Actions\Checkout\Steps;
4
5
use Facebook\WebDriver\WebDriverExpectedCondition;
6
use Magium\Magento\AbstractMagentoTestCase;
7
use Magium\Magento\Identities\Customer;
8
use Magium\Magento\Themes\OnePageCheckout\AbstractThemeConfiguration;
9
use Magium\WebDriver\WebDriver;
10
11
class BillingAddress implements StepInterface
12
{
13
    const ACTION = 'Checkout\Steps\BillingAddress';
14
15
    protected $webdriver;
16
    protected $theme;
17
    protected $customerIdentity;
18
    protected $testCase;
19
    protected $shipToDifferentAddress;
20
21
    protected $enterNewAddress;
22
    protected $bypass = [];
23
    
24
    public function __construct(
25
        WebDriver                   $webdriver,
26
        AbstractThemeConfiguration          $theme,
27
        Customer            $customerIdentity,
28
        AbstractMagentoTestCase     $testCase
29
    ) {
30
        $this->webdriver        = $webdriver;
31
        $this->theme            = $theme;
32
        $this->customerIdentity = $customerIdentity;
33
        $this->testCase         = $testCase;
34
    }
35
36
    /**
37
     * Allows you to bypass arbitrary element assertions and entry.  Currently only supports email address.
38
     *
39
     * @see Magium\Magento\Actions\Checkout\Steps\CustomerBillingAddress
40
     *
41
     * @param $element The name of the element
42
     */
43
44
    public function bypassElement($element)
45
    {
46
        $this->bypass[] = $element;
47
    }
48
49
    public function shipToDifferentAddress($ship = true)
50
    {
51
        $this->shipToDifferentAddress = $ship;
52
    }
53
54
    public function enterNewAddress($newAddress = true)
55
    {
56
        $this->enterNewAddress = $newAddress;
57
    }
58
59
    protected function preExecute()
60
    {
61
        if ($this->enterNewAddress & $this->webdriver->elementDisplayed($this->theme->getBillingNewAddressXpath(), WebDriver::BY_XPATH)) {
62
            $this->webdriver->byXpath($this->theme->getBillingNewAddressXpath())->click();
63
        }
64
65
        if ($this->shipToDifferentAddress) {
66 View Code Duplication
            if ($this->webdriver->elementExists($this->theme->getDoNotUseBillingAddressForShipping(), WebDriver::BY_XPATH)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
67
                $this->webdriver->byXpath($this->theme->getDoNotUseBillingAddressForShipping())->click();
68
            }
69 View Code Duplication
        } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
70
            if ($this->webdriver->elementExists($this->theme->getUseBillingAddressForShipping(), WebDriver::BY_XPATH)) {
71
                $this->webdriver->byXpath($this->theme->getUseBillingAddressForShipping())->click();
72
            }
73
        }
74
75
        if (!$this->enterNewAddress && $this->webdriver->elementDisplayed($this->theme->getBillingAddressDropdownXpath(), WebDriver::BY_XPATH)) {
76
            // We're logged in and we have an address.
77
78
            return true;
79
        }
80
        return false;
81
    }
82
83
    public function execute()
84
    {
85
        if ($this->preExecute()) {
86
            return true;
87
        }
88
89 View Code Duplication
        if ($this->theme->getBillingEmailAddressXpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
90
            $this->testCase->byXpath($this->theme->getBillingEmailAddressXpath())->clear();
91
            $this->testCase->byXpath($this->theme->getBillingEmailAddressXpath())->sendKeys($this->customerIdentity->getEmailAddress());
92
        }
93 View Code Duplication
        if ($this->theme->getBillingFirstNameXpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
94
            $this->testCase->byXpath($this->theme->getBillingFirstNameXpath())->clear();
95
            $this->testCase->byXpath($this->theme->getBillingFirstNameXpath())->sendKeys($this->customerIdentity->getBillingFirstName());
96
        }
97
98 View Code Duplication
        if ($this->theme->getBillingLastNameXpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
99
            $this->testCase->byXpath($this->theme->getBillingLastNameXpath())->clear();
100
            $this->testCase->byXpath($this->theme->getBillingLastNameXpath())->sendKeys($this->customerIdentity->getBillingLastName());
101
        }
102
103 View Code Duplication
        if ($this->theme->getBillingCompanyXpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
104
            $this->testCase->byXpath($this->theme->getBillingCompanyXpath())->clear();
105
            $this->testCase->byXpath($this->theme->getBillingCompanyXpath())->sendKeys($this->customerIdentity->getBillingCompany());
106
        }
107
108 View Code Duplication
        if ($this->theme->getBillingAddressXpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
109
            $this->testCase->byXpath($this->theme->getBillingAddressXpath())->clear();
110
            $this->testCase->byXpath($this->theme->getBillingAddressXpath())->sendKeys($this->customerIdentity->getBillingAddress());
111
        }
112
113 View Code Duplication
        if ($this->theme->getBillingAddress2Xpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
114
            $this->testCase->byXpath($this->theme->getBillingAddress2Xpath())->clear();
115
            $this->testCase->byXpath($this->theme->getBillingAddress2Xpath())->sendKeys($this->customerIdentity->getBillingAddress2());
116
        }
117
118 View Code Duplication
        if ($this->theme->getBillingCityXpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
119
            $this->testCase->byXpath($this->theme->getBillingCityXpath())->clear();
120
            $this->testCase->byXpath($this->theme->getBillingCityXpath())->sendKeys($this->customerIdentity->getBillingCity());
121
        }
122
123
        $regionXpath = $this->theme->getBillingRegionIdXpath($this->customerIdentity->getBillingRegionId());
124
        if ($regionXpath) {
125
            $this->testCase->byXpath($regionXpath)->click();
126
        }
127
128 View Code Duplication
        if ($this->theme->getBillingPostCodeXpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
129
            $this->testCase->byXpath($this->theme->getBillingPostCodeXpath())->clear();
130
            $this->testCase->byXpath($this->theme->getBillingPostCodeXpath())->sendKeys($this->customerIdentity->getBillingPostCode());
131
        }
132
133
        $countryXpath = $this->theme->getBillingCountryIdXpath($this->customerIdentity->getBillingCountryId());
134
        if ($countryXpath) {
135
            $this->testCase->byXpath($countryXpath)->click();
136
        }
137
138 View Code Duplication
        if ($this->theme->getBillingTelephoneXpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
139
            $this->testCase->byXpath($this->theme->getBillingTelephoneXpath())->clear();
140
            $this->testCase->byXpath($this->theme->getBillingTelephoneXpath())->sendKeys($this->customerIdentity->getBillingTelephone());
141
        }
142
143 View Code Duplication
        if ($this->theme->getBillingFaxXpath()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
144
            $this->testCase->byXpath($this->theme->getBillingFaxXpath())->clear();
145
            $this->testCase->byXpath($this->theme->getBillingFaxXpath())->sendKeys($this->customerIdentity->getBillingFax());
146
        }
147
148
        return true;
149
    }
150
151
152 View Code Duplication
    public function nextAction()
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...
153
    {
154
        $this->testCase->byXpath($this->theme->getBillingContinueButtonXpath())->click();
155
156
        $this->webdriver->wait()->until(WebDriverExpectedCondition::not(WebDriverExpectedCondition::visibilityOf($this->webdriver->byXpath($this->theme->getBillingContinueCompletedXpath()))));
157
        return true;
158
    }
159
}