3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \ImportExport \Test \Unit \Block \Adminhtml \Export ;
7
9
10
+ use Magento \Backend \Helper \Data ;
11
+ use Magento \Catalog \Model \Product \ReservedAttributeList ;
12
+ use Magento \Catalog \Model \ResourceModel \Product ;
13
+ use Magento \Eav \Api \Data \AttributeOptionInterfaceFactory ;
14
+ use Magento \Eav \Model \Config ;
15
+ use Magento \Eav \Model \Entity \Attribute ;
16
+ use Magento \Eav \Model \Entity \TypeFactory ;
17
+ use Magento \Eav \Model \ResourceModel \Helper ;
18
+ use Magento \Framework \Api \AttributeValueFactory ;
19
+ use Magento \Framework \Api \DataObjectHelper ;
20
+ use Magento \Framework \Api \ExtensionAttributesFactory ;
21
+ use Magento \Framework \Data \Collection \AbstractDb ;
22
+ use Magento \Framework \DataObject ;
23
+ use Magento \Framework \Escaper ;
24
+ use Magento \Framework \Filesystem ;
25
+ use Magento \Framework \Locale \Resolver ;
26
+ use Magento \Framework \Model \Context ;
27
+ use Magento \Framework \Reflection \DataObjectProcessor ;
28
+ use Magento \Framework \Registry ;
29
+ use Magento \Framework \Stdlib \DateTime \DateTimeFormatterInterface ;
30
+ use Magento \Framework \Stdlib \DateTime \Timezone ;
8
31
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
32
+ use Magento \Framework \Validator \UniversalFactory ;
33
+ use Magento \Framework \View \Element \Html \Date ;
34
+ use Magento \Framework \View \Layout ;
35
+ use Magento \ImportExport \Block \Adminhtml \Export \Filter ;
36
+ use Magento \Store \Model \StoreManager ;
37
+ use PHPUnit \Framework \MockObject \MockObject ;
38
+ use PHPUnit \Framework \TestCase ;
9
39
10
40
/**
11
41
* @SuppressWarnings(PHPMD)
12
42
*/
13
- class FilterTest extends \ PHPUnit \ Framework \ TestCase
43
+ class FilterTest extends TestCase
14
44
{
15
45
/**
16
- * @var \Magento\Framework\Model\ Context|\PHPUnit_Framework_MockObject_MockObject
46
+ * @var Context|MockObject
17
47
*/
18
48
protected $ modelContext ;
19
49
20
50
/**
21
- * @var \Magento\Framework\ Registry|\PHPUnit_Framework_MockObject_MockObject
51
+ * @var Registry|MockObject
22
52
*/
23
53
protected $ registry ;
24
54
25
55
/**
26
- * @var \Magento\Framework\Api\ ExtensionAttributesFactory|\PHPUnit_Framework_MockObject_MockObject
56
+ * @var ExtensionAttributesFactory|MockObject
27
57
*/
28
58
protected $ extensionFactory ;
29
59
30
60
/**
31
- * @var \Magento\Framework\Api\ AttributeValueFactory|\PHPUnit_Framework_MockObject_MockObject
61
+ * @var AttributeValueFactory|MockObject
32
62
*/
33
63
protected $ customAttributeFactory ;
34
64
35
65
/**
36
- * @var \Magento\Eav\Model\ Config|\PHPUnit_Framework_MockObject_MockObject
66
+ * @var Config|MockObject
37
67
*/
38
68
protected $ eavConfig ;
39
69
40
70
/**
41
- * @var \Magento\Eav\Model\Entity\ TypeFactory|\PHPUnit_Framework_MockObject_MockObject
71
+ * @var TypeFactory|MockObject
42
72
*/
43
73
protected $ eavTypeFactory ;
44
74
45
75
/**
46
- * @var \Magento\Store\Model\ StoreManager|\PHPUnit_Framework_MockObject_MockObject
76
+ * @var StoreManager|MockObject
47
77
*/
48
78
protected $ storeManager ;
49
79
50
80
/**
51
- * @var \Magento\Eav\Model\ResourceModel\ Helper|\PHPUnit_Framework_MockObject_MockObject
81
+ * @var Helper|MockObject
52
82
*/
53
83
protected $ resourceHelper ;
54
84
55
85
/**
56
- * @var \Magento\Framework\Validator\ UniversalFactory|\PHPUnit_Framework_MockObject_MockObject
86
+ * @var UniversalFactory|MockObject
57
87
*/
58
88
protected $ universalFactory ;
59
89
60
90
/**
61
- * @var \Magento\Eav\Api\Data\ AttributeOptionInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
91
+ * @var AttributeOptionInterfaceFactory|MockObject
62
92
*/
63
93
protected $ optionDataFactory ;
64
94
65
95
/**
66
- * @var \Magento\Framework\Reflection\ DataObjectProcessor|\PHPUnit_Framework_MockObject_MockObject
96
+ * @var DataObjectProcessor|MockObject
67
97
*/
68
98
protected $ dataObjectProcessor ;
69
99
70
100
/**
71
- * @var \Magento\Framework\Api\ DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject
101
+ * @var DataObjectHelper|MockObject
72
102
*/
73
103
protected $ dataObjectHelper ;
74
104
75
105
/**
76
- * @var \Magento\Framework\Stdlib\DateTime\ Timezone|\PHPUnit_Framework_MockObject_MockObject
106
+ * @var Timezone|MockObject
77
107
*/
78
108
protected $ localeDate ;
79
109
80
110
/**
81
- * @var \Magento\Catalog\Model\Product\ ReservedAttributeList|\PHPUnit_Framework_MockObject_MockObject
111
+ * @var ReservedAttributeList|MockObject
82
112
*/
83
113
protected $ reservedAttributeList ;
84
114
85
115
/**
86
- * @var \Magento\Framework\Locale\ Resolver|\PHPUnit_Framework_MockObject_MockObject
116
+ * @var Resolver|MockObject
87
117
*/
88
118
protected $ localeResolver ;
89
119
90
120
/**
91
- * @var \Magento\Catalog\Model\ResourceModel\ Product|\PHPUnit_Framework_MockObject_MockObject
121
+ * @var Product|MockObject
92
122
*/
93
123
protected $ resource ;
94
124
95
125
/**
96
- * @var \PHPUnit_Framework_MockObject_MockObject
126
+ * @var MockObject
97
127
*/
98
128
protected $ resourceCollection ;
99
129
100
130
/**
101
- * @var \Magento\Backend\Block\Template\Context|\PHPUnit_Framework_MockObject_MockObject
131
+ * @var \Magento\Backend\Block\Template\Context|MockObject
102
132
*/
103
133
protected $ context ;
104
134
105
135
/**
106
- * @var \Magento\Backend\Helper\ Data|\PHPUnit_Framework_MockObject_MockObject
136
+ * @var Data|MockObject
107
137
*/
108
138
protected $ backendHelper ;
109
139
110
140
/**
111
- * @var \Magento\ImportExport\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
141
+ * @var \Magento\ImportExport\Helper\Data|MockObject
112
142
*/
113
143
protected $ importExportData ;
114
144
@@ -118,36 +148,36 @@ class FilterTest extends \PHPUnit\Framework\TestCase
118
148
protected $ objectManagerHelper ;
119
149
120
150
/**
121
- * @var \Magento\ImportExport\Block\Adminhtml\Export\ Filter|\PHPUnit_Framework_MockObject_MockObject
151
+ * @var Filter|MockObject
122
152
*/
123
153
protected $ filter ;
124
154
125
155
/**
126
- * @var \Magento\Framework\Stdlib\DateTime\ DateTimeFormatterInterface|\PHPUnit_Framework_MockObject_MockObject
156
+ * @var DateTimeFormatterInterface|MockObject
127
157
*/
128
158
private $ dateTimeFormatter ;
129
159
130
- protected function setUp ()
160
+ protected function setUp (): void
131
161
{
132
- $ this ->modelContext = $ this ->createMock (\ Magento \ Framework \ Model \ Context::class);
133
- $ this ->registry = $ this ->createMock (\ Magento \ Framework \ Registry::class);
134
- $ this ->extensionFactory = $ this ->createMock (\ Magento \ Framework \ Api \ ExtensionAttributesFactory::class);
135
- $ this ->customAttributeFactory = $ this ->createMock (\ Magento \ Framework \ Api \ AttributeValueFactory::class);
136
- $ this ->eavConfig = $ this ->createMock (\ Magento \ Eav \ Model \ Config::class);
137
- $ this ->eavTypeFactory = $ this ->createMock (\ Magento \ Eav \ Model \ Entity \ TypeFactory::class);
138
- $ this ->storeManager = $ this ->createMock (\ Magento \ Store \ Model \ StoreManager::class);
139
- $ this ->resourceHelper = $ this ->createMock (\ Magento \ Eav \ Model \ ResourceModel \ Helper::class);
140
- $ this ->universalFactory = $ this ->createMock (\ Magento \ Framework \ Validator \ UniversalFactory::class);
141
- $ this ->optionDataFactory = $ this ->createMock (\ Magento \ Eav \ Api \ Data \ AttributeOptionInterfaceFactory::class);
142
- $ this ->dataObjectProcessor = $ this ->createMock (\ Magento \ Framework \ Reflection \ DataObjectProcessor::class);
143
- $ this ->dataObjectHelper = $ this ->createMock (\ Magento \ Framework \ Api \ DataObjectHelper::class);
144
- $ this ->localeDate = $ this ->createMock (\ Magento \ Framework \ Stdlib \ DateTime \ Timezone::class);
162
+ $ this ->modelContext = $ this ->createMock (Context::class);
163
+ $ this ->registry = $ this ->createMock (Registry::class);
164
+ $ this ->extensionFactory = $ this ->createMock (ExtensionAttributesFactory::class);
165
+ $ this ->customAttributeFactory = $ this ->createMock (AttributeValueFactory::class);
166
+ $ this ->eavConfig = $ this ->createMock (Config::class);
167
+ $ this ->eavTypeFactory = $ this ->createMock (TypeFactory::class);
168
+ $ this ->storeManager = $ this ->createMock (StoreManager::class);
169
+ $ this ->resourceHelper = $ this ->createMock (Helper::class);
170
+ $ this ->universalFactory = $ this ->createMock (UniversalFactory::class);
171
+ $ this ->optionDataFactory = $ this ->createMock (AttributeOptionInterfaceFactory::class);
172
+ $ this ->dataObjectProcessor = $ this ->createMock (DataObjectProcessor::class);
173
+ $ this ->dataObjectHelper = $ this ->createMock (DataObjectHelper::class);
174
+ $ this ->localeDate = $ this ->createMock (Timezone::class);
145
175
$ this ->localeDate ->expects ($ this ->any ())->method ('getDateFormat ' )->will ($ this ->returnValue ('12-12-2012 ' ));
146
- $ this ->reservedAttributeList = $ this ->createMock (\ Magento \ Catalog \ Model \ Product \ ReservedAttributeList::class);
147
- $ this ->localeResolver = $ this ->createMock (\ Magento \ Framework \ Locale \ Resolver::class);
148
- $ this ->resource = $ this ->createMock (\ Magento \ Catalog \ Model \ ResourceModel \ Product::class);
176
+ $ this ->reservedAttributeList = $ this ->createMock (ReservedAttributeList::class);
177
+ $ this ->localeResolver = $ this ->createMock (Resolver::class);
178
+ $ this ->resource = $ this ->createMock (Product::class);
149
179
$ this ->resourceCollection = $ this ->getMockForAbstractClass (
150
- \ Magento \ Framework \ Data \ Collection \ AbstractDb::class,
180
+ AbstractDb::class,
151
181
[],
152
182
'' ,
153
183
false
@@ -156,33 +186,33 @@ protected function setUp()
156
186
\Magento \Backend \Block \Template \Context::class,
157
187
['getFileSystem ' , 'getEscaper ' , 'getLocaleDate ' , 'getLayout ' ]
158
188
);
159
- $ filesystem = $ this ->createMock (\ Magento \ Framework \ Filesystem::class);
189
+ $ filesystem = $ this ->createMock (Filesystem::class);
160
190
$ this ->context ->expects ($ this ->any ())->method ('getFileSystem ' )->will ($ this ->returnValue ($ filesystem ));
161
- $ escaper = $ this ->createPartialMock (\ Magento \ Framework \ Escaper::class, ['escapeHtml ' ]);
191
+ $ escaper = $ this ->createPartialMock (Escaper::class, ['escapeHtml ' ]);
162
192
$ escaper ->expects ($ this ->any ())->method ('escapeHtml ' )->will ($ this ->returnValue ('' ));
163
193
$ this ->context ->expects ($ this ->any ())->method ('getEscaper ' )->will ($ this ->returnValue ($ escaper ));
164
- $ timeZone = $ this ->createMock (\ Magento \ Framework \ Stdlib \ DateTime \ Timezone::class);
194
+ $ timeZone = $ this ->createMock (Timezone::class);
165
195
$ timeZone ->expects ($ this ->any ())->method ('getDateFormat ' )->will ($ this ->returnValue ('M/d/yy ' ));
166
196
$ this ->context ->expects ($ this ->any ())->method ('getLocaleDate ' )->will ($ this ->returnValue ($ timeZone ));
167
197
$ dateBlock = $ this ->createPartialMock (
168
- \ Magento \ Framework \ View \ Element \ Html \ Date::class,
198
+ Date::class,
169
199
['setValue ' , 'getHtml ' , 'setId ' , 'getId ' ]
170
200
);
171
201
$ dateBlock ->expects ($ this ->any ())->method ('setValue ' )->will ($ this ->returnSelf ());
172
202
$ dateBlock ->expects ($ this ->any ())->method ('getHtml ' )->will ($ this ->returnValue ('' ));
173
203
$ dateBlock ->expects ($ this ->any ())->method ('setId ' )->will ($ this ->returnSelf ());
174
204
$ dateBlock ->expects ($ this ->any ())->method ('getId ' )->will ($ this ->returnValue (1 ));
175
- $ layout = $ this ->createMock (\ Magento \ Framework \ View \ Layout::class);
205
+ $ layout = $ this ->createMock (Layout::class);
176
206
$ layout ->expects ($ this ->any ())->method ('createBlock ' )->will ($ this ->returnValue ($ dateBlock ));
177
207
$ this ->context ->expects ($ this ->any ())->method ('getLayout ' )->will ($ this ->returnValue ($ layout ));
178
- $ this ->backendHelper = $ this ->createMock (\ Magento \ Backend \ Helper \ Data::class);
208
+ $ this ->backendHelper = $ this ->createMock (Data::class);
179
209
$ this ->importExportData = $ this ->createMock (\Magento \ImportExport \Helper \Data::class);
180
210
$ this ->dateTimeFormatter = $ this ->createMock (
181
- \ Magento \ Framework \ Stdlib \ DateTime \ DateTimeFormatterInterface::class
211
+ DateTimeFormatterInterface::class
182
212
);
183
213
$ this ->objectManagerHelper = new ObjectManagerHelper ($ this );
184
214
$ this ->filter = $ this ->objectManagerHelper ->getObject (
185
- \ Magento \ ImportExport \ Block \ Adminhtml \ Export \ Filter::class,
215
+ Filter::class,
186
216
[
187
217
'context ' => $ this ->context ,
188
218
'backendHelper ' => $ this ->backendHelper ,
@@ -202,7 +232,7 @@ protected function setUp()
202
232
public function testDecorateFilter ($ attributeData , $ backendType , $ columnValue )
203
233
{
204
234
$ value = '' ;
205
- $ attribute = new \ Magento \ Eav \ Model \ Entity \ Attribute (
235
+ $ attribute = new Attribute (
206
236
$ this ->modelContext ,
207
237
$ this ->registry ,
208
238
$ this ->extensionFactory ,
@@ -227,7 +257,7 @@ public function testDecorateFilter($attributeData, $backendType, $columnValue)
227
257
$ attribute ->setOptions ($ attributeData ['options ' ]);
228
258
$ attribute ->setFilterOptions ($ attributeData ['filter_options ' ]);
229
259
$ attribute ->setBackendType ($ backendType );
230
- $ column = new \ Magento \ Framework \ DataObject ();
260
+ $ column = new DataObject ();
231
261
$ column ->setData ($ columnValue , 'value ' );
232
262
$ isExport = true ;
233
263
$ result = $ this ->filter ->decorateFilter ($ value , $ attribute , $ column , $ isExport );
0 commit comments