Skip to content

Commit 3b6a896

Browse files
author
Stanislav Idolov
committed
MAGETWO-59626: Error saving configurable product after disabling child products
1 parent 01eca72 commit 3b6a896

File tree

6 files changed

+53
-27
lines changed

6 files changed

+53
-27
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/BlockGallery.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@
1010
use Magento\Mtf\Client\Locator;
1111
use Magento\Ui\Test\Block\Adminhtml\Section;
1212

13+
/**
14+
* Class for product gallery block
15+
*/
1316
class BlockGallery extends Section
1417
{
18+
/**
19+
* @var string
20+
*/
21+
private $imageLoader = '.image.image-placeholder .file-row';
22+
1523
/**
1624
* Upload product images
1725
*
@@ -22,12 +30,10 @@ class BlockGallery extends Section
2230
*/
2331
public function setFieldsData(array $data, SimpleElement $element = null)
2432
{
25-
if (isset($data['image'])) {
26-
foreach ($data['image']['value'] as $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-
}
33+
foreach ($data['image']['value'] as $imageData) {
34+
$uploadElement = $element->find('[name="image"]', Locator::SELECTOR_CSS, 'upload');
35+
$uploadElement->setValue($imageData['file']);
36+
$this->waitForElementNotVisible($this->imageLoader);
3137
}
3238
return $this;
3339
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
</fields>
144144
</attributes>
145145
<gallery>
146-
<class>\Magento\Ui\Test\Block\Adminhtml\Section</class>
146+
<class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\BlockGallery</class>
147147
<selector>[data-index='block_gallery']</selector>
148148
<strategy>css selector</strategy>
149149
</gallery>
@@ -223,9 +223,4 @@
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>
231226
</sections>

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCanUpdate.php renamed to dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCanSaveProduct.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
namespace Magento\Catalog\Test\Constraint;
88

99
/**
10-
* Class AssertProductCanUpdate
10+
* Assert that can save already exist product
1111
*/
12-
class AssertProductCanUpdate extends \Magento\Mtf\Constraint\AbstractConstraint
12+
class AssertCanSaveProduct extends \Magento\Mtf\Constraint\AbstractConstraint
1313
{
1414
/**
15-
* Assert that product with image can update without errors.
15+
* Assert that can save already exist product
1616
*
1717
* @param \Magento\Mtf\Fixture\FixtureInterface $product
1818
* @param \Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit $catalogProductEdit
@@ -29,7 +29,8 @@ public function processAssert(
2929
$catalogProductEdit->getFormPageActions()->save();
3030

3131
\PHPUnit_Framework_Assert::assertNotEmpty(
32-
$catalogProductEdit->getMessagesBlock()->getSuccessMessage()
32+
$catalogProductEdit->getMessagesBlock()->getSuccessMessage(),
33+
'Cant save existing product.'
3334
);
3435
}
3536

@@ -40,6 +41,6 @@ public function processAssert(
4041
*/
4142
public function toString()
4243
{
43-
return 'Product with image was updated without errors.';
44+
return 'Product was saved without errors.';
4445
}
4546
}

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" group="block_gallery" source="Magento\Catalog\Test\Fixture\Product\Image" />
40-
<field name="image_label" group="block_gallery" is_required="0" />
39+
<field name="image" is_required="0" group="gallery" source="Magento\Catalog\Test\Fixture\Product\Image" />
40+
<field name="image_label" group="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" />

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/Image.php

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,46 @@
1515
class Image extends DataSource
1616
{
1717
/**
18-
* Image constructor.
18+
* Fixture Factory instance.
19+
*
20+
* @var FixtureFactory
21+
*/
22+
private $fixtureFactory;
23+
24+
/**
25+
* Fixture data.
26+
*
27+
* @var array
28+
*/
29+
private $fixtureData;
30+
31+
/**
1932
* @param FixtureFactory $fixtureFactory
2033
* @param array $params
2134
* @param array $data
22-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2335
*/
2436
public function __construct(FixtureFactory $fixtureFactory, array $params, $data = [])
2537
{
26-
foreach ($data as $key => &$imageData) {
38+
$this->fixtureFactory = $fixtureFactory;
39+
$this->params = $params;
40+
$this->fixtureData = $data;
41+
}
42+
43+
/**
44+
* {@inheritdoc}
45+
* @throws \Exception
46+
*/
47+
public function getData($key = null)
48+
{
49+
foreach ($this->fixtureData as &$imageData) {
2750
if (isset($imageData['file']) && file_exists(MTF_TESTS_PATH . $imageData['file'])) {
2851
$imageData['file'] = MTF_TESTS_PATH . $imageData['file'];
2952
} else {
30-
unset($data[$key]);
53+
throw new \Exception("Image '{$imageData['file']}'' not found on the server.");
3154
}
3255
}
33-
$this->data = $data;
56+
$this->data = $this->fixtureData;
57+
58+
return parent::getData($key);
3459
}
3560
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,7 @@
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 and try to save it again</data>
503+
<variation name="CreateSimpleProductEntityWithImageTestVariation1" summary="Create product with image and try to save it again">
505504
<data name="product/data/image/0/file" xsi:type="string">Magento/Catalog/Test/_files/test1.png</data>
506505
<data name="product/data/image/1/file" xsi:type="string">Magento/Catalog/Test/_files/test2.png</data>
507506
<data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data>
@@ -512,7 +511,7 @@
512511
<data name="tag" xsi:type="string">severity:S1</data>
513512
<data name="product/data/quantity_and_stock_status/qty" xsi:type="string">100</data>
514513
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
515-
<constraint name="Magento\Catalog\Test\Constraint\AssertProductCanUpdate" />
514+
<constraint name="Magento\Catalog\Test\Constraint\AssertCanSaveProduct" />
516515
</variation>
517516
</testCase>
518517
</config>

0 commit comments

Comments
 (0)