Skip to content

Commit 140b33d

Browse files
author
Oleksandr Manchenko
committed
MTA-1899: Re-factor price blocks
- Fixed Msrp, Weee modules
1 parent b5886b3 commit 140b33d

File tree

16 files changed

+122
-78
lines changed

16 files changed

+122
-78
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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\ProductList\ProductItem;
10+
use Magento\Mtf\Client\Locator;
11+
use Magento\Mtf\Fixture\FixtureInterface;
12+
13+
/**
14+
* Product list block.
15+
*/
16+
class ListProduct extends \Magento\Catalog\Test\Block\Product\ListProduct
17+
{
18+
/**
19+
* Return product item block.
20+
*
21+
* @param FixtureInterface $product
22+
* @return ProductItem
23+
*/
24+
public function getProductItem(FixtureInterface $product)
25+
{
26+
$locator = sprintf($this->productItem, $product->getName());
27+
28+
return $this->blockFactory->create(
29+
'Magento\Msrp\Test\Block\Product\ProductList\ProductItem',
30+
['element' => $this->_rootElement->find($locator, Locator::SELECTOR_XPATH)]
31+
);
32+
}
33+
}

dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/View/Map.php renamed to dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/Map.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\Msrp\Test\Block\Product\View;
7+
namespace Magento\Msrp\Test\Block\Product;
88

