diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/BlockGallery.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/BlockGallery.php index bc1a0ebc4ce1501ab3e322c16e84a09f909e6fd0..5a7ee7970eab6dec3c7302722220b2643ff1d5b1 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/BlockGallery.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/BlockGallery.php @@ -10,8 +10,16 @@ use Magento\Mtf\Client\Element\SimpleElement; use Magento\Mtf\Client\Locator; use Magento\Ui\Test\Block\Adminhtml\Section; +/** + * Class for product gallery block + */ class BlockGallery extends Section { + /** + * @var string + */ + private $imageLoader = '.image.image-placeholder .file-row'; + /** * Upload product images * @@ -22,12 +30,10 @@ class BlockGallery extends Section */ public function setFieldsData(array $data, SimpleElement $element = null) { - if (isset($data['image'])) { - foreach ($data['image']['value'] as $imageData) { - $uploadElement = $this->_rootElement->find('[name="image"]', Locator::SELECTOR_CSS, 'upload'); - $uploadElement->setValue($imageData['file']); - $this->waitForElementNotVisible('.image.image-placeholder .file-row'); - } + foreach ($data['image']['value'] as $imageData) { + $uploadElement = $element->find('[name="image"]', Locator::SELECTOR_CSS, 'upload'); + $uploadElement->setValue($imageData['file']); + $this->waitForElementNotVisible($this->imageLoader); } return $this; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml index b4f2d99385cf35ea511e0cc2d0a06ed38c102972..3b66164ebe658097e05fdba2e8b53c6cb3d643d2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml @@ -143,7 +143,7 @@ </fields> </attributes> <gallery> - <class>\Magento\Ui\Test\Block\Adminhtml\Section</class> + <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\BlockGallery</class> <selector>[data-index='block_gallery']</selector> <strategy>css selector</strategy> </gallery> @@ -223,9 +223,4 @@ <selector>[data-index="related"]</selector> <strategy>css selector</strategy> </related> - <block_gallery> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\BlockGallery</class> - <selector>[data-index="block_gallery"]</selector> - <strategy>css selector</strategy> - </block_gallery> </sections> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCanUpdate.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCanSaveProduct.php similarity index 80% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCanUpdate.php rename to dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCanSaveProduct.php index 24f1f9d7714cc0b4031bd0586321cbb0e7ae92ef..6f0dcd095207e255cf2f44f048b675a1599142a4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCanUpdate.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCanSaveProduct.php @@ -7,12 +7,12 @@ namespace Magento\Catalog\Test\Constraint; /** - * Class AssertProductCanUpdate + * Assert that can save already exist product */ -class AssertProductCanUpdate extends \Magento\Mtf\Constraint\AbstractConstraint +class AssertCanSaveProduct extends \Magento\Mtf\Constraint\AbstractConstraint { /** - * Assert that product with image can update without errors. + * Assert that can save already exist product * * @param \Magento\Mtf\Fixture\FixtureInterface $product * @param \Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit $catalogProductEdit @@ -29,7 +29,8 @@ class AssertProductCanUpdate extends \Magento\Mtf\Constraint\AbstractConstraint $catalogProductEdit->getFormPageActions()->save(); \PHPUnit_Framework_Assert::assertNotEmpty( - $catalogProductEdit->getMessagesBlock()->getSuccessMessage() + $catalogProductEdit->getMessagesBlock()->getSuccessMessage(), + 'Cant save existing product.' ); } @@ -40,6 +41,6 @@ class AssertProductCanUpdate extends \Magento\Mtf\Constraint\AbstractConstraint */ public function toString() { - return 'Product with image was updated without errors.'; + return 'Product was saved without errors.'; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml index a4ca27a0c9e7c7680a43011a10c6d76c3b1bfb22..e8ceb1d0889247805746a401f6c60bb5a0556010 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml @@ -36,8 +36,8 @@ <field name="gallery" is_required="0" /> <field name="gift_message_available" is_required="0" /> <field name="has_options" is_required="0" /> - <field name="image" is_required="0" group="block_gallery" source="Magento\Catalog\Test\Fixture\Product\Image" /> - <field name="image_label" group="block_gallery" is_required="0" /> + <field name="image" is_required="0" group="gallery" source="Magento\Catalog\Test\Fixture\Product\Image" /> + <field name="image_label" group="gallery" is_required="0" /> <field name="manufacturer" is_required="0" /> <field name="media_gallery" is_required="0" /> <field name="meta_description" is_required="0" group="search-engine-optimization" /> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/Image.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/Image.php index 0136c3431fe3c3d7e701f07fddcfbbfc7e31f9a1..ad72a6db4f4cef615f4abb7edddc497886a73981 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/Image.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/Image.php @@ -15,21 +15,46 @@ use Magento\Mtf\Fixture\FixtureFactory; class Image extends DataSource { /** - * Image constructor. + * Fixture Factory instance. + * + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * Fixture data. + * + * @var array + */ + private $fixtureData; + + /** * @param FixtureFactory $fixtureFactory * @param array $params * @param array $data - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function __construct(FixtureFactory $fixtureFactory, array $params, $data = []) { - foreach ($data as $key => &$imageData) { + $this->fixtureFactory = $fixtureFactory; + $this->params = $params; + $this->fixtureData = $data; + } + + /** + * {@inheritdoc} + * @throws \Exception + */ + public function getData($key = null) + { + foreach ($this->fixtureData as &$imageData) { if (isset($imageData['file']) && file_exists(MTF_TESTS_PATH . $imageData['file'])) { $imageData['file'] = MTF_TESTS_PATH . $imageData['file']; } else { - unset($data[$key]); + throw new \Exception("Image '{$imageData['file']}'' not found on the server."); } } - $this->data = $data; + $this->data = $this->fixtureData; + + return parent::getData($key); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml index 5e0a61a9c0426be36736e9361ed8970ca4f2243d..9690f409011cf04555dbca1da6ade15af5ed56a2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml @@ -500,8 +500,7 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInCart" /> </variation> - <variation name="CreateSimpleProductEntityWithImageTestVariation1"> - <data name="description" xsi:type="string">Create product with image and try to save it again</data> + <variation name="CreateSimpleProductEntityWithImageTestVariation1" summary="Create product with image and try to save it again"> <data name="product/data/image/0/file" xsi:type="string">Magento/Catalog/Test/_files/test1.png</data> <data name="product/data/image/1/file" xsi:type="string">Magento/Catalog/Test/_files/test2.png</data> <data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data> @@ -512,7 +511,7 @@ <data name="tag" xsi:type="string">severity:S1</data> <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">100</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> - <constraint name="Magento\Catalog\Test\Constraint\AssertProductCanUpdate" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertCanSaveProduct" /> </variation> </testCase> </config>