AbstractConfigure   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 31
c 1
b 0
f 0
dl 0
loc 65
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A loginToBackOffice() 0 25 1
A installPagantisModule() 0 19 1
A goToPagantis() 0 5 1
1
<?php
2
3
namespace Test\Configure;
4
5
use Facebook\WebDriver\WebDriverBy;
6
use Facebook\WebDriver\WebDriverExpectedCondition;
7
use Test\PagantisOscommerceTest;
8
9
/**
10
 * Class ConfigureTest
11
 * @package Test\Configure
12
 */
13
abstract class AbstractConfigure extends PagantisOscommerceTest
14
{
15
    /**
16
     * Login to the backoffice
17
     */
18
    public function loginToBackOffice()
19
    {
20
        $this->webDriver->get(self::OSCURL_BACKOFFICE);
21
        sleep(2);
22
23
        $usernameElementSearch = WebDriverBy::name('username');
24
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($usernameElementSearch);
25
        $this->waitUntil($condition);
26
27
        $this->findByName('username')->clear()->sendKeys($this->configuration['username']);
28
        $this->findByName('password')->clear()->sendKeys($this->configuration['password']);
29
30
31
        $this->webDriver->executeScript('$("#tdb1").click();');
32
33
        $loginElements = $this->webDriver->findElements(WebDriverBy::className('messageStackError'));
34
        $this->assertEquals(0, count($loginElements), "Login KO");
35
36
        $elementSearch = WebDriverBy::className('headerBar');
37
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($elementSearch);
38
        $this->waitUntil($condition);
39
40
        $text = $this->findByClass('headerBar')->getText();
41
42
        $this->assertContains('Logged in', $text, "Login OK");
43
    }
44
45
    /**
46
     * Configure PagantisModule
47
     */
48
    public function installPagantisModule()
49
    {
50
        // click on install new module
51
        $button = WebDriverBy::id('tdb1');
52
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($button);
53
        $this->waitUntil($condition);
54
        $this->findById('tdb1')->click();
55
56
        // click on Pagantis
57
        $button = WebDriverBy::xpath("//td[contains(text(), 'Pagantis')]");
58
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($button);
59
        $this->waitUntil($condition);
60
        $this->findByXpath("//td[contains(text(), 'Pagantis')]")->click();
61
62
        // Click on install module
63
        $button = WebDriverBy::id('tdb2');
64
        $condition = WebDriverExpectedCondition::visibilityOfElementLocated($button);
65
        $this->waitUntil($condition);
66
        $this->findById('tdb2')->click();
67
68
    }
69
70
    /**
71
     * Configure paylater module
72
     */
73
    public function goToPagantis()
74
    {
75
        $this->findByLinkText('Módulos')->click();
76
        sleep(1);
77
        $this->findByLinkText('Pago')->click();
78
    }
79
}