Skip to content

Commit f63b0a1

Browse files
Merge pull request #1118 from magento-jackalopes/MAGETWO-69319-functional-test
[jackalopes] MAGETWO-69319: Create functional automated test for covering the functionality of Mass updating the products
2 parents 1c7e460 + 0abd1da commit f63b0a1

File tree

4 files changed

+165
-0
lines changed

4 files changed

+165
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Test\Constraint;
7+
8+
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
9+
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
12+
class AssertUpdatedProductStatusInGrid extends AbstractConstraint
13+
{
14+
/* tags */
15+
const SEVERITY = 'low';
16+
/* end tags */
17+
18+
/**
19+
* Asserts that the Disabled product is present in the grid after filtering by the product status
20+
*
21+
* @param CatalogProductSimple $product
22+
* @param CatalogProductIndex $catalogProductIndex
23+
* @return void
24+
*/
25+
public function processAssert(
26+
CatalogProductSimple $product,
27+
CatalogProductIndex $catalogProductIndex
28+
) {
29+
$catalogProductIndex->open();
30+
$productStatus = ($product->getStatus() === null || $product->getStatus() === 'Yes')
31+
? 'Enabled'
32+
: 'Disabled';
33+
$filter = ['status' => $productStatus];
34+
\PHPUnit_Framework_Assert::assertTrue(
35+
$catalogProductIndex->getProductGrid()->isRowVisible($filter),
36+
'Product \'' . $product->getName() . '\' is absent in Products grid.'
37+
);
38+
}
39+
40+
/**
41+
* Returns a string representation of the object.
42+
*
43+
* @return string
44+
*/
45+
public function toString()
46+
{
47+
return 'Products are in grid.';
48+
}
49+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,7 @@
14161416
<field name="tax_class_id" xsi:type="array">
14171417
<item name="dataset" xsi:type="string">taxable_goods</item>
14181418
</field>
1419+
<field name="status" xsi:type="string">Yes</field>
14191420
<field name="website_ids" xsi:type="array">
14201421
<item name="0" xsi:type="array">
14211422
<item name="dataset" xsi:type="string">default</item>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Test\TestCase\Product;
7+
8+
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
9+
use Magento\Mtf\Fixture\FixtureFactory;
10+
use Magento\Mtf\TestCase\Injectable;
11+
12+
/**
13+
* Preconditions:
14+
* 1. Create product according to data set.
15+
*
16+
* Steps:
17+
* 1. Login to backend.
18+
* 2. Navigate Products->Catalog.
19+
* 3. Select products created in preconditions.
20+
* 4. Select Change status action from mass-action.
21+
* 5. Select Disable
22+
* 6. Perform asserts.
23+
*
24+
* @group Products
25+
* @ZephyrId MAGETWO-60847
26+
*/
27+
class MassProductUpdateStatusTest extends Injectable
28+
{
29+
/* tags */
30+
const MVP = 'yes';
31+
/* end tags */
32+
33+
/**
34+
* Product page with the grid.
35+
*
36+
* @var CatalogProductIndex
37+
*/
38+
private $catalogProductIndex;
39+
40+
/**
41+
* Product grid action
42+
*
43+
* @var string
44+
*/
45+
private $productGridAction = 'Change status';
46+
47+
/**
48+
* Factory for Fixtures.
49+
*
50+
* @var FixtureFactory
51+
*/
52+
private $fixtureFactory;
53+
54+
/**
55+
* Injection data
56+
*
57+
* @param CatalogProductIndex $catalogProductIndex
58+
* @param FixtureFactory $fixtureFactory
59+
*/
60+
public function __inject(
61+
CatalogProductIndex $catalogProductIndex,
62+
FixtureFactory $fixtureFactory
63+
) {
64+
$this->catalogProductIndex = $catalogProductIndex;
65+
$this->fixtureFactory = $fixtureFactory;
66+
}
67+
68+
/**
69+
* Mass update the status of the products in the grid
70+
*
71+
* @param string $gridStatus
72+
* @param array $initialProducts
73+
* @return array
74+
*/
75+
public function test(
76+
$gridStatus,
77+
array $initialProducts,
78+
FixtureFactory $fixtureFactory
79+
) {
80+
// Preconditions
81+
$changeStatusProducts = [];
82+
foreach ($initialProducts as $product) {
83+
list($fixture, $dataset) = explode('::', $product);
84+
$product = $fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
85+
$product->persist();
86+
$changeStatusProducts[] = ['sku' => $product->getSku()];
87+
}
88+
89+
// Steps
90+
$this->catalogProductIndex->open();
91+
$this->catalogProductIndex->getProductGrid()
92+
->massaction($changeStatusProducts, [$this->productGridAction => $gridStatus]);
93+
return ['products' => $initialProducts];
94+
}
95+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. 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\MassProductUpdateStatusTest" summary="Update status of Products Using Mass Actions" ticketId="MAGETWO-60847">
10+
<variation name="MassProductStatusUpdateTestVariation1">
11+
<data name="initialProducts" xsi:type="array">
12+
<item name ="0" xsi:type="string">catalogProductSimple::simple_10_dollar</item>
13+
<item name ="1" xsi:type="string">catalogProductSimple::simple_10_dollar</item>
14+
</data>
15+
<data name="gridStatus" xsi:type="string">Disable</data>
16+
<data name="product/data/status" xsi:type="string">No</data>
17+
<constraint name="Magento\Catalog\Test\Constraint\AssertUpdatedProductStatusInGrid" />
18+
</variation>
19+
</testCase>
20+
</config>

0 commit comments

Comments
 (0)