Passed
Push — master ( c01df0...b2280f )
by Cesar
10:38 queued 06:42
created

PagantisMagentoTest::findByLinkText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pagantis\Pagantis\Test;
4
5
use Facebook\WebDriver\Remote\DesiredCapabilities;
6
use Facebook\WebDriver\Remote\RemoteWebDriver;
7
use Facebook\WebDriver\WebDriverBy;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Class pagantisMagentoTest
12
 * @package Pagantis\Test
13
 */
14
abstract class PagantisMagentoTest extends TestCase
15
{
16
    /**
17
     * Magento Backoffice URL
18
     */
19
    const BACKOFFICE_FOLDER = '/admin';
20
21
    /**
22
     * Magento Logout URL
23
     */
24
    const LOGOUT_FOLDER = '/customer/account/logout/';
25
26
    /**
27
     * Magento Checkout URL
28
     */
29
    const CHECKOUT_FOLDER = '/checkout/';
30
31
    /**
32
     * Product name
33
     */
34
    const PRODUCT_NAME = 'Fusion Backpack';
35
36
    /**
37
     * Product quantity after
38
     */
39
    const PRODUCT_QTY_AFTER = 3;
40
41
    /**
42
     * Magento checkout Title
43
     */
44
    const CHECKOUT_TITLE = 'Checkout';
45
46
    /**
47
     * Magento cart Title
48
     */
49
    const CART_TITLE = 'Cart';
50
51
    /**
52
     * Magento success title
53
     */
54
    const SUCCESS_TITLE = 'Success Page';
55
56
    /**
57
     * Magento order confirmation title
58
     */
59
    const ORDER_TITLE = 'Order #';
60
61
    /**
62
     * Pagantis Order Title
63
     */
64
    const PAGANTIS_TITLE = 'Paga+Tarde';
65
66
    /**
67
     * Already processed
68
     */
69
    const NOTFOUND_TITLE = 'Merchant order not found';
70
71
    /**
72
     * Wrong order
73
     */
74
    const NOORDER_TITLE = 'We can not get the Pagantis identification in database';
75
76
    /**
77
     * Magento Logout URL
78
     */
79
    const NOTIFICATION_FOLDER = '/pagantis/notify/';
80
81
    /**
82
     * Magento Logout URL
83
     */
84
    const NOTIFICATION_PARAMETER = 'quoteId';
85
86
    /**
87
     * Magento Log URL
88
     */
89
    const LOG_FOLDER = '/pagantis/Payment/Log';
90
91
    /**
92
     * Magento Config URL
93
     */
94
    const CONFIG_FOLDER = '/pagantis/Payment/Config';
95
96
    /**
97
     * @var array
98
     */
99
    protected $configuration = array(
100
        'backofficeUsername' => 'admin',
101
        'backofficePassword' => 'password123',
102
        'publicKey'          => 'tk_fd53cd467ba49022e4f8215e',
103
        'secretKey'          => '21e57baa97459f6a',
104
        'methodName'         => 'Pagantis',
105
        'methodTitle'        => 'Financiación instantánea',
106
        'defaultSimulatorOpt'=> 6,
107
        'defaultMinIns'      => 3,
108
        'defaultMaxIns'      => 12,
109
        'minAmount'          => 70,
110
        'username'           => '[email protected]',
111
        'password'           => 'Prestashop_demo',
112
        'firstname'          => 'John',
113
        'lastname'           => 'Döe Martinez',
114
        'email'              => null,
115
        'zip'                => '08023',
116
        'city'               => 'Barcelona',
117
        'street'             => 'Av Diagonal 585, planta 7',
118
        'phone'              => '600123123',
119
        'checkoutDescription'=> 'Paga hasta en 12'
120
    );
121
122
    /**
123
     * @var RemoteWebDriver
124
     */
125
    protected $webDriver;
126
127
    /**
128
     * Magento version provided for tests in commandline as an argument.
129
     *
130
     * @var String
131
     */
132
    protected $version;
133
134
    /**
135
     * Magento version testing url port based on magento version
136
     *
137
     * @var array
138
     */
139
    protected $versionsPort = array(
140
        '22' => '8085',
141
        '23' => '8084',
142
    );
143
144
    /**
145
     * pagantisMagentoTest constructor.
146
     */
147
    public function __construct()
148
    {
149
        if (!isset($_SERVER['argv']) ||
150
            !isset($_SERVER['argv'][4]) ||
151
            $_SERVER['argv'][4] != 'magentoVersion' ||
152
            !isset($_SERVER['argv'][6]) ||
153
            !isset($this->versionsPort[$_SERVER['argv'][6]])
154
        ) {
155
            throw new \Exception("No magentoVersion param provided or not valid for phpunit testing");
156
        }
157
158
        $this->version = $_SERVER['argv'][6];
159
        $this->configuration['magentoUrl'] = 'http://magento'.$this->version.'-test.docker:'.
160
            $this->versionsPort[$this->version].'/index.php';
161
        $this->configuration['email'] = "john.doe+".microtime(true)."@pagantis.com";
162
163
        return parent::__construct();
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::__construct() targeting PHPUnit_Framework_TestCase::__construct() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
164
    }
165
166
    /**
167
     * Configure selenium
168
     */
169
    protected function setUp()
170
    {
171
        $this->webDriver = PagantisWebDriver::create(
172
            'http://localhost:4444/wd/hub',
173
            DesiredCapabilities::chrome(),
174
            180000,
175
            180000
176
        );
177
    }
178
179
    /**
180
     * @param $name
181
     *
182
     * @return \Facebook\WebDriver\Remote\RemoteWebElement
183
     */
184
    public function findByName($name)
185
    {
186
        return $this->webDriver->findElement(WebDriverBy::name($name));
187
    }
188
189
    /**
190
     * @param $id
191
     *
192
     * @return \Facebook\WebDriver\Remote\RemoteWebElement
193
     */
194
    public function findById($id)
195
    {
196
        return $this->webDriver->findElement(WebDriverBy::id($id));
197
    }
198
199
    /**
200
     * @param $className
201
     *
202
     * @return \Facebook\WebDriver\Remote\RemoteWebElement
203
     */
204
    public function findByClass($className)
205
    {
206
        return $this->webDriver->findElement(WebDriverBy::className($className));
207
    }
208
209
    /**
210
     * @param $css
211
     *
212
     * @return \Facebook\WebDriver\Remote\RemoteWebElement
213
     */
214
    public function findByCss($css)
215
    {
216
        return $this->webDriver->findElement(WebDriverBy::cssSelector($css));
217
    }
218
219
    /**
220
     * @param $link
221
     *
222
     * @return \Facebook\WebDriver\Remote\RemoteWebElement
223
     */
224
    public function findByLinkText($link)
225
    {
226
        return $this->webDriver->findElement(WebDriverBy::linkText($link));
227
    }
228
229
    /**
230
     * @param $link
231
     *
232
     * @return \Facebook\WebDriver\Remote\RemoteWebElement
233
     */
234
    public function findByPartialLinkText($link)
235
    {
236
        return $this->webDriver->findElement(WebDriverBy::partialLinkText($link));
237
    }
238
239
    /**
240
     * Quit browser
241
     */
242
    protected function quit()
243
    {
244
        $this->webDriver->quit();
245
    }
246
}
247