Skip to content

Commit 6d8c02d

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-29712' into develop
2 parents 13f1ae1 + ddd3d69 commit 6d8c02d

File tree

47 files changed

+2804
-159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2804
-159
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Price.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,21 +294,23 @@ protected function escape($price, $currency = '$')
294294
* Get price excluding tax
295295
*
296296
* @param string $currency
297-
* @return string
297+
* @return string|null
298298
*/
299299
public function getPriceExcludingTax($currency = '$')
300300
{
301-
return trim($this->_rootElement->find($this->priceExcludingTax)->getText(), $currency);
301+
$priceElement = $this->_rootElement->find($this->priceExcludingTax);
302+
return $priceElement->isVisible() ? trim($priceElement->getText(), $currency) : null;
302303
}
303304

304305
/**
305306
* Get price including tax
306307
*
307308
* @param string $currency
308-
* @return string
309+
* @return string|null
309310
*/
310311
public function getPriceIncludingTax($currency = '$')
311312
{
312-
return trim($this->_rootElement->find($this->priceIncludingTax)->getText(), $currency);
313+
$priceElement = $this->_rootElement->find($this->priceIncludingTax);
314+
return $priceElement->isVisible() ? trim($priceElement->getText(), $currency) : null;
313315
}
314316
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/GroupPriceOptions.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public function getDataConfig()
6969
}
7070

7171
/**
72+
* Get preset array
73+
*
7274
* @param string $name
7375
* @return mixed|null
7476
*/

dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/CreateProductStep.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public function run()
5555
if ($product->hasData('id') === false) {
5656
$product->persist();
5757
}
58-
59-
return ['product' => $product];
58+
return ['product' => $product];
6059
}
6160
}

dev/tests/functional/tests/app/Magento/CatalogRule/Test/Repository/CatalogRule.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,16 @@ public function __construct(array $defaultConfig = [], array $defaultData = [])
8888
'simple_action' => 'By Fixed Amount',
8989
'discount_amount' => '10',
9090
];
91+
92+
$this->_data['catalog_price_rule_all_groups'] = [
93+
'name' => 'catalog_price_rule_all_groups_%isolation%',
94+
'description' => '-50% of price, Priority = 0',
95+
'is_active' => 'Active',
96+
'website_ids' => ['Main Website'],
97+
'customer_group_ids' => ['NOT LOGGED IN', 'General', 'Wholesale', 'Retailer'],
98+
'sort_order' => '0',
99+
'simple_action' => 'By Percentage of the Original Price',
100+
'discount_amount' => '50',
101+
];
91102
}
92103
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* {license_notice}
4+
*
5+
* @copyright {copyright}
6+
* @license {license_link}
7+
*/
8+
9+
namespace Magento\CatalogRule\Test\TestStep;
10+
11+
use Mtf\Fixture\FixtureFactory;
12+
use Mtf\TestStep\TestStepInterface;
13+
14+
/**
15+
* Creating catalog rule
16+
*/
17+
class CreateCatalogRuleStep implements TestStepInterface
18+
{
19+
/**
20+
* Catalog Rule dataset name
21+
*
22+
* @var string
23+
*/
24+
protected $catalogRule;
25+
26+
/**
27+
* Factory for Fixture
28+
*
29+
* @var FixtureFactory
30+
*/
31+
protected $fixtureFactory;
32+
33+
/**
34+
* Preparing step properties
35+
*
36+
* @constructor
37+
* @param FixtureFactory $fixtureFactory
38+
* @param string $catalogRule
39+
*/
40+
public function __construct(FixtureFactory $fixtureFactory, $catalogRule)
41+
{
42+
$this->fixtureFactory = $fixtureFactory;
43+
$this->catalogRule = $catalogRule;
44+
}
45+
46+
/**
47+
* Create catalog rule
48+
*
49+
* @return array
50+
*/
51+
public function run()
52+
{
53+
$result['catalogRule'] = null;
54+
if ($this->catalogRule != '-') {
55+
$catalogRule = $this->fixtureFactory->createByCode(
56+
'catalogRule',
57+
['dataSet' => $this->catalogRule]
58+
);
59+
$catalogRule->persist();
60+
$result['catalogRule'] = $catalogRule;
61+
}
62+
return $result;
63+
}
64+
}

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,27 @@ public function getProductName()
6969
/**
7070
* Get product price
7171
*
72-
* @return string
72+
* @return string|null
7373
*/
7474
public function getPrice()
7575
{
76-
$cartProductPrice = $this->_rootElement->find($this->price, Locator::SELECTOR_XPATH)->getText();
77-
return str_replace(',', '', $this->escapeCurrency($cartProductPrice));
76+
$cartProductPrice = $this->_rootElement->find($this->price, Locator::SELECTOR_XPATH);
77+
return $cartProductPrice->isVisible()
78+
? str_replace(',', '', $this->escapeCurrency($cartProductPrice->getText()))
79+
: null;
7880
}
7981

