10
10
use Magento \Catalog \Test \Page \Adminhtml \CatalogCategoryEdit ;
11
11
use Magento \Catalog \Test \Page \Adminhtml \CatalogCategoryIndex ;
12
12
use Magento \Mtf \Constraint \AbstractAssertForm ;
13
+ use Magento \Mtf \Client \Locator ;
14
+ use Magento \Mtf \Client \BrowserInterface ;
15
+ use Magento \Mtf \Block \BlockFactory ;
13
16
14
17
/**
15
18
* Assert that displayed category data on edit page equals passed from fixture.
@@ -27,31 +30,81 @@ class AssertCategoryForm extends AbstractAssertForm
27
30
*/
28
31
protected $ skippedFixtureFields = [
29
32
'parent_id ' ,
30
- 'id '
33
+ 'id ' ,
34
+ 'store_id '
31
35
];
32
36
37
+ /**
38
+ * Default sore switcher block locator.
39
+ *
40
+ * @var string
41
+ */
42
+ private $ storeSwitcherBlock = '.store-switcher ' ;
43
+
44
+ /**
45
+ * Dropdown block locator.
46
+ *
47
+ * @var string
48
+ */
49
+ private $ dropdownBlock = '.dropdown ' ;
50
+
51
+ /**
52
+ * Selector for confirm.
53
+ *
54
+ * @var string
55
+ */
56
+ private $ confirmModal = '.confirm._show[data-role=modal] ' ;
57
+
33
58
/**
34
59
* Assert that displayed category data on edit page equals passed from fixture.
35
60
*
36
61
* @param CatalogCategoryIndex $catalogCategoryIndex
37
62
* @param CatalogCategoryEdit $catalogCategoryEdit
38
63
* @param Category $category
64
+ * @param BrowserInterface $browser
65
+ * @param BlockFactory $blockFactory
39
66
* @return void
40
67
*/
41
68
public function processAssert (
42
69
CatalogCategoryIndex $ catalogCategoryIndex ,
43
70
CatalogCategoryEdit $ catalogCategoryEdit ,
44
- Category $ category
71
+ Category $ category ,
72
+ BrowserInterface $ browser ,
73
+ BlockFactory $ blockFactory
45
74
) {
46
75
$ catalogCategoryIndex ->open ();
47
76
$ catalogCategoryIndex ->getTreeCategories ()->selectCategory ($ category , true );
48
-
77
+ $ this -> switchScope ( $ category , $ browser , $ blockFactory );
49
78
$ fixtureData = $ this ->prepareFixtureData ($ category ->getData ());
50
79
$ formData = $ catalogCategoryEdit ->getEditForm ()->getData ($ category );
51
80
$ error = $ this ->verifyData ($ this ->sortData ($ fixtureData ), $ this ->sortData ($ formData ));
52
81
\PHPUnit_Framework_Assert::assertEmpty ($ error , $ error );
53
82
}
54
83
84
+ /**
85
+ * Switches scope to selected store on the edit form
86
+ *
87
+ * @param Category $category
88
+ * @param BrowserInterface $browser
89
+ * @param BlockFactory $blockFactory
90
+ * @return void
91
+ */
92
+ private function switchScope (Category $ category , BrowserInterface $ browser , BlockFactory $ blockFactory )
93
+ {
94
+ if ($ category ->hasData ('store_id ' )) {
95
+ $ store = $ category ->getStoreId ()['source ' ]->getName ();
96
+ $ storeSwitcherBlock = $ browser ->find ($ this ->storeSwitcherBlock );
97
+ $ storeSwitcherBlock ->find ($ this ->dropdownBlock , Locator::SELECTOR_CSS , 'liselectstore ' )->setValue ($ store );
98
+ $ modalElement = $ browser ->find ($ this ->confirmModal );
99
+ /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */
100
+ $ modal = $ blockFactory ->create (
101
+ \Magento \Ui \Test \Block \Adminhtml \Modal::class,
102
+ ['element ' => $ modalElement ]
103
+ );
104
+ $ modal ->acceptAlert ();
105
+ }
106
+ }
107
+
55
108
/**
56
109
* Prepares fixture data for comparison.
57
110
*
0 commit comments