Skip to content

Commit b5886b3

Browse files
author
Oleksandr Manchenko
committed
MTA-1899: Re-factor price blocks
- Fixed logical and code style errors
1 parent 40adef7 commit b5886b3

File tree

26 files changed

+284
-257
lines changed

26 files changed

+284
-257
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/AbstractPriceBlock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract class AbstractPriceBlock extends Block
3232
protected function getTypePrice($type, $currency = '$')
3333
{
3434
$typePriceElement = $this->getTypePriceElement($type);
35-
return $typePriceElement->isVisible() ? $this->escape($typePriceElement->getText(), $currency) : null;
35+
return $typePriceElement->isVisible() ? $this->trimPrice($typePriceElement->getText(), $currency) : null;
3636
}
3737

3838
/**
@@ -57,7 +57,7 @@ protected function getTypePriceElement($type)
5757
* @param string $currency
5858
* @return string
5959
*/
60-
protected function escape($price, $currency = '$')
60+
protected function trimPrice($price, $currency = '$')
6161
{
6262
return str_replace([',', $currency], '', $price);
6363
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function getPriceExcludingTax($currency = '$')
129129
*/
130130
public function getPriceIncludingTax($currency = '$')
131131
{
132-
return $this->getTypePrice('price_including_tax'. $currency);
132+
return $this->getTypePrice('price_including_tax', $currency);
133133
}
134134

135135
/**

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\Catalog\Test\Block\Product\ProductList;
88

9-
use Magento\Catalog\Test\Block\Product\Map;
109
use Magento\Catalog\Test\Block\Product\Price;
1110
use Magento\Mtf\Block\Block;
1211
use Magento\Mtf\Client\Locator;
@@ -30,20 +29,6 @@ class ProductItem extends Block
3029
*/
3130
protected $priceBox = '.price-box';
3231

33-
/**
34-
* Click for Price link.
35-
*
36-
* @var string
37-
*/
38-
protected $mapLink = ".map-show-info";
39-
40-
/**
41-
* Popup map price.
42-
*
43-
* @var string
44-
*/
45-
protected $mapPopupBlock = '//ancestor::*[@id="map-popup-click-for-price"]/..';
46-
4732
/**
4833
* 'Add to Card' button.
4934
*
@@ -113,28 +98,4 @@ public function getPriceBlock()
11398
['element' => $this->_rootElement->find($this->priceBox)]
11499
);
115100
}
116-
117-
/**
118-
* Open MAP block.
119-
*
120-
* @return void
121-
*/
122-
public function openMapBlock()
123-
{
124-
$this->_rootElement->find($this->mapLink)->click();
125-
$this->waitForElementVisible($this->mapPopupBlock, Locator::SELECTOR_XPATH);
126-
}
127-
128-
/**
129-
* Return MAP block.
130-
*
131-
* @return Map
132-
*/
133-
public function getMapBlock()
134-
{
135-
return $this->blockFactory->create(
136-
'Magento\Catalog\Test\Block\Product\Map',
137-
['element' => $this->_rootElement->find($this->mapPopupBlock, Locator::SELECTOR_XPATH)]
138-
);
139-
}
140101
}

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

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,6 @@ class View extends AbstractConfigureBlock
8484
*/
8585
protected $productShortDescription = '.product.attibute.overview';
8686

87-
/**
88-
* Click for Price link on Product page.
89-
*
90-
* @var string
91-
*/
92-
protected $clickForPrice = '[id*=msrp-popup]';
93-
94-
/**
95-
* MAP popup on Product page.
96-
*
97-
* @var string
98-
*/
99-
protected $mapPopupBlock = '//ancestor::*[@id="map-popup-click-for-price"]/..';
100-
10187
/**
10288
* Stock Availability control.
10389
*
@@ -245,26 +231,6 @@ public function getProductSku()
245231
return $this->_rootElement->find($this->productSku, Locator::SELECTOR_CSS)->getText();
246232
}
247233

248-
/**
249-
* Return product price excluding tax displayed on page.
250-
*
251-
* @return string
252-
*/
253-
public function getProductPriceExcludingTax()
254-
{
255-
return $this->getPriceBlock()->getPriceExcludingTax();
256-
}
257-
258-
/**
259-
* Return product price including tax displayed on page.
260-
*
261-
* @return string
262-
*/
263-
public function getProductPriceIncludingTax()
264-
{
265-
return $this->getPriceBlock()->getPriceIncludingTax();
266-
}
267-
268234
/**
269235
* Return product short description on page.
270236
*
@@ -332,30 +298,6 @@ public function clickAddToCartButton()
332298
$this->_rootElement->find($this->addToCart, Locator::SELECTOR_CSS)->click();
333299
}
334300

335-
/**
336-
* Open MAP block on Product View page.
337-
*
338-
* @return void
339-
*/
340-
public function openMapBlock()
341-
{
342-
$this->_rootElement->find($this->clickForPrice, Locator::SELECTOR_CSS)->click();
343-
$this->waitForElementVisible($this->mapPopupBlock, Locator::SELECTOR_XPATH);
344-
}
345-
346-
/**
347-
* Return MAP block.
348-
*
349-
* @return Map
350-
*/
351-
public function getMapBlock()
352-
{
353-
return $this->blockFactory->create(
354-
'Magento\Catalog\Test\Block\Product\Map',
355-
['element' => $this->_rootElement->find($this->mapPopupBlock, Locator::SELECTOR_XPATH)]
356-
);
357-
}
358-
359301
/**
360302
* Check 'Add to card' button visible.
361303
*

dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedCatalogPage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function processAssert(
4646
$categoryName = $product->getCategoryIds()[0];
4747
$cmsIndexPage->getTopmenu()->selectCategoryByName($categoryName);
4848
$priceBlock = $catalogCategoryViewPage->getListProductBlock()->getProductItem($product)->getPriceBlock();
49-
$actualPrice['regular'] = $priceBlock->getPrice();
49+
$actualPrice['regular'] = $priceBlock->getOldPrice();
5050
$actualPrice['special'] = $priceBlock->getSpecialPrice();
5151
$actualPrice['discount_amount'] = $actualPrice['regular'] - $actualPrice['special'];
5252
$diff = $this->verifyData($actualPrice, $productPrice[$key]);

dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedProductPage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function processAssert(
4848
$cmsIndexPage->getTopmenu()->selectCategoryByName($categoryName);
4949
$catalogCategoryViewPage->getListProductBlock()->getProductItem($product)->open();
5050
$productPriceBlock = $catalogProductViewPage->getViewBlock()->getPriceBlock();
51-
$actualPrice['regular'] = $productPriceBlock->getPrice();
51+
$actualPrice['regular'] = $productPriceBlock->getOldPrice();
5252
$actualPrice['special'] = $productPriceBlock->getSpecialPrice();
5353
$actualPrice['discount_amount'] = $actualPrice['regular'] - $actualPrice['special'];
5454
$diff = $this->verifyData($actualPrice, $productPrice[$key]);

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,8 @@ protected function createNewVariationSet(array $attribute)
165165
);
166166

167167
$this->_rootElement->find($this->createNewVariationSet)->click();
168-
$newAttribute = $this->getEditAttributeForm();
169-
$newAttribute->fill($attributeFixture);
170-
$newAttribute->_rootElement->find($this->saveAttribute)->click();
171-
172-
$this->browser->switchToFrame();
168+
$this->getEditAttributeForm()->fill($attributeFixture);
169+
$this->getEditAttributeForm()->saveAttributeForm();
173170
}
174171

175172
/**

dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public function getCategoryPrices(FixtureInterface $product, $actualPrices)
4545
*/
4646
public function getProductPagePrices($actualPrices)
4747
{
48-
$viewBlock = $this->catalogProductView->getViewBlock();
49-
$actualPrices['product_view_price_excl_tax'] = $viewBlock->getProductPriceExcludingTax();
50-
$actualPrices['product_view_price_incl_tax'] = $viewBlock->getProductPriceIncludingTax();
48+
$priceBlock = $this->catalogProductView->getViewBlock()->getPriceBlock();
49+
$actualPrices['product_view_price_excl_tax'] = $priceBlock->getPriceExcludingTax();
50+
$actualPrices['product_view_price_incl_tax'] = $priceBlock->getPriceIncludingTax();
5151

5252
return $actualPrices;
5353
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Msrp\Test\Block\Category;
8+
9+
use Magento\Msrp\Test\Block\Product\View\Map;
10+
use Magento\Mtf\Block\Block;
11+
use Magento\Mtf\Client\Locator;
12+
use Magento\Mtf\Fixture\FixtureInterface;
13+
14+
/**
15+
* Category view block on the category page.
16+
*/
17+
class View extends Block
18+
{
19+
/**
20+
* Click for Price link.
21+
*
22+
* @var string
23+
*/
24+
protected $mapLink = './/*[@class="product-item-info" and contains(.,"%s")]//*[contains(@class,"map-show-info")]';
25+
26+
/**
27+
* Popup MAP Block.
28+
*
29+
* @var string
30+
*/
31+
protected $mapPopupBlock = '//ancestor::*[@id="map-popup-click-for-price"]/..';
32+
33+
/**
34+
* Open MAP block.
35+
*
36+
* @param FixtureInterface $product
37+
* @return void
38+
*/
39+
public function openMapBlock(FixtureInterface $product)
40+
{
41+
$this->_rootElement->find(sprintf($this->mapLink, $product->getName()), Locator::SELECTOR_XPATH)->click();
42+
$this->waitForElementVisible($this->mapPopupBlock, Locator::SELECTOR_XPATH);
43+
}
44+
45+
/**
46+
* Return MAP block.
47+
*
48+
* @return Map
49+
*/
50+
public function getMapBlock()
51+
{
52+
return $this->blockFactory->create(
53+
'Magento\Msrp\Test\Block\Product\View\Map',
54+
['element' => $this->_rootElement->find($this->mapPopupBlock, Locator::SELECTOR_XPATH)]
55+
);
56+
}
57+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Msrp\Test\Block\Product;
8+
9+
use Magento\Msrp\Test\Block\Product\View\Map;
10+
use Magento\Mtf\Block\Block;
11+
use Magento\Mtf\Client\Locator;
12+
13+
/**
14+
* Product view block on the product page.
15+
*/
16+
class View extends Block
17+
{
18+
/**
19+
* Click for Price link on Product page.
20+
*
21+
* @var string
22+
*/
23+
protected $clickForPrice = '[id*=msrp-popup]';
24+
25+
/**
26+
* MAP popup on Product page.
27+
*
28+
* @var string
29+
*/
30+
protected $mapPopupBlock = '//ancestor::*[@id="map-popup-click-for-price"]/..';
31+
32+
/**
33+
* Open MAP block on Product View page.
34+
*
35+
* @return void
36+
*/
37+
public function openMapBlock()
38+
{
39+
$this->_rootElement->find($this->clickForPrice, Locator::SELECTOR_CSS)->click();
40+
$this->waitForElementVisible($this->mapPopupBlock, Locator::SELECTOR_XPATH);
41+
}
42+
43+
/**
44+
* Return MAP block.
45+
*
46+
* @return Map
47+
*/
48+
public function getMapBlock()
49+
{
50+
return $this->blockFactory->create(
51+
'Magento\Msrp\Test\Block\Product\View\Map',
52+
['element' => $this->_rootElement->find($this->mapPopupBlock, Locator::SELECTOR_XPATH)]
53+
);
54+
}
55+
}

0 commit comments

Comments
 (0)