Passed
Pull Request — master (#16)
by
unknown
04:38
created

PaylaterMgInstallTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 37
dl 0
loc 61
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPaylaterMg21InstallTest() 0 6 1
A configurePaylater() 0 43 4
1
<?php
2
3
namespace DigitalOrigin\Pmt\Test\Install;
4
5
use DigitalOrigin\Pmt\Test\Common\AbstractMg21Selenium;
6
use Facebook\WebDriver\WebDriverExpectedCondition;
7
use Facebook\WebDriver\WebDriverBy;
8
9
/**
10
 * Class PaylaterMgInstallTest
11
 * @package DigitalOrigin\Test\Install
12
 *
13
 * @group magento-install
14
 */
15
class PaylaterMgInstallTest extends AbstractMg21Selenium
16
{
17
    /**
18
     * @throws \Exception
19
     */
20
    public function testPaylaterMg21InstallTest()
21
    {
22
        $this->loginToBackOffice();
23
        $this->getPaylaterBackOffice();
24
        $this->configurePaylater();
25
        $this->quit();
26
    }
27
28
    /**
29
     * @require getPaylaterBackOffice
30
     *
31
     * @throws \Exception
32
     */
33
    private function configurePaylater()
34
    {
35
        $verify = WebDriverBy::id('payment_us_paylater_pmt_public_key');
36
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($verify);
37
        $this->webDriver->wait()->until($condition);
38
        $this->assertTrue((bool) $condition, "PR5");
39
40
        $verify = WebDriverBy::id('payment_us_paylater_pmt_private_key');
41
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($verify);
42
        $this->webDriver->wait()->until($condition);
43
        $this->assertTrue((bool) $condition, "PR5");
44
45
        $activeSelect = $this->findById('payment_us_paylater_active');
46
        $activeOptions = $activeSelect->findElements(WebDriverBy::xpath('option'));
47
        foreach ($activeOptions as $activeOption) {
48
            if ($activeOption->getText() == 'Yes') {
49
                $activeOption->click();
50
                break;
51
            }
52
        }
53
        $this->findById('payment_us_paylater_pmt_public_key')->clear()->sendKeys($this->configuration['publicKey']);
54
        $this->findById('payment_us_paylater_pmt_private_key')->clear()->sendKeys($this->configuration['secretKey']);
55
56
        $this->findById('payment_us_paylater_title')->clear()->sendKeys($this->configuration['methodName']);
57
        $simulatorCss = "option[value='".$this->configuration['defaultSimulatorOpt']."']";
58
        $this->webDriver->findElement(WebDriverBy::id('payment_us_paylater_product_simulator'))
59
                        ->findElement(WebDriverBy::cssSelector($simulatorCss))
60
                        ->click();
61
62
        $this->findById('config-edit-form')->submit();
63
64
        $validatorSearch = WebDriverBy::className('message-success');
65
        $actualString = $this->webDriver->findElement($validatorSearch)->getText();
66
        $compareString = (strstr($actualString, 'You saved the configuration')) === false ? false : true;
67
        $this->assertTrue($compareString, $actualString);
68
69
        $enabledModule = $this->findByCss("select#payment_us_paylater_active > option[selected]");
70
        $this->assertEquals($enabledModule->getText(), 'Yes', 'PR6');
71
72
        $verify = WebDriverBy::id('payment_us_paylater_active');
73
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($verify);
74
        $this->webDriver->wait()->until($condition);
75
        $this->assertTrue((bool) $condition, "PR7");
76
    }
77
}
78