Skip to content

Commit 94e9e8b

Browse files
author
Dmytro Aponasenko
committed
Merge branch 'MTA-550' of https://github.corp.ebay.com/magento-qmt/magento2ce into develop
2 parents 8aa00fb + 9648881 commit 94e9e8b

File tree

46 files changed

+1200
-1229
lines changed

Some content is hidden

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

46 files changed

+1200
-1229
lines changed

dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,5 +510,23 @@
510510
<backend_type>virtual</backend_type>
511511
<group>websites</group>
512512
</field>
513+
<field name="cross_sell_products">
514+
<attribute_code>cross_sell_products</attribute_code>
515+
<backend_type>virtual</backend_type>
516+
<group>crosssells</group>
517+
<source>Magento\Catalog\Test\Fixture\CatalogProductSimple\CrossSellProducts</source>
518+
</field>
519+
<field name="up_sell_products">
520+
<attribute_code>up_sell_products</attribute_code>
521+
<backend_type>virtual</backend_type>
522+
<group>upsells</group>
523+
<source>Magento\Catalog\Test\Fixture\CatalogProductSimple\UpSellProducts</source>
524+
</field>
525+
<field name="related_products">
526+
<attribute_code>related_products</attribute_code>
527+
<backend_type>virtual</backend_type>
528+
<group>related-products</group>
529+
<source>Magento\Catalog\Test\Fixture\CatalogProductSimple\RelatedProducts</source>
530+
</field>
513531
</fields>
514532
</fixture>

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

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,10 @@
66

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

