Skip to content

Commit f735796

Browse files
author
Dmytro Aponasenko
committed
Merge branch 'MTA-2480' of https://github.corp.ebay.com/magento-qmt/magento2ce into develop
2 parents 0c4d56f + 94ad2e8 commit f735796

File tree

18 files changed

+548
-30
lines changed

18 files changed

+548
-30
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Block\Cache;
8+
9+
use Magento\Backend\Test\Block\Widget\Grid as ParentGrid;
10+
11+
/**
12+
* Backend Cache Management grid.
13+
*/
14+
class Grid extends ParentGrid
15+
{
16+
/**
17+
* Search for item and select it
18+
*
19+
* @param array $filter
20+
* @throws \Exception
21+
*/
22+
public function searchAndSelect(array $filter)
23+
{
24+
$selectItem = $this->getRow($filter, false)->find($this->selectItem);
25+
if ($selectItem->isVisible()) {
26+
$selectItem->click();
27+
} else {
28+
throw new \Exception('Searched item was not found.');
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Constraint;
8+
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Backend\Test\Page\Adminhtml\AdminCache;
11+
12+
/**
13+
* Assert Cache is Invalidated and Refreshable.
14+
*/
15+
class AssertCacheIsRefreshableAndInvalidated extends AbstractConstraint
16+
{
17+
/**
18+
* Success message of refreshed cache.
19+
*/
20+
const SUCCESS_MESSAGE = '%d cache type(s) refreshed.';
21+
22+
/**
23+
* Assert Cache is Invalidated and Refreshable.
24+
*
25+
* @param AdminCache $adminCache
26+
* @param array $cacheTags
27+
* @return void
28+
*/
29+
public function processAssert(AdminCache $adminCache, $cacheTags)
30+
{
31+
$items = [];
32+
foreach ($cacheTags as $cacheTag) {
33+
$items[] = [
34+
'tags' => $cacheTag,
35+
'status' => 'Invalidated'
36+
];
37+
}
38+
39+
$adminCache->open();
40+
$adminCache->getGridBlock()->massaction($items, 'Refresh');
41+
42+
\PHPUnit_Framework_Assert::assertEquals(
43+
sprintf(self::SUCCESS_MESSAGE, count($items)),
44+
$adminCache->getMessagesBlock()->getSuccessMessages(),
45+
'Cache is Invalid and refreshable.'
46+
);
47+
}
48+
49+
/**
50+
* Returns a string representation of the object.
51+
*
52+
* @return string
53+
*/
54+
public function toString()
55+
{
56+
return 'Cache is not Invalid or not refreshable.';
57+
}
58+
}

dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages .messages" strategy="css selector"/>
1111
<block name="actionsBlock" class="Magento\Backend\Test\Block\Cache" locator="div.page-actions" strategy="css selector"/>
1212
<block name="additionalBlock" class="Magento\Backend\Test\Block\Cache\Additional" locator="div.additional-cache-management" strategy="css selector"/>
13+
<block name="gridBlock" class="Magento\Backend\Test\Block\Cache\Grid" locator="div#cache_grid" strategy="css selector"/>
1314
</page>
1415
</config>

dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface
5858
*/
5959
public function persist(FixtureInterface $fixture = null)
6060
{
61+
if ($fixture->hasData('attribute_id')) {
62+
return ['attribute_id' => $fixture->getData('attribute_id')];
63+
}
6164
$data = $this->replaceMappingData($fixture->getData());
6265
$data['frontend_label'] = [0 => $data['frontend_label']];
6366

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,46 @@
1313
<field name="is_required" xsi:type="string">No</field>
1414
</dataset>
1515

16+
<dataset name="quantity_and_stock_status">
17+
<field name="attribute_id" xsi:type="number">113</field>
18+
<field name="frontend_label" xsi:type="string">Quantity</field>
19+
<field name="attribute_code" xsi:type="string">quantity_and_stock_status</field>
20+
<field name="frontend_input" xsi:type="string">Dropdown</field>
21+
<field name="is_required" xsi:type="string">No</field>
22+
<field name="options" xsi:type="array">
23+
<item name="0" xsi:type="array">
24+
<item name="is_default" xsi:type="string">Yes</item>
25+
<item name="admin" xsi:type="string">In Stock</item>
26+
<item name="view" xsi:type="string">In Stock</item>
27+
</item>
28+
<item name="1" xsi:type="array">
29+
<item name="is_default" xsi:type="string">No</item>
30+
<item name="admin" xsi:type="string">Out of Stock</item>
31+
<item name="view" xsi:type="string">Out of Stock</item>
32+
</item>
33+
</field>
34+
</dataset>
35+
36+
<dataset name="tax_class_id">
37+
<field name="attribute_id" xsi:type="number">172</field>
38+
<field name="frontend_label" xsi:type="string">Tax Class</field>
39+
<field name="attribute_code" xsi:type="string">tax_class_id</field>
40+
<field name="frontend_input" xsi:type="string">Dropdown</field>
41+
<field name="is_required" xsi:type="string">No</field>
42+
<field name="options" xsi:type="array">
43+
<item name="0" xsi:type="array">
44+
<item name="is_default" xsi:type="string">No</item>
45+
<item name="admin" xsi:type="string">None</item>
46+
<item name="view" xsi:type="string">None</item>
47+
</item>
48+
<item name="1" xsi:type="array">
49+
<item name="is_default" xsi:type="string">Yes</item>
50+
<item name="admin" xsi:type="string">Taxable Goods</item>
51+
<item name="view" xsi:type="string">Taxable Goods</item>
52+
</item>
53+
</field>
54+
</dataset>
55+
1656
<dataset name="attribute_type_text_field">
1757
<field name="frontend_label" xsi:type="string">attribute_text%isolation%</field>
1858
<field name="attribute_code" xsi:type="string">attribute_text%isolation%</field>

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<data name="productAttribute/data/used_for_sort_by" xsi:type="string">Yes</data>
5959
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeInGrid" />
6060
<constraint name="Magento\Catalog\Test\Constraint\AssertAttributeForm" />
61+
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductByAttribute" />
6162
<constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm" />
6263
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsUsedInSortOnFrontend" />
6364
<constraint name="Magento\CatalogRule\Test\Constraint\AssertProductAttributeIsUsedPromoRules" />
@@ -69,8 +70,11 @@
6970
<data name="productAttribute/data/is_required" xsi:type="string">Yes</data>
7071
<data name="productAttribute/data/attribute_code" xsi:type="string">attr_yesno_%isolation%</data>
7172
<data name="productAttribute/data/is_global" xsi:type="string">Global</data>
73+
<data name="productAttribute/data/is_searchable" xsi:type="string">Yes</data>
74+
<data name="productAttribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data>
7275
<data name="productAttribute/data/default_value_yesno" xsi:type="string">No</data>
7376
<data name="productAttribute/data/manage_frontend_label" xsi:type="string">Yes/No_Global</data>
77+
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductByAttribute" />
7478
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeInGrid" />
7579
<constraint name="Magento\Catalog\Test\Constraint\AssertAttributeForm" />
7680
<constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm" />
@@ -100,6 +104,7 @@
100104
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsComparable" />
101105
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsFilterable" />
102106
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsFilterableInSearch" />
107+
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductByAttribute" />
103108
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAttributeSearchableByLabel" />
104109
<constraint name="Magento\Catalog\Test\Constraint\AssertAttributeOptionsOnProductForm" />
105110
</variation>

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
use Magento\Catalog\Test\Fixture\CatalogAttributeSet;
1010
use Magento\Catalog\Test\Fixture\CatalogProductAttribute;
11+
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
1112
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeIndex;
1213
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeNew;
14+
use Magento\Mtf\Fixture\FixtureFactory;
1315
use Magento\Mtf\TestCase\Injectable;
1416

1517
/**
@@ -36,6 +38,24 @@ class UpdateProductAttributeEntityTest extends Injectable
3638
const DOMAIN = 'MX';
3739
/* end tags */
3840

41+
/**
42+
* Factory for fixtures.
43+
*
44+
* @var FixtureFactory
45+
*/
46+
protected $fixtureFactory;
47+
48+
/**
49+
* Prepare data.
50+
*
51+
* @param FixtureFactory $fixtureFactory
52+
* @return void
53+
*/
54+
public function __prepare(FixtureFactory $fixtureFactory)
55+
{
56+
$this->fixtureFactory = $fixtureFactory;
57+
}
58+
3959
/**
4060
* Run UpdateProductAttributeEntity test
4161
*
@@ -44,14 +64,16 @@ class UpdateProductAttributeEntityTest extends Injectable
4464
* @param CatalogAttributeSet $productTemplate
4565
* @param CatalogProductAttributeIndex $attributeIndex
4666
* @param CatalogProductAttributeNew $attributeNew
47-
* @return void
67+
* @param CatalogProductSimple $productSimple
68+
* @return array
4869
*/
4970
public function testUpdateProductAttribute(
5071
CatalogProductAttribute $productAttributeOriginal,
5172
CatalogProductAttribute $attribute,
5273
CatalogAttributeSet $productTemplate,
5374
CatalogProductAttributeIndex $attributeIndex,
54-
CatalogProductAttributeNew $attributeNew
75+
CatalogProductAttributeNew $attributeNew,
76+
CatalogProductSimple $productSimple
5577
) {
5678
//Precondition
5779
$productTemplate->persist();
@@ -66,5 +88,42 @@ public function testUpdateProductAttribute(
6688
$attributeIndex->getGrid()->searchAndOpen($filter);
6789
$attributeNew->getAttributeForm()->fill($attribute);
6890
$attributeNew->getPageActions()->save();
91+
$attribute = $this->prepareAttribute($attribute, $productAttributeOriginal);
92+
$productSimple->persist();
93+
94+
return ['product' => $this->prepareProduct($productSimple, $attribute, $productTemplate)];
95+
}
96+
97+
/**
98+
* Prepare product data.
99+
*
100+
* @param CatalogProductSimple $product
101+
* @param CatalogProductAttribute $attribute
102+
* @param CatalogAttributeSet $productTemplate
103+
* @return CatalogProductSimple
104+
*/
105+
protected function prepareProduct($product, $attribute, $productTemplate)
106+
{
107+
$data = [
108+
'attribute_set_id' => ['attribute_set' => $productTemplate],
109+
'custom_attribute' => $attribute
110+
];
111+
$data = array_merge($data, $product->getData());
112+
113+
return $this->fixtureFactory->createByCode('catalogProductSimple', ['data' => $data]);
114+
}
115+
116+
/**
117+
* Prepare attribute data.
118+
*
119+
* @param CatalogProductAttribute $attribute
120+
* @param CatalogProductAttribute $productAttributeOriginal
121+
* @return CatalogProductAttribute
122+
*/
123+
protected function prepareAttribute($attribute, $productAttributeOriginal)
124+
{
125+
$attributeData = array_merge($attribute->getData(), $productAttributeOriginal->getData());
126+
127+
return $this->fixtureFactory->createByCode('catalogProductAttribute', ['data' => $attributeData]);
69128
}
70129
}

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<data name="attribute/data/options/dataset" xsi:type="string">default</data>
3535
<data name="attribute/data/is_required" xsi:type="string">Yes</data>
3636
<data name="attribute/data/is_global" xsi:type="string">Global</data>
37+
<data name="attribute/data/default_value_text" xsi:type="string">attribute_edited%isolation%</data>
3738
<data name="attribute/data/is_unique" xsi:type="string">Yes</data>
3839
<data name="attribute/data/is_searchable" xsi:type="string">Yes</data>
3940
<data name="attribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data>
@@ -49,5 +50,16 @@
4950
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeSaveMessage" />
5051
<constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm" />
5152
</variation>
53+
<variation name="UpdateProductAttributeEntityTestVariation3">
54+
<data name="productTemplate/dataset" xsi:type="string">custom_attribute_set</data>
55+
<data name="productAttributeOriginal/dataset" xsi:type="string">tax_class_id</data>
56+
<data name="attribute/data/is_searchable" xsi:type="string">Yes</data>
57+
<data name="attribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data>
58+
<data name="cacheTags" xsi:type="array">
59+
<item name="0" xsi:type="string">FPC</item>
60+
</data>
61+
<constraint name="Magento\Backend\Test\Constraint\AssertCacheIsRefreshableAndInvalidated" />
62+
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductByAttribute" />
63+
</variation>
5264
</testCase>
5365
</config>

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
use Magento\Catalog\Test\Fixture\CatalogAttributeSet;
1010
use Magento\Catalog\Test\Fixture\CatalogProductAttribute;
11+
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
12+
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
1113
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductSetEdit;
1214
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductSetIndex;
1315
use Magento\Mtf\Fixture\FixtureFactory;
@@ -46,26 +48,46 @@ class AddAttributeToProductTemplateStep implements TestStepInterface
4648
*/
4749
protected $productTemplate;
4850

51+
/**
52+
* Catalog Product Index page.
53+
*
54+
* @var CatalogProductIndex
55+
*/
56+
protected $catalogProductIndex;
57+
58+
/**
59+
* Catalog Product Edit page.
60+
*
61+
* @var CatalogProductEdit
62+
*/
63+
protected $catalogProductEdit;
64+
4965
/**
5066
* @constructor
5167
* @param CatalogProductSetIndex $catalogProductSetIndex
5268
* @param CatalogProductSetEdit $catalogProductSetEdit
5369
* @param CatalogProductAttribute $attribute
5470
* @param CatalogAttributeSet $productTemplate
5571
* @param FixtureFactory $fixtureFactory
72+
* @param CatalogProductIndex $catalogProductIndex
73+
* @param CatalogProductEdit $catalogProductEdit
5674
*/
5775
public function __construct(
5876
CatalogProductSetIndex $catalogProductSetIndex,
5977
CatalogProductSetEdit $catalogProductSetEdit,
6078
CatalogProductAttribute $attribute,
6179
CatalogAttributeSet $productTemplate,
62-
FixtureFactory $fixtureFactory
80+
FixtureFactory $fixtureFactory,
81+
CatalogProductIndex $catalogProductIndex,
82+
CatalogProductEdit $catalogProductEdit
6383
) {
6484
$this->catalogProductSetIndex = $catalogProductSetIndex;
6585
$this->catalogProductSetEdit = $catalogProductSetEdit;
6686
$this->attribute = $attribute;
6787
$this->productTemplate = $productTemplate;
6888
$this->fixtureFactory = $fixtureFactory;
89+
$this->catalogProductIndex = $catalogProductIndex;
90+
$this->catalogProductEdit = $catalogProductEdit;
6991
}
7092

7193
/**
@@ -87,10 +109,14 @@ public function run()
87109
'dataset' => 'product_with_category_with_anchor',
88110
'data' => [
89111
'attribute_set_id' => ['attribute_set' => $this->productTemplate],
112+
'custom_attribute' => $this->attribute
90113
],
91114
]
92115
);
93-
$product->persist();
116+
$this->catalogProductIndex->open()->getGridPageActionBlock()->addProduct('simple');
117+
$productForm = $this->catalogProductEdit->getProductForm();
118+
$productForm->fill($product);
119+
$this->catalogProductEdit->getFormPageActions()->save();
94120

95121
return ['product' => $product];
96122
}

0 commit comments

Comments
 (0)