8082
/**
8183
* Get product price including tax
8284
*
83-
* @return string
85+
* @return string|null
8486
*/
8587
public function getPriceInclTax()
8688
{
87-
$cartProductPrice = $this->_rootElement->find($this->priceInclTax, Locator::SELECTOR_XPATH)->getText();
88-
return str_replace(',', '', $this->escapeCurrency($cartProductPrice));
89+
$cartProductPrice = $this->_rootElement->find($this->priceInclTax, Locator::SELECTOR_XPATH);
90+
return $cartProductPrice->isVisible()
91+
? str_replace(',', '', $this->escapeCurrency($cartProductPrice->getText()))
92+
: null;
8993
}
9094

9195
/**
@@ -112,29 +116,33 @@ public function getQty()
112116
/**
113117
* Get sub-total for the specified item in the cart
114118
*
115-
* @return string
119+
* @return string|null
116120
*/
117121
public function getSubtotalPrice()
118122
{
119-
$price = $this->_rootElement->find($this->subtotalPrice, Locator::SELECTOR_XPATH)->getText();
120-
return str_replace(',', '', $this->escapeCurrency($price));
123+
$cartProductPrice = $this->_rootElement->find($this->subtotalPrice, Locator::SELECTOR_XPATH);
124+
return $cartProductPrice->isVisible()
125+
? str_replace(',', '', $this->escapeCurrency($cartProductPrice->getText()))
126+
: null;
121127
}
122128

123129
/**
124130
* Get sub-total including tax for the specified item in the cart
125131
*
126-
* @return string
132+
* @return string|null
127133
*/
128134
public function getSubtotalPriceInclTax()
129135
{
130-
$price = $this->_rootElement->find($this->subTotalPriceInclTax, Locator::SELECTOR_XPATH)->getText();
131-
return str_replace(',', '', $this->escapeCurrency($price));
136+
$cartProductPrice = $this->_rootElement->find($this->subTotalPriceInclTax, Locator::SELECTOR_XPATH);
137+
return $cartProductPrice->isVisible()
138+
? str_replace(',', '', $this->escapeCurrency($cartProductPrice->getText()))
139+
: null;
132140
}
133141