9-
use Magento\Mtf\Block\Block;
10-
use Magento\Mtf\Client\Locator;
11-
use Magento\Mtf\Fixture\FixtureInterface;
12-
use Magento\Mtf\Client\Element\SimpleElement;
13-
use Magento\Catalog\Test\Fixture\Product;
14-
159
/**
16-
* Class Crosssell
17-
* Crosssell product block on the page
10+
* Cross-sell product block on the checkout page.
1811
*/
19-
class Crosssell extends Block
12+
class Crosssell extends PromotedSection
2013
{
21-
/**
22-
* Link selector
23-
*
24-
* @var string
25-
*/
26-
protected $linkSelector = '.product.name [title="%s"]';
27-
28-
/**
29-
* Verify cross-sell item
30-
*
31-
* @param FixtureInterface $crosssell
32-
* @return bool
33-
*/
34-
public function verifyProductCrosssell(FixtureInterface $crosssell)
35-
{
36-
$match = $this->_rootElement->find(sprintf($this->linkSelector, $crosssell->getName()), Locator::SELECTOR_CSS);
37-
return $match->isVisible();
38-
}
39-
40-
/**
41-
* Click on cross-sell product link
42-
*
43-
* @param Product $product
44-
* @return SimpleElement
45-
*/
46-
public function clickLink($product)
47-
{
48-
$this->_rootElement->find(
49-
sprintf($this->linkSelector, $product->getName()),
50-
Locator::SELECTOR_CSS
51-
)->click();
52-
}
14+
//
5315
}

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,50 @@
1414
*/
1515
class ProductItem extends Block
1616
{
17+
/**
18+
* Link to product view page.
19+
*
20+
* @var string
21+
*/
22+
protected $link = 'a.product-item-link';
23+
1724
/**
1825
* 'Add to Card' button.
1926
*
2027
* @var string
2128
*/
2229
protected $addToCard = "button.action.tocart";
2330

31+
/**
32+
* Check whether block is visible.
33+
*
34+
* @return bool
35+
*/
36+
public function isVisible()
37+
{
38+
return $this->_rootElement->isVisible();
39+
}
40+
41+
/**
42+
* Open product view page by link.
43+
*
44+
* @return void
45+
*/
46+
public function open()
47+
{
48+
$this->_rootElement->find($this->link, Locator::SELECTOR_CSS)->click();
49+
}
50+
51+
/**
52+
* Return product name.
53+
*
54+
* @return string
55+
*/
56+
public function getProductName()
57+
{
58+
return trim($this->_rootElement->find($this->link)->getText());
59+
}
60+
2461
/**
2562
* Checking that "Add to Card" button is visible
2663
*
@@ -30,4 +67,14 @@ public function isVisibleAddToCardButton()
3067
{
3168
return $this->_rootElement->find($this->addToCard, Locator::SELECTOR_CSS)->isVisible();
3269
}
70+
71+
/**
72+
* Click by "Add to Cart" button.
73+
*
74+
* @return void
75+
*/
76+
public function clickAddToCart()
77+
{
78+
$this->_rootElement->find($this->addToCard, Locator::SELECTOR_CSS)->click();
79+
}
3380
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Block\Product\ProductList;
8+
9+
use Magento\Mtf\Block\Block;
10+
use Magento\Mtf\Client\Locator;
11+
use Magento\Mtf\Fixture\FixtureInterface;
12+
13+
/**
14+
* Base promoted products block.
15+
*/
16+
class PromotedSection extends Block
17+
{
18+
/**
19+
* Product item block.
20+
*
21+
* @var string
22+
*/
23+
protected $productItem = 'li.product-item';
24+
25+
/**
26+
* Product item block by product name.
27+
*
28+
* @var string
29+
*/
30+
protected $productItemByName = './/*[contains(@class,"product-item-link") and @title="%s"]/ancestor::li';
31+
32+
/**
33+
* Check whether block is visible.
34+
*
35+
* @return bool
36+
*/
37+
public function isVisible()
38+
{
39+
return $this->_rootElement->isVisible();
40+
}
41+
42+
/**
43+
* Return product item block.
44+
*
45+
* @param FixtureInterface $product
46+
* @return ProductItem
47+
*/
48+
public function getProductItem(FixtureInterface $product)
49+
{
50+
$locator = sprintf($this->productItemByName, $product->getName());
51+
52+
return $this->blockFactory->create(
53+
'Magento\Catalog\Test\Block\Product\ProductList\ProductItem',
54+
['element' => $this->_rootElement->find($locator, Locator::SELECTOR_XPATH)]
55+
);
56+
}
57+
58+
/**
59+
* Return list of products.
60+
*
61+
* @return ProductItem[]
62+
*/
63+
public function getProducts()
64+
{
65+
$elements = $this->_rootElement->getElements($this->productItem, Locator::SELECTOR_CSS);
66+
$result = [];
67+
68+
foreach ($elements as $element) {
69+
$result[] = $this->blockFactory->create(
70+
'Magento\Catalog\Test\Block\Product\ProductList\ProductItem',
71+
['element' => $element]
72+
);
73+
}
74+
75+
return $result;
76+
}
77+
}

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

Lines changed: 25 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,77 +6,48 @@
66

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

9-
use Magento\Mtf\Block\Block;
9+
use Magento\Catalog\Test\Block\Product\ProductList\Related\ProductItem;
1010
use Magento\Mtf\Client\Locator;
11-
use Magento\Mtf\Client\Element\SimpleElement;
11+
use Magento\Mtf\Fixture\FixtureInterface;
1212

1313
/**
14-
* Class Related
15-
* Related product block on the page
14+
* Related products section on the page.
1615
*/
17-
class Related extends Block
16+
class Related extends PromotedSection
1817
{
1918
/**
20-
* Related product locator on the page
19+
* Return product item block.
2120
*
22-
* @var string
21+
* @param FixtureInterface $product
22+
* @return ProductItem
2323
*/
24-
protected $relatedProduct = "//div[normalize-space(div//a)='%s']";
25-
26-
/**
27-
* Checking related product visibility
28-
*
29-
* @param string $productName
30-
* @return bool
31-
*/
32-
public function isRelatedProductVisible($productName)
24+
public function getProductItem(FixtureInterface $product)
3325
{
34-
return $this->getProductElement($productName)->isVisible();
35-
}
26+
$locator = sprintf($this->productItemByName, $product->getName());
3627

37-
/**
38-
* Verify that you can choose the related products
39-
*
40-
* @param string $productName
41-
* @return bool
42-
*/
43-
public function isRelatedProductSelectable($productName)
44-
{
45-
return $this->getProductElement($productName)->find("[name='related_products[]']")->isVisible();
28+
return $this->blockFactory->create(
29+
'Magento\Catalog\Test\Block\Product\ProductList\Related\ProductItem',
30+
['element' => $this->_rootElement->find($locator, Locator::SELECTOR_XPATH)]
31+
);
4632
}
4733

4834
/**
49-
* Open related product
35+
* Return list of products.
5036
*
51-
* @param string $productName
52-
* @return void
37+
* @return ProductItem[]
5338
*/
54-
public function openRelatedProduct($productName)
39+
public function getProducts()
5540
{
56-
$this->getProductElement($productName)->find('.product.name>a')->click();
57-
}
41+
$elements = $this->_rootElement->getElements($this->productItem, Locator::SELECTOR_CSS);
42+
$result = [];
5843

59-
/**
60-
* Select related product
61-
*
62-
* @param string $productName
63-
* @return void
64-
*/
65-
public function selectProductForAddToCart($productName)
66-
{
67-
$this->getProductElement($productName)
68-
->find("[name='related_products[]']", Locator::SELECTOR_CSS, 'checkbox')
69-
->setValue('Yes');
70-
}
44+
foreach ($elements as $element) {
45+
$result[] = $this->blockFactory->create(
46+
'Magento\Catalog\Test\Block\Product\ProductList\Related\ProductItem',
47+
['element' => $element]
48+
);
49+
}
7150

72-
/**
73-
* Get related product element
74-
*
75-
* @param string $productName
76-
* @return SimpleElement
77-
*/
78-
private function getProductElement($productName)
79-
{
80-
return $this->_rootElement->find(sprintf($this->relatedProduct, $productName), Locator::SELECTOR_XPATH);
51+
return $result;
8152
}
8253
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Block\Product\ProductList\Related;
8+
9+
use Magento\Mtf\Client\Locator;
10+
11+
/**
12+
* Product item block on related products section.
13+
*/
14+
class ProductItem extends \Magento\Catalog\Test\Block\Product\ProductList\ProductItem
15+
{
16+
/**
17+
* Trigger for choose related product.
18+
*
19+
* @var string
20+
*/
21+
protected $triggerChoose = "[name='related_products[]']";
22+
23+
/**
24+
* Verify that you can choose the related products.
25+
*
26+
* @return bool
27+
*/
28+
public function isSelectable()
29+
{
30+
return $this->_rootElement->find($this->triggerChoose)->isVisible();
31+
}
32+
33+
/**
34+
* Choose the related products.
35+
*
36+
* @return void
37+
*/
38+
public function select()
39+
{
40+
$this->_rootElement->find($this->triggerChoose, Locator::SELECTOR_CSS, 'checkbox')->setValue('Yes');
41+
}
42+
}

0 commit comments

Comments
 (0)