File tree Expand file tree Collapse file tree 6 files changed +53
-27
lines changed
dev/tests/functional/tests/app/Magento/Catalog/Test Expand file tree Collapse file tree 6 files changed +53
-27
lines changed Original file line number Diff line number Diff line change 10
10
use Magento \Mtf \Client \Locator ;
11
11
use Magento \Ui \Test \Block \Adminhtml \Section ;
12
12
13
+ /**
14
+ * Class for product gallery block
15
+ */
13
16
class BlockGallery extends Section
14
17
{
18
+ /**
19
+ * @var string
20
+ */
21
+ private $ imageLoader = '.image.image-placeholder .file-row ' ;
22
+
15
23
/**
16
24
* Upload product images
17
25
*
@@ -22,12 +30,10 @@ class BlockGallery extends Section
22
30
*/
23
31
public function setFieldsData (array $ data , SimpleElement $ element = null )
24
32
{
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 );
31
37
}
32
38
return $ this ;
33
39
}
Original file line number Diff line number Diff line change 143
143
</fields >
144
144
</attributes >
145
145
<gallery >
146
- <class >\Magento\Ui \Test\Block\Adminhtml\Section</class >
146
+ <class >\Magento\Catalog \Test\Block\Adminhtml\Product\Edit\ Section\BlockGallery </class >
147
147
<selector >[data-index='block_gallery']</selector >
148
148
<strategy >css selector</strategy >
149
149
</gallery >
223
223
<selector >[data-index="related"]</selector >
224
224
<strategy >css selector</strategy >
225
225
</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 >
231
226
</sections >
Original file line number Diff line number Diff line change 7
7
namespace Magento \Catalog \Test \Constraint ;
8
8
9
9
/**
10
- * Class AssertProductCanUpdate
10
+ * Assert that can save already exist product
11
11
*/
12
- class AssertProductCanUpdate extends \Magento \Mtf \Constraint \AbstractConstraint
12
+ class AssertCanSaveProduct extends \Magento \Mtf \Constraint \AbstractConstraint
13
13
{
14
14
/**
15
- * Assert that product with image can update without errors.
15
+ * Assert that can save already exist product
16
16
*
17
17
* @param \Magento\Mtf\Fixture\FixtureInterface $product
18
18
* @param \Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit $catalogProductEdit
@@ -29,7 +29,8 @@ public function processAssert(
29
29
$ catalogProductEdit ->getFormPageActions ()->save ();
30
30
31
31
\PHPUnit_Framework_Assert::assertNotEmpty (
32
- $ catalogProductEdit ->getMessagesBlock ()->getSuccessMessage ()
32
+ $ catalogProductEdit ->getMessagesBlock ()->getSuccessMessage (),
33
+ 'Cant save existing product. '
33
34
);
34
35
}
35
36
@@ -40,6 +41,6 @@ public function processAssert(
40
41
*/
41
42
public function toString ()
42
43
{
43
- return 'Product with image was updated without errors. ' ;
44
+ return 'Product was saved without errors. ' ;
44
45
}
45
46
}
Original file line number Diff line number Diff line change 36
36
<field name =" gallery" is_required =" 0" />
37
37
<field name =" gift_message_available" is_required =" 0" />
38
38
<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" />
41
41
<field name =" manufacturer" is_required =" 0" />
42
42
<field name =" media_gallery" is_required =" 0" />
43
43
<field name =" meta_description" is_required =" 0" group =" search-engine-optimization" />
Original file line number Diff line number Diff line change 15
15
class Image extends DataSource
16
16
{
17
17
/**
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
+ /**
19
32
* @param FixtureFactory $fixtureFactory
20
33
* @param array $params
21
34
* @param array $data
22
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
23
35
*/
24
36
public function __construct (FixtureFactory $ fixtureFactory , array $ params , $ data = [])
25
37
{
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 ) {
27
50
if (isset ($ imageData ['file ' ]) && file_exists (MTF_TESTS_PATH . $ imageData ['file ' ])) {
28
51
$ imageData ['file ' ] = MTF_TESTS_PATH . $ imageData ['file ' ];
29
52
} else {
30
- unset( $ data [ $ key ] );
53
+ throw new \ Exception ( " Image ' { $ imageData [ ' file ' ]} '' not found on the server. " );
31
54
}
32
55
}
33
- $ this ->data = $ data ;
56
+ $ this ->data = $ this ->fixtureData ;
57
+
58
+ return parent ::getData ($ key );
34
59
}
35
60
}
Original file line number Diff line number Diff line change 500
500
<constraint name =" Magento\Catalog\Test\Constraint\AssertProductPage" />
501
501
<constraint name =" Magento\Catalog\Test\Constraint\AssertProductInCart" />
502
502
</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" >
505
504
<data name =" product/data/image/0/file" xsi : type =" string" >Magento/Catalog/Test/_files/test1.png</data >
506
505
<data name =" product/data/image/1/file" xsi : type =" string" >Magento/Catalog/Test/_files/test2.png</data >
507
506
<data name =" product/data/url_key" xsi : type =" string" >simple-product-%isolation%</data >
512
511
<data name =" tag" xsi : type =" string" >severity:S1</data >
513
512
<data name =" product/data/quantity_and_stock_status/qty" xsi : type =" string" >100</data >
514
513
<constraint name =" Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
515
- <constraint name =" Magento\Catalog\Test\Constraint\AssertProductCanUpdate " />
514
+ <constraint name =" Magento\Catalog\Test\Constraint\AssertCanSaveProduct " />
516
515
</variation >
517
516
</testCase >
518
517
</config >
You can’t perform that action at this time.
0 commit comments