134142
/**
135143
* Get product options in the cart
136144
*
137-
* @return string
145+
* @return array
138146
*/
139147
public function getOptions()
140148
{

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Totals extends Block
7676
*
7777
* @var string
7878
*/
79-
protected $discount = '//tr[normalize-space(th)="Discount"]//span';
79+
protected $discount = '[class=totals] .amount .price';
8080

8181
/**
8282
* Get shipping price including tax selector
@@ -95,45 +95,45 @@ class Totals extends Block
9595
/**
9696
* Get Grand Total Text
9797
*
98-
* @return array|string
98+
* @return string
9999
*/
100100
public function getGrandTotal()
101101
{
102-
$grandTotal = $this->_rootElement->find($this->grandTotal)->getText();
102+
$grandTotal = $this->_rootElement->find($this->grandTotal, Locator::SELECTOR_CSS)->getText();
103103
return $this->escapeCurrency($grandTotal);
104104
}
105105

106106
/**
107107
* Get Grand Total Text
108108
*
109-
* @return string
109+
* @return string|null
110110
*/
111111
public function getGrandTotalIncludingTax()
112112
{
113-
$grandTotal = $this->_rootElement->find($this->grandTotalInclTax, Locator::SELECTOR_CSS)->getText();
114-
return $this->escapeCurrency($grandTotal);
113+
$priceElement = $this->_rootElement->find($this->grandTotalInclTax, Locator::SELECTOR_CSS);
114+
return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null;
115115
}
116116

117117
/**
118118
* Get Grand Total Text
119119
*
120-
* @return string
120+
* @return string|null
121121
*/
122122
public function getGrandTotalExcludingTax()
123123
{
124-
$grandTotal = $this->_rootElement->find($this->grandTotalExclTax, Locator::SELECTOR_CSS)->getText();
125-
return $this->escapeCurrency($grandTotal);
124+
$priceElement = $this->_rootElement->find($this->grandTotalExclTax, Locator::SELECTOR_CSS);
125+
return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null;
126126
}
127127

128128
/**
129129
* Get Tax text from Order Totals
130130
*
131-
* @return array|string
131+
* @return string|null
132132
*/
133133
public function getTax()
134134
{
135-
$taxPrice = $this->_rootElement->find($this->tax, Locator::SELECTOR_CSS)->getText();
136-
return $this->escapeCurrency($taxPrice);
135+
$priceElement = $this->_rootElement->find($this->tax, Locator::SELECTOR_CSS);
136+
return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null;
137137
}
138138

139139
/**
@@ -153,37 +153,37 @@ public function isTaxVisible()
153153
*/
154154
public function getSubtotal()
155155
{
156-
$subTotal = $this->_rootElement->find($this->subtotal)->getText();
156+
$subTotal = $this->_rootElement->find($this->subtotal, Locator::SELECTOR_CSS)->getText();
157157
return $this->escapeCurrency($subTotal);
158158
}
159159

160160
/**
161161
* Get Subtotal text
162162
*
163-
* @return string
163+
* @return string|null
164164
*/
165165
public function getSubtotalIncludingTax()
166166
{
167-
$subTotal = $this->_rootElement->find($this->subtotalInclTax, Locator::SELECTOR_CSS)->getText();
168-
return $this->escapeCurrency($subTotal);
167+
$priceElement = $this->_rootElement->find($this->subtotalInclTax, Locator::SELECTOR_CSS);
168+
return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null;
169169
}
170170

171171
/**
172172
* Get Subtotal text
173173
*
174-
* @return string
174+
* @return string|null
175175
*/
176176
public function getSubtotalExcludingTax()
177177
{
178-
$subTotal = $this->_rootElement->find($this->subtotalExclTax, Locator::SELECTOR_CSS)->getText();
179-
return $this->escapeCurrency($subTotal);
178+
$priceElement = $this->_rootElement->find($this->subtotalExclTax, Locator::SELECTOR_CSS);
179+
return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null;
180180
}
181181

182182
/**
183183
* Method that escapes currency symbols
184184
*
185185
* @param string $price
186-
* @return string
186+
* @return string|null
187187
*/
188188
protected function escapeCurrency($price)
189189
{
@@ -194,35 +194,34 @@ protected function escapeCurrency($price)
194194
/**
195195
* Get discount
196196
*
197-
* @return string
197+
* @return string|null
198198
*/
199199
public function getDiscount()
200200
{
201-
$discount = $this->_rootElement->find($this->discount, Locator::SELECTOR_XPATH)->getText();
202-
return $this->escapeCurrency($discount);
201+
$priceElement = $this->_rootElement->find($this->discount, Locator::SELECTOR_CSS);
202+
return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null;
203203
}
204204

205205
/**
206206
* Get shipping price
207207
*
208-
* @return string
208+
* @return string|null
209209
*/
210210
public function getShippingPrice()
211211
{
212-
$shippingPrice = $this->_rootElement->find($this->shippingPriceSelector, Locator::SELECTOR_CSS)->getText();
213-
return $this->escapeCurrency($shippingPrice);
212+
$priceElement = $this->_rootElement->find($this->shippingPriceSelector, Locator::SELECTOR_CSS);
213+
return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null;
214214
}
215215

216216
/**
217217
* Get shipping price
218218
*
219-
* @return string
219+
* @return string|null
220220
*/
221221
public function getShippingPriceInclTax()
222222
{
223-
$shippingPrice = $this->_rootElement
224-
->find($this->shippingPriceInclTaxSelector, Locator::SELECTOR_CSS)->getText();
225-
return $this->escapeCurrency($shippingPrice);
223+
$priceElement = $this->_rootElement->find($this->shippingPriceInclTaxSelector, Locator::SELECTOR_CSS);
224+
return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null;
226225
}
227226

228227
/**

0 commit comments

Comments
 (0)