Passed
Pull Request — master (#14)
by pablo
01:51
created

OrderConfirmation::run()   A

Complexity

Conditions 2
Paths 5

Size

Total Lines 32
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 23
c 3
b 0
f 0
dl 0
loc 32
rs 9.552
cc 2
nc 5
nop 1
1
<?php
2
3
namespace Pagantis\SeleniumFormUtils\Step;
4
5
use Facebook\WebDriver\WebDriverBy;
6
use Facebook\WebDriver\WebDriverExpectedCondition;
7
use Clearpay\Clearpay\Test\ClearpayMagentoTest;
0 ignored issues
show
Bug introduced by
The type Clearpay\Clearpay\Test\ClearpayMagentoTest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * Class OrderConfirmation
11
 *
12
 * @package Clearpay\SeleniumFormUtils\Step
13
 */
14
class OrderConfirmation extends AbstractStep
15
{
16
    /**
17
     * Handler step
18
     */
19
    const STEP = 'OrderConfirmation'
20
    ;
21
22
    /**
23
     * First step Confirm retrieved data
24
     *
25
     * @param bool $rejected
26
     * @return bool
27
     * @throws \Exception
28
     */
29
    public function run($rejected = false)
30
    {
31
        try{
32
            //Wait after redirection
33
            sleep(3);
34
            $simulatorElementSearch = WebDriverBy::id('OrderConfirmation-container');
35
            $condition  = WebDriverExpectedCondition::presenceOfElementLocated($simulatorElementSearch);
36
            $this->webDriver->wait()->until($condition);
37
        } catch (\Exception $e) {
38
            $errorElementSearch = WebDriverBy::className('technical-error-container');
39
            $condition  = WebDriverExpectedCondition::presenceOfElementLocated($errorElementSearch);
40
            $this->webDriver->wait()->until($condition);
41
            $this->assertTrue((bool) $condition, "ERROR ON ".self::STEP);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not exist on Pagantis\SeleniumFormUtils\Step\OrderConfirmation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
            $this->/** @scrutinizer ignore-call */ 
42
                   assertTrue((bool) $condition, "ERROR ON ".self::STEP);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
            return false;
43
        }
44
45
        //Click on popup
46
        sleep(3);
47
        $buttonElementSearch = WebDriverBy::name('dialogButton');
48
        $condition  = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch);
49
        $this->webDriver->wait()->until($condition);
50
        $formContinue = $this->webDriver->findElement($buttonElementSearch)->click();
0 ignored issues
show
Unused Code introduced by
The assignment to $formContinue is dead and can be removed.
Loading history...
51
        sleep(3);
52
53
        //Click on confirm
54
        $buttonElementSearch = WebDriverBy::className('button-contained-primary');
55
        $condition  = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch);
56
        $this->webDriver->wait()->until($condition);
57
        $formContinue = $this->webDriver->findElement($buttonElementSearch)->click();
58
        sleep(3);
59
60
        return false;
61
    }
62
}
63