Skip to content

Commit 28dc588

Browse files
committed
MTA-1594: Re-factor Functional tests which are not end-to-end
- Re-factored MassProductPriceUpdateTest
1 parent 6c008b3 commit 28dc588

File tree

5 files changed

+174
-44
lines changed

5 files changed

+174
-44
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action;
88

9-
use Magento\Backend\Test\Block\Widget\Form;
109
use Magento\Mtf\Client\Locator;
10+
use Magento\Mtf\Fixture\FixtureInterface;
11+
use Magento\Backend\Test\Block\Widget\Form;
12+
use Magento\Mtf\Client\Element\SimpleElement;
1113

1214
/**
1315
* Product attribute massaction edit page.
@@ -41,4 +43,24 @@ public function enablePriceEdit()
4143
'checkbox'
4244
)->setValue('Yes');
4345
}
46+
47+
/**
48+
* Fill the root form
49+
*
50+
* @param FixtureInterface $fixture
51+
* @param SimpleElement|null $element
52+
* @return $this
53+
*/
54+
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
55+
{
56+
$data = $fixture->getData();
57+
foreach ($data as $name => $dataValue) {
58+
$fields['toggle_' . $name ] = 'Yes';
59+
$fields[$name] = $dataValue;
60+
}
61+
$mapping = $this->dataMapping($fields);
62+
$this->_fill($mapping, $element);
63+
64+
return $this;
65+
}
4466
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<mapping strict="0">
99
<wrapper>attributes</wrapper>
1010
<fields>
11-
<price/>
11+
<toggle_price>
12+
<selector>[name='toggle_price']</selector>
13+
<input>checkbox</input>
14+
</toggle_price>
15+
<price />
1216
</fields>
1317
</mapping>

dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductActionAttributeEdit.php

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\TestCase\Product;
8+
9+
use Magento\Mtf\TestCase\Injectable;
10+
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
11+
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
12+
use Magento\Catalog\Test\Page\Product\CatalogProductActionAttributeEdit;
13+
14+
/**
15+
* Precondition:
16+
* 1. Product is created.
17+
* 2. Product flat is enabled.
18+
*
19+
* Steps:
20+
* 1. Login to backend.
21+
* 2. Go to Products -> Catalog.
22+
* 3. Find Product (from preconditions) in Products grid.
23+
* 4. Select Product's check-box.
24+
* 5. Select "Update Attributes" value in "Select Product Actions" drop-down list.
25+
* 6. Click on the "Submit" button. "Attributes" page is opened (/catalog/product_action_attribute/edit/).
26+
* 7. Open "Attributes" tab.
27+
* 8. Fill data.
28+
* 9. Click on the "Save" button.
29+
* 10. Perform asserts.
30+
*
31+
* @group Products_(MX)
32+
* @ZephyrId MAGETWO-21128
33+
*/
34+
class MassProductPriceUpdateTest extends Injectable
35+
{
36+
/* tags */
37+
const MVP = 'yes';
38+
const DOMAIN = 'MX';
39+
/* end tags */
40+
41+
/**
42+
* Product page with a grid.
43+
*
44+
* @var CatalogProductIndex
45+
*/
46+
protected $productGrid;
47+
48+
/**
49+
* Page to update a product.
50+
*
51+
* @var CatalogProductActionAttributeEdit
52+
*/
53+
protected $attributeMassActionPage;
54+
55+
/**
56+
* Configuration data.
57+
*
58+
* @var string
59+
*/
60+
protected $configData;
61+
62+
/**
63+
* Injection data.
64+
*
65+
* @param CatalogProductIndex $productGrid
66+
* @param CatalogProductActionAttributeEdit $attributeMassActionPage
67+
* @return void
68+
*/
69+
public function __inject(
70+
CatalogProductIndex $productGrid,
71+
CatalogProductActionAttributeEdit $attributeMassActionPage
72+
) {
73+
$this->productGrid = $productGrid;
74+
$this->attributeMassActionPage = $attributeMassActionPage;
75+
}
76+
77+
/**
78+
* Run mass update product simple entity test.
79+
*
80+
* @param CatalogProductSimple $initialProduct
81+
* @param CatalogProductSimple $product
82+
* @param string $configData
83+
* @return array
84+
*/
85+
public function test(CatalogProductSimple $initialProduct, CatalogProductSimple $product, $configData)
86+
{
87+
$this->configData = $configData;
88+
89+
// Preconditions
90+
$initialProduct->persist();
91+
92+
$this->objectManager->create(
93+
'Magento\Config\Test\TestStep\SetupConfigurationStep',
94+
['configData' => $configData]
95+
)->run();
96+
97+
// Steps
98+
$this->productGrid->open();
99+
$this->productGrid->getProductGrid()->updateAttributes([['sku' => $initialProduct->getSku()]]);
100+
$formBlock = $this->attributeMassActionPage->getAttributesBlockForm();
101+
$formBlock->fill($product);
102+
$formBlock->save();
103+
$this->productGrid->getMessagesBlock()->waitSuccessMessage();
104+
$data = array_merge($initialProduct->getData(), $product->getData());
105+
$product = $this->objectManager->create(
106+
'Magento\Catalog\Test\Fixture\CatalogProductSimple',
107+
['data' => $data]
108+
);
109+
110+
return [
111+
'category' => $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0],
112+
'product' => $product,
113+
];
114+
}
115+
116+
/**
117+
* Clear data after test.
118+
*
119+
* @return void
120+
*/
121+
public function tearDown()
122+
{
123+
$this->objectManager->create(
124+
'Magento\Config\Test\TestStep\SetupConfigurationStep',
125+
['configData' => $this->configData, 'rollback' => true]
126+
)->run();
127+
}
128+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Catalog\Test\TestCase\Product\MassProductPriceUpdateTest">
10+
<variation name="MassProductPriceUpdateTestVariation1">
11+
<data name="configData" xsi:type="string">product_flat</data>
12+
<data name="initialProduct/dataSet" xsi:type="string">simple_10_dollar</data>
13+
<data name="product/data/price/value" xsi:type="string">1.99</data>
14+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" />
15+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInCategory" />
16+
</variation>
17+
</testCase>
18+
</config>

0 commit comments

Comments
 (0)