99
/**
1010
* Minimum Advertised Price block.
@@ -43,7 +43,7 @@ class Map extends \Magento\Catalog\Test\Block\AbstractPriceBlock
4343
* Get actual Price value on frontend.
4444
*
4545
* @param string $currency
46-
* @return null|string
46+
* @return string|null
4747
*/
4848
public function getActualPrice($currency = '$')
4949
{
@@ -54,7 +54,7 @@ public function getActualPrice($currency = '$')
5454
* Get old Price value on frontend.
5555
*
5656
* @param string $currency
57-
* @return null|string
57+
* @return string|null
5858
*/
5959
public function getOldPrice($currency = '$')
6060
{

dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Category/View.php renamed to dev/tests/functional/tests/app/Magento/Msrp/Test/Block/Product/ProductList/ProductItem.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\Msrp\Test\Block\Category;
7+
namespace Magento\Msrp\Test\Block\Product\ProductList;
88

9-
use Magento\Msrp\Test\Block\Product\View\Map;
10-
use Magento\Mtf\Block\Block;
9+
use Magento\Msrp\Test\Block\Product\Map;
1110
use Magento\Mtf\Client\Locator;
12-
use Magento\Mtf\Fixture\FixtureInterface;
1311

1412
/**
15-
* Category view block on the category page.
13+
* Product item block on frontend category view.
1614
*/
17-
class View extends Block
15+
class ProductItem extends \Magento\Catalog\Test\Block\Product\ProductList\ProductItem
1816
{
1917
/**
2018
* Click for Price link.
2119
*
2220
* @var string
2321
*/
24-
protected $mapLink = './/*[@class="product-item-info" and contains(.,"%s")]//*[contains(@class,"map-show-info")]';
22+
protected $mapLink = '.map-show-info';
2523

2624
/**
2725
* Popup MAP Block.
@@ -33,12 +31,11 @@ class View extends Block
3331
/**
3432
* Open MAP block.
3533
*
36-
* @param FixtureInterface $product
3734
* @return void
3835
*/
39-
public function openMapBlock(FixtureInterface $product)
36+
public function openMapBlock()
4037
{
41-
$this->_rootElement->find(sprintf($this->mapLink, $product->getName()), Locator::SELECTOR_XPATH)->click();
38+
$this->_rootElement->find($this->mapLink)->click();
4239
$this->waitForElementVisible($this->mapPopupBlock, Locator::SELECTOR_XPATH);
4340
}
4441

@@ -50,7 +47,7 @@ public function openMapBlock(FixtureInterface $product)
5047
public function getMapBlock()
5148
{
5249
return $this->blockFactory->create(
53-
'Magento\Msrp\Test\Block\Product\View\Map',
50+
'Magento\Msrp\Test\Block\Product\Map',
5451
['element' => $this->_rootElement->find($this->mapPopupBlock, Locator::SELECTOR_XPATH)]
5552
);
5653
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66

77
namespace Magento\Msrp\Test\Block\Product;
88

9-
use Magento\Msrp\Test\Block\Product\View\Map;
10-
use Magento\Mtf\Block\Block;
119
use Magento\Mtf\Client\Locator;
1210

1311
/**
1412
* Product view block on the product page.
1513
*/
16-
class View extends Block
14+
class View extends \Magento\Catalog\Test\Block\Product\View
1715
{
1816
/**
1917
* Click for Price link on Product page.
@@ -48,7 +46,7 @@ public function openMapBlock()
4846
public function getMapBlock()
4947
{
5048
return $this->blockFactory->create(
51-
'Magento\Msrp\Test\Block\Product\View\Map',
49+
'Magento\Msrp\Test\Block\Product\Map',
5250
['element' => $this->_rootElement->find($this->mapPopupBlock, Locator::SELECTOR_XPATH)]
5351
);
5452
}

dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpInShoppingCart.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public function processAssert(
4444
if ($product->hasData('checkout_data')) {
4545
$catalogProductView->getViewBlock()->addToCart($product);
4646
} else {
47-
$catalogProductView->getMapViewBlock()->openMapBlock();
48-
$catalogProductView->getMapViewBlock()->getMapBlock()->addToCart();
47+
$catalogProductView->getMsrpViewBlock()->openMapBlock();
48+
$catalogProductView->getMsrpViewBlock()->getMapBlock()->addToCart();
4949
}
5050
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
5151

dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnCategoryPage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function processAssert(
3434
$cmsIndex->open();
3535
$cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
3636

37-
$productBlock = $catalogCategoryView->getListProductBlock()->getProductItem($product);
37+
$productBlock = $catalogCategoryView->getMsrpListProductBlock()->getProductItem($product);
3838
\PHPUnit_Framework_Assert::assertTrue(
3939
$productBlock->isVisible(),
4040
'Product is invisible on Category page.'
@@ -51,8 +51,8 @@ public function processAssert(
5151
'Regular price on Category page is visible and not expected.'
5252
);
5353

54-
$catalogCategoryView->getMapViewBlock()->openMapBlock($product);
55-
$mapBlock = $catalogCategoryView->getMapViewBlock()->getMapBlock();
54+
$productBlock->openMapBlock();
55+
$mapBlock = $productBlock->getMapBlock();
5656
\PHPUnit_Framework_Assert::assertEquals(
5757
$product->getMsrp(),
5858
$mapBlock->getOldPrice(),

dev/tests/functional/tests/app/Magento/Msrp/Test/Constraint/AssertMsrpOnProductView.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public function processAssert(
3838
$cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
3939
$catalogCategoryView->getListProductBlock()->getProductItem($product)->open();
4040

41-
$priceBlock = $catalogProductView->getViewBlock()->getPriceBlock();
41+
$viewBlock = $catalogProductView->getMsrpViewBlock();
42+
$priceBlock = $viewBlock->getPriceBlock();
4243
\PHPUnit_Framework_Assert::assertEquals(
4344
$product->getMsrp(),
4445
$priceBlock->getOldPrice(),
@@ -49,8 +50,8 @@ public function processAssert(
4950
'Regular price on Product view page is visible and not expected.'
5051
);
5152

52-
$catalogProductView->getMapViewBlock()->openMapBlock();
53-
$mapBlock = $catalogProductView->getMapViewBlock()->getMapBlock();
53+
$viewBlock->openMapBlock();
54+
$mapBlock = $viewBlock->getMapBlock();
5455
\PHPUnit_Framework_Assert::assertContains(
5556
$product->getMsrp(),
5657
$mapBlock->getOldPrice(),

dev/tests/functional/tests/app/Magento/Msrp/Test/Page/Category/CatalogCategoryView.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd">
99
<page name="CatalogCategoryView" area="Category" mca="catalog/category/view" module="Magento_Catalog">
10-
<block name="mapViewBlock" class="Magento\Msrp\Test\Block\Category\View" locator="#maincontent" strategy="css selector"/>
10+
<block name="msrpListProductBlock" class="Magento\Msrp\Test\Block\Product\ListProduct" locator=".products.wrapper.grid" strategy="css selector"/>
1111
</page>
1212
</config>

dev/tests/functional/tests/app/Magento/Msrp/Test/Page/Product/CatalogProductView.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd">
99
<page name="CatalogProductView" area="Product" mca="catalog/product/view" module="Magento_Catalog">
10-
<block name="mapViewBlock" class="Magento\Msrp\Test\Block\Product\View" locator="#maincontent" strategy="css selector"/>
10+
<block name="msrpViewBlock" class="Magento\Msrp\Test\Block\Product\View" locator="#maincontent" strategy="css selector"/>
1111
</page>
1212
</config>

dev/tests/functional/tests/app/Magento/Weee/Test/Block/Category/View.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)