5
5
*/
6
6
namespace Magento \ImportExport \Controller \Adminhtml ;
7
7
8
+ use Magento \TestFramework \Helper \Xpath ;
9
+ use Magento \TestFramework \TestCase \AbstractBackendController ;
10
+
8
11
/**
9
12
* @magentoAppArea adminhtml
10
13
*/
11
- class ExportTest extends \ Magento \ TestFramework \ TestCase \ AbstractBackendController
14
+ class ExportTest extends AbstractBackendController
12
15
{
13
16
/**
14
17
* Set value of $_SERVER['HTTP_X_REQUESTED_WITH'] parameter here
@@ -18,20 +21,8 @@ class ExportTest extends \Magento\TestFramework\TestCase\AbstractBackendControll
18
21
protected $ _httpXRequestedWith ;
19
22
20
23
/**
21
- * Get possible entity types
22
- *
23
- * @return array
24
+ * @inheritdoc
24
25
*/
25
- public function getEntityTypesDataProvider ()
26
- {
27
- return [
28
- 'products ' => ['$entityType ' => 'catalog_product ' ],
29
- 'customers ' => ['$entityType ' => 'customer ' ],
30
- // customer entities
31
- 'customers_customer_entities ' => ['$entityType ' => 'customer ' , '$customerEntityType ' => 'customer ' ]
32
- ];
33
- }
34
-
35
26
protected function setUp (): void
36
27
{
37
28
parent ::setUp ();
@@ -41,6 +32,9 @@ protected function setUp(): void
41
32
}
42
33
}
43
34
35
+ /**
36
+ * @inheritdoc
37
+ */
44
38
protected function tearDown (): void
45
39
{
46
40
if ($ this ->_httpXRequestedWith !== null ) {
@@ -56,10 +50,14 @@ protected function tearDown(): void
56
50
* @dataProvider getEntityTypesDataProvider
57
51
*
58
52
* @param string $entityType
59
- * @param string $customerEntityType
53
+ * @param string|null $customerEntityType
54
+ * @param array $expectedAttributes
60
55
*/
61
- public function testGetFilterAction ($ entityType , $ customerEntityType = null )
62
- {
56
+ public function testGetFilterAction (
57
+ string $ entityType ,
58
+ string $ customerEntityType = null ,
59
+ array $ expectedAttributes = []
60
+ ) {
63
61
$ this ->getRequest ()->setParam ('isAjax ' , true );
64
62
65
63
// Provide X_REQUESTED_WITH header in response to mark next action as ajax
@@ -72,7 +70,35 @@ public function testGetFilterAction($entityType, $customerEntityType = null)
72
70
}
73
71
$ this ->dispatch ($ url );
74
72
75
- $ this ->assertStringContainsString ('<div id="export_filter_grid" ' , $ this ->getResponse ()->getBody ());
73
+ $ body = $ this ->getResponse ()->getBody ();
74
+ $ this ->assertStringContainsString ('<div id="export_filter_grid" ' , $ body );
75
+ foreach ($ expectedAttributes as $ attribute ) {
76
+ $ this ->assertStringContainsString ("name= \"export_filter[ {$ attribute }] \"" , $ body );
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Get possible entity types
82
+ *
83
+ * @return array
84
+ */
85
+ public function getEntityTypesDataProvider ()
86
+ {
87
+ return [
88
+ 'products ' => [
89
+ 'entityType ' => 'catalog_product ' ,
90
+ 'customerEntityType ' => null ,
91
+ 'expectedAttributes ' => ['category_ids ' ]
92
+ ],
93
+ 'customers ' => [
94
+ 'entityType ' => 'customer '
95
+ ],
96
+ // customer entities
97
+ 'customers_customer_entities ' => [
98
+ 'entityType ' => 'customer ' ,
99
+ 'customerEntityType ' => 'customer '
100
+ ]
101
+ ];
76
102
}
77
103
78
104
/**
@@ -86,14 +112,14 @@ public function testIndexAction()
86
112
87
113
$ this ->assertEquals (
88
114
1 ,
89
- \ Magento \ TestFramework \ Helper \ Xpath::getElementsCountForXpath (
115
+ Xpath::getElementsCountForXpath (
90
116
'//fieldset[@id="base_fieldset"] ' ,
91
117
$ body
92
118
)
93
119
);
94
120
$ this ->assertEquals (
95
121
3 ,
96
- \ Magento \ TestFramework \ Helper \ Xpath::getElementsCountForXpath (
122
+ Xpath::getElementsCountForXpath (
97
123
'//fieldset[@id="base_fieldset"]/div[contains(@class,"field")] ' ,
98
124
$ body
99
125
)
0 commit comments