Skip to content

Commit 586a715

Browse files
author
Stanislav Idolov
committed
MAGETWO-59626: Error saving configurable product after disabling child products
1 parent 97a5df0 commit 586a715

File tree

8 files changed

+132
-2
lines changed

8 files changed

+132
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section;
8+
9+
use Magento\Mtf\Client\Element\SimpleElement;
10+
use Magento\Mtf\Client\Locator;
11+
use Magento\Ui\Test\Block\Adminhtml\Section;
12+
13+
class BlockGallery extends Section
14+
{
15+
/**
16+
* Upload product images
17+
*
18+
* @param array $data
19+
* @param SimpleElement|null $element
20+
* @return $this
21+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
22+
*/
23+
public function setFieldsData(array $data, SimpleElement $element = null)
24+
{
25+
if (isset($data['image'])) {
26+
foreach ($data['image']['value'] as $key => $imageData) {
27+
$uploadElement = $this->_rootElement->find('[name="image"]', Locator::SELECTOR_CSS, 'upload');
28+
$uploadElement->setValue($imageData['file']);
29+
$this->waitForElementNotVisible('.image.image-placeholder .file-row');
30+
}
31+
}
32+
return $this;
33+
}
34+
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,9 @@
223223
<selector>[data-index="related"]</selector>
224224
<strategy>css selector</strategy>
225225
</related>
226+
<block_gallery>
227+
<class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\BlockGallery</class>
228+
<selector>[data-index="block_gallery"]</selector>
229+
<strategy>css selector</strategy>
230+
</block_gallery>
226231
</sections>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Constraint;
8+
9+
/**
10+
* Class AssertProductCanUpdate
11+
*/
12+
class AssertProductCanUpdate extends \Magento\Mtf\Constraint\AbstractConstraint
13+
{
14+
/**
15+
* Assert that product with image can update without errors.
16+
*
17+
* @param \Magento\Mtf\Fixture\FixtureInterface $product
18+
* @param \Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit $catalogProductEdit
19+
* @param \Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex $catalogProductIndex
20+
*/
21+
public function processAssert(
22+
\Magento\Mtf\Fixture\FixtureInterface $product,
23+
\Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit $catalogProductEdit,
24+
\Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex $catalogProductIndex
25+
) {
26+
$filter = ['sku' => $product->getSku()];
27+
$catalogProductIndex->open()->getProductGrid()->searchAndOpen($filter);
28+
$catalogProductEdit->getFormPageActions()->save();
29+
30+
\PHPUnit_Framework_Assert::assertNotEmpty(
31+
$catalogProductEdit->getMessagesBlock()->getSuccessMessage()
32+
);
33+
}
34+
35+
/**
36+
* Returns a string representation of the object
37+
*
38+
* @return string
39+
*/
40+
public function toString()
41+
{
42+
return 'Product with image was updated without errors.';
43+
}
44+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
<field name="gallery" is_required="0" />
3737
<field name="gift_message_available" is_required="0" />
3838
<field name="has_options" is_required="0" />
39-
<field name="image" is_required="0" />
40-
<field name="image_label" is_required="0" />
39+
<field name="image" is_required="0" group="block_gallery" source="Magento\Catalog\Test\Fixture\Product\Image" />
40+
<field name="image_label" group="block_gallery" is_required="0" />
4141
<field name="manufacturer" is_required="0" />
4242
<field name="media_gallery" is_required="0" />
4343
<field name="meta_description" is_required="0" group="search-engine-optimization" />
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Fixture\Product;
8+
9+
use Magento\Mtf\Fixture\DataSource;
10+
use Magento\Mtf\Fixture\FixtureFactory;
11+
12+
/**
13+
* Image entity data source.
14+
*/
15+
class Image extends DataSource
16+
{
17+
/**
18+
* Image constructor.
19+
* @param FixtureFactory $fixtureFactory
20+
* @param array $params
21+
* @param array $data
22+
*/
23+
public function __construct(FixtureFactory $fixtureFactory, array $params, $data = [])
24+
{
25+
foreach ($data as $key => &$imageData) {
26+
if (isset($imageData['file']) && file_exists(MTF_TESTS_PATH . $imageData['file'])) {
27+
$imageData['file'] = MTF_TESTS_PATH . $imageData['file'];
28+
} else {
29+
unset($data[$key]);
30+
}
31+
}
32+
$this->data = $data;
33+
}
34+
}

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,5 +500,18 @@
500500
<constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" />
501501
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInCart" />
502502
</variation>
503+
<variation name="CreateSimpleProductEntityWithImageTestVariation1">
504+
<data name="description" xsi:type="string">Create product with image</data>
505+
<data name="product/data/image/0/file" xsi:type="string">Magento/Catalog/Test/_files/test1.png</data>
506+
<data name="product/data/image/1/file" xsi:type="string">Magento/Catalog/Test/_files/test2.png</data>
507+
<data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data>
508+
<data name="product/data/name" xsi:type="string">Simple Product %isolation%</data>
509+
<data name="product/data/sku" xsi:type="string">simple_sku_%isolation%</data>
510+
<data name="product/data/price/value" xsi:type="string">10</data>
511+
<data name="product/data/weight" xsi:type="string">50</data>
512+
<data name="product/data/quantity_and_stock_status/qty" xsi:type="string">100</data>
513+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
514+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductCanUpdate" />
515+
</variation>
503516
</testCase>
504517
</config>
Loading
Loading

0 commit comments

Comments
 (0)