|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Test\Buy; |
|
4
|
|
|
|
|
5
|
|
|
use Facebook\WebDriver\WebDriverBy; |
|
6
|
|
|
use Facebook\WebDriver\WebDriverExpectedCondition; |
|
7
|
|
|
use Test\PagantisOscommerceTest; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class AbstractBuy |
|
11
|
|
|
* @package Test\Buy |
|
12
|
|
|
*/ |
|
13
|
|
|
abstract class AbstractBuy extends PagantisOscommerceTest |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* Product name |
|
17
|
|
|
*/ |
|
18
|
|
|
const PRODUCT_NAME = 'Matrox G200 MMS'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Correct purchase message |
|
22
|
|
|
*/ |
|
23
|
|
|
const CORRECT_PURCHASE_MESSAGE = 'YOUR ORDER HAS BEEN RECEIVED.'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Canceled purchase message |
|
27
|
|
|
*/ |
|
28
|
|
|
const CANCELED_PURCHASE_MESSAGE = 'YOUR ORDER HAS BEEN CANCELED.'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Shopping cart message |
|
32
|
|
|
*/ |
|
33
|
|
|
const SHOPPING_CART_MESSAGE = 'SHOPPING CART'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Empty shopping cart message |
|
37
|
|
|
*/ |
|
38
|
|
|
const EMPTY_SHOPPING_CART = 'SHOPPING CART IS EMPTY'; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Pagantis Order Title |
|
42
|
|
|
*/ |
|
43
|
|
|
const PAGANTIS_TITLE = 'Paga+Tarde'; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Notification route |
|
47
|
|
|
*/ |
|
48
|
|
|
const NOTIFICATION_FOLDER = '/pagantis/notify'; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Buy unregistered |
|
52
|
|
|
*/ |
|
53
|
|
|
public function prepareProductAndCheckout() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->goToProductPage(); |
|
56
|
|
|
$this->addToCart(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* testAddToCart |
|
61
|
|
|
*/ |
|
62
|
|
|
public function addToCart() |
|
63
|
|
|
{ |
|
64
|
|
|
$addToCartButtonSearch = WebDriverBy::id('tdb4'); |
|
65
|
|
|
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($addToCartButtonSearch); |
|
66
|
|
|
$this->waitUntil($condition); |
|
67
|
|
|
$addToCartButtonElement = $this->webDriver->findElement($addToCartButtonSearch); |
|
68
|
|
|
$this->webDriver->executeScript("arguments[0].scrollIntoView(true);", array($addToCartButtonElement)); |
|
69
|
|
|
$addToCartButtonElement->click(); |
|
70
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
$buyButtonSearch = WebDriverBy::id('tdb5'); |
|
73
|
|
|
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($buyButtonSearch); |
|
74
|
|
|
$this->waitUntil($condition); |
|
75
|
|
|
$buyButtonElement = $this->webDriver->findElement($buyButtonSearch); |
|
76
|
|
|
$this->webDriver->executeScript("arguments[0].scrollIntoView(true);", array($buyButtonElement)); |
|
77
|
|
|
$buyButtonElement->click(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Go to the product page |
|
82
|
|
|
*/ |
|
83
|
|
|
public function goToProductPage() |
|
84
|
|
|
{ |
|
85
|
|
|
$this->webDriver->get(self::OSCURL); |
|
86
|
|
|
$productGridSearch = WebDriverBy::className('contentText'); |
|
87
|
|
|
$productLinkSearch = $productGridSearch->linkText(self::PRODUCT_NAME); |
|
88
|
|
|
|
|
89
|
|
|
$this->webDriver->wait()->until( |
|
90
|
|
|
WebDriverExpectedCondition::elementToBeClickable( |
|
91
|
|
|
$productLinkSearch |
|
92
|
|
|
) |
|
93
|
|
|
); |
|
94
|
|
|
$productLinkElement = $this->webDriver->findElement($productLinkSearch); |
|
95
|
|
|
$this->webDriver->executeScript("arguments[0].scrollIntoView(true);", array($productLinkElement)); |
|
96
|
|
|
sleep(3); |
|
97
|
|
|
$productLinkElement->click(); |
|
98
|
|
|
$this->assertSame( |
|
99
|
|
|
self::PRODUCT_NAME . ', ' . self::TITLE, |
|
100
|
|
|
$this->webDriver->getTitle() |
|
101
|
|
|
); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Fill the shipping method information |
|
106
|
|
|
*/ |
|
107
|
|
|
public function fillPaymentMethod() |
|
108
|
|
|
{ |
|
109
|
|
|
$button = WebDriverBy::xpath("//tr[@class='moduleRow']/td[2]/input[@value='pagantis']"); |
|
110
|
|
|
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($button); |
|
111
|
|
|
$this->waitUntil($condition); |
|
112
|
|
|
$this->findByXpath("//tr[@class='moduleRow']/td[2]/input[@value='pagantis']")->click(); |
|
113
|
|
|
|
|
114
|
|
|
$buttonSearch = WebDriverBy::id('tdb6'); |
|
115
|
|
|
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($buttonSearch); |
|
116
|
|
|
$this->waitUntil($condition); |
|
117
|
|
|
$buttonElement = $this->webDriver->findElement($buttonSearch); |
|
118
|
|
|
$this->webDriver->executeScript("arguments[0].scrollIntoView(true);", array($buttonElement)); |
|
119
|
|
|
$buttonElement->click(); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Fill the shipping method information |
|
124
|
|
|
*/ |
|
125
|
|
|
public function fillShippingMethod() |
|
126
|
|
|
{ |
|
127
|
|
|
$buttonSearch = WebDriverBy::id('tdb6'); |
|
128
|
|
|
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($buttonSearch); |
|
129
|
|
|
$this->waitUntil($condition); |
|
130
|
|
|
$buttonElement = $this->webDriver->findElement($buttonSearch); |
|
131
|
|
|
$this->webDriver->executeScript("arguments[0].scrollIntoView(true);", array($buttonElement)); |
|
132
|
|
|
$buttonElement->click(); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Complete order and open Pagantis (redirect or iframe methods) |
|
138
|
|
|
* |
|
139
|
|
|
* @throws \Facebook\WebDriver\Exception\NoSuchElementException |
|
140
|
|
|
* @throws \Facebook\WebDriver\Exception\TimeOutException |
|
141
|
|
|
*/ |
|
142
|
|
|
public function goToPagantis() |
|
143
|
|
|
{ |
|
144
|
|
|
$buttonSearch = WebDriverBy::id('tdb5'); |
|
145
|
|
|
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($buttonSearch); |
|
146
|
|
|
$this->waitUntil($condition); |
|
147
|
|
|
$buttonElement = $this->webDriver->findElement($buttonSearch); |
|
148
|
|
|
$this->webDriver->executeScript("arguments[0].scrollIntoView(true);", array($buttonElement)); |
|
149
|
|
|
$buttonElement->click(); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Close previous pagantis session if an user is logged in |
|
154
|
|
|
* |
|
155
|
|
|
* @throws \Facebook\WebDriver\Exception\NoSuchElementException |
|
156
|
|
|
* @throws \Facebook\WebDriver\Exception\TimeOutException |
|
157
|
|
|
*/ |
|
158
|
|
|
public function logoutFromPagantis() |
|
159
|
|
|
{ |
|
160
|
|
|
// Wait the page to render (check the simulator is rendered) |
|
161
|
|
|
$this->webDriver->wait()->until( |
|
162
|
|
|
WebDriverExpectedCondition::elementToBeClickable( |
|
163
|
|
|
WebDriverBy::name('minusButton') |
|
164
|
|
|
) |
|
165
|
|
|
); |
|
166
|
|
|
// Check if user is logged in in Pagantis |
|
167
|
|
|
$closeSession = $this->webDriver->findElements(WebDriverBy::name('one_click_return_to_normal')); |
|
168
|
|
|
if (count($closeSession) !== 0) { |
|
169
|
|
|
//Logged out |
|
170
|
|
|
$continueButtonSearch = WebDriverBy::name('one_click_return_to_normal'); |
|
171
|
|
|
$continueButtonElement = $this->webDriver->findElement($continueButtonSearch); |
|
172
|
|
|
$continueButtonElement->click(); |
|
173
|
|
|
} |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* Verify That UTF Encoding is working |
|
178
|
|
|
*/ |
|
179
|
|
|
public function verifyUTF8() |
|
180
|
|
|
{ |
|
181
|
|
|
$paymentFormElement = WebDriverBy::className('FieldsPreview-desc'); |
|
182
|
|
|
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($paymentFormElement); |
|
183
|
|
|
$this->webDriver->wait()->until($condition); |
|
184
|
|
|
$this->assertTrue((bool) $condition); |
|
185
|
|
|
$this->assertSame( |
|
186
|
|
|
$this->configuration['firstname'] . ' ' . $this->configuration['lastname'], |
|
187
|
|
|
$this->findByClass('FieldsPreview-desc')->getText() |
|
188
|
|
|
); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Check if the purchase was in the myAccount panel and with Processing status |
|
193
|
|
|
* |
|
194
|
|
|
* @param string $statusText |
|
195
|
|
|
* |
|
196
|
|
|
* @throws \Facebook\WebDriver\Exception\NoSuchElementException |
|
197
|
|
|
* @throws \Facebook\WebDriver\Exception\TimeOutException |
|
198
|
|
|
*/ |
|
199
|
|
|
public function checkLastPurchaseStatus($statusText = 'Processing') |
|
200
|
|
|
{ |
|
201
|
|
|
$accountMenu = WebDriverBy::cssSelector('.account-cart-wrapper a.skip-link.skip-account'); |
|
202
|
|
|
$this->clickElement($accountMenu); |
|
|
|
|
|
|
203
|
|
|
|
|
204
|
|
|
$myAccountMenu = WebDriverBy::cssSelector('#header-account .first a'); |
|
205
|
|
|
$this->clickElement($myAccountMenu); |
|
206
|
|
|
|
|
207
|
|
|
$this->webDriver->wait()->until( |
|
208
|
|
|
WebDriverExpectedCondition::visibilityOfElementLocated( |
|
209
|
|
|
WebDriverBy::cssSelector('.box-account.box-recent') |
|
210
|
|
|
) |
|
211
|
|
|
); |
|
212
|
|
|
|
|
213
|
|
|
$status = $this->findByCss('.box-account.box-recent .data-table.orders .first .status em')->getText(); |
|
214
|
|
|
$this->assertTrue(($status == $statusText)); |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* Check purchase return message |
|
219
|
|
|
* |
|
220
|
|
|
* @param string $message |
|
221
|
|
|
* |
|
222
|
|
|
* @throws \Facebook\WebDriver\Exception\NoSuchElementException |
|
223
|
|
|
* @throws \Facebook\WebDriver\Exception\TimeOutException |
|
224
|
|
|
*/ |
|
225
|
|
|
public function checkPurchaseReturn($message = '') |
|
226
|
|
|
{ |
|
227
|
|
|
// Check if all goes good |
|
228
|
|
|
$this->webDriver->wait()->until( |
|
229
|
|
|
WebDriverExpectedCondition::visibilityOfElementLocated( |
|
230
|
|
|
WebDriverBy::cssSelector('.page-title h1') |
|
231
|
|
|
) |
|
232
|
|
|
); |
|
233
|
|
|
$successMessage = $this->findByCss('.page-title h1'); |
|
234
|
|
|
$this->assertContains( |
|
235
|
|
|
$message, |
|
236
|
|
|
$successMessage->getText() |
|
237
|
|
|
); |
|
238
|
|
|
} |
|
239
|
|
|
} |
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.