22
22
*/
23
23
class GroupActionsTest extends TestCase
24
24
{
25
+ /**
26
+ * @var int
27
+ */
28
+ private const STUB_NOT_LOGGED_IN_CUSTOMER_GROUP_ID = 0 ;
29
+
30
+ /**
31
+ * @var string
32
+ */
33
+ private const STUB_NOT_LOGGED_IN_CUSTOMER_GROUP_NAME = 'Not Logged In ' ;
34
+
35
+ /**
36
+ * @var int
37
+ */
38
+ private const STUB_GENERAL_CUSTOMER_GROUP_ID = 1 ;
39
+
40
+ /**
41
+ * @var string
42
+ */
43
+ private const STUB_GENERAL_CUSTOMER_GROUP_NAME = 'General ' ;
44
+
45
+ /**
46
+ * @var string
47
+ */
48
+ private const STUB_GROUP_EDIT_URL = 'http://magento.com/customer/group/edit ' ;
49
+
50
+ /**
51
+ * @var string
52
+ */
53
+ private const STUB_GROUP_DELETE_URL = 'http://magento.com/customer/group/delete ' ;
54
+
25
55
/**
26
56
* @var GroupActions
27
57
*/
@@ -97,7 +127,6 @@ public function setUp()
97
127
*/
98
128
public function testPrepareDataSourceWithNonDefaultGroup (array $ items , bool $ isDefaultGroup , array $ expected )
99
129
{
100
- $ customerGroup = 'General ' ;
101
130
$ dataSource = [
102
131
'data ' => [
103
132
'items ' => $ items
@@ -111,18 +140,29 @@ public function testPrepareDataSourceWithNonDefaultGroup(array $items, bool $isD
111
140
112
141
$ this ->groupManagementMock ->expects ($ this ->any ())
113
142
->method ('isReadonly ' )
114
- ->with (1 )
143
+ ->with (static :: STUB_GENERAL_CUSTOMER_GROUP_ID )
115
144
->willReturn ($ isDefaultGroup );
116
145
$ this ->escaperMock ->expects ($ this ->any ())
117
146
->method ('escapeHtml ' )
118
- ->with ($ customerGroup )
119
- ->willReturn ($ customerGroup );
147
+ ->with (static :: STUB_GENERAL_CUSTOMER_GROUP_NAME )
148
+ ->willReturn (static :: STUB_GENERAL_CUSTOMER_GROUP_NAME );
120
149
$ this ->urlBuilderMock ->expects ($ this ->any ())
121
150
->method ('getUrl ' )
122
151
->willReturnMap (
123
152
[
124
- ['customer/group/edit ' , ['id ' => 1 ], 'http://magento.com/customer/group/edit ' ],
125
- ['customer/group/delete ' , ['id ' => 1 ], 'http://magento.com/customer/group/delete ' ]
153
+ [
154
+ 'customer/group/edit ' ,
155
+ [
156
+ 'id ' => static ::STUB_GENERAL_CUSTOMER_GROUP_ID
157
+ ],
158
+ static ::STUB_GROUP_EDIT_URL ],
159
+ [
160
+ 'customer/group/delete ' ,
161
+ [
162
+ 'id ' => static ::STUB_GENERAL_CUSTOMER_GROUP_ID
163
+ ],
164
+ static ::STUB_GROUP_DELETE_URL
165
+ ]
126
166
]
127
167
);
128
168
@@ -142,12 +182,12 @@ public function testPrepareDataSourceWithDefaultGroup()
142
182
'data ' => [
143
183
'items ' => [
144
184
[
145
- 'customer_group_id ' => 1 ,
146
- 'customer_group_code ' => ' General ' ,
185
+ 'customer_group_id ' => static :: STUB_GENERAL_CUSTOMER_GROUP_ID ,
186
+ 'customer_group_code ' => static :: STUB_GENERAL_CUSTOMER_GROUP_NAME ,
147
187
],
148
188
[
149
- 'customer_group_id ' => 0 ,
150
- 'customer_group_code ' => ' Not Logged In ' ,
189
+ 'customer_group_id ' => static :: STUB_NOT_LOGGED_IN_CUSTOMER_GROUP_ID ,
190
+ 'customer_group_code ' => static :: STUB_NOT_LOGGED_IN_CUSTOMER_GROUP_NAME ,
151
191
],
152
192
]
153
193
]
@@ -156,22 +196,22 @@ public function testPrepareDataSourceWithDefaultGroup()
156
196
'data ' => [
157
197
'items ' => [
158
198
[
159
- 'customer_group_id ' => 1 ,
160
- 'customer_group_code ' => ' General ' ,
199
+ 'customer_group_id ' => static :: STUB_GENERAL_CUSTOMER_GROUP_ID ,
200
+ 'customer_group_code ' => static :: STUB_GENERAL_CUSTOMER_GROUP_NAME ,
161
201
'name ' => [
162
202
'edit ' => [
163
- 'href ' => ' http://magento.com/customer/group/edit ' ,
203
+ 'href ' => static :: STUB_GROUP_EDIT_URL ,
164
204
'label ' => __ ('Edit ' ),
165
205
'__disableTmpl ' => true ,
166
206
]
167
207
]
168
208
],
169
209
[
170
- 'customer_group_id ' => 0 ,
171
- 'customer_group_code ' => ' Not Logged In ' ,
210
+ 'customer_group_id ' => static :: STUB_NOT_LOGGED_IN_CUSTOMER_GROUP_ID ,
211
+ 'customer_group_code ' => static :: STUB_NOT_LOGGED_IN_CUSTOMER_GROUP_NAME ,
172
212
'name ' => [
173
213
'edit ' => [
174
- 'href ' => ' http://magento.com/customer/group/edit ' ,
214
+ 'href ' => static :: STUB_GROUP_EDIT_URL ,
175
215
'label ' => __ ('Edit ' ),
176
216
'__disableTmpl ' => true ,
177
217
]
@@ -188,16 +228,36 @@ public function testPrepareDataSourceWithDefaultGroup()
188
228
->method ('escapeHtml ' )
189
229
->willReturnMap (
190
230
[
191
- ['General ' , null , 'General ' ],
192
- ['Not Logged In ' , null , 'Not Logged In ' ]
231
+ [
232
+ static ::STUB_GENERAL_CUSTOMER_GROUP_NAME ,
233
+ null ,
234
+ static ::STUB_GENERAL_CUSTOMER_GROUP_NAME
235
+ ],
236
+ [
237
+ static ::STUB_NOT_LOGGED_IN_CUSTOMER_GROUP_NAME ,
238
+ null ,
239
+ static ::STUB_NOT_LOGGED_IN_CUSTOMER_GROUP_NAME
240
+ ]
193
241
]
194
242
);
195
243
$ this ->urlBuilderMock ->expects ($ this ->any ())
196
244
->method ('getUrl ' )
197
245
->willReturnMap (
198
246
[
199
- ['customer/group/edit ' , ['id ' => 1 ], 'http://magento.com/customer/group/edit ' ],
200
- ['customer/group/edit ' , ['id ' => 0 ], 'http://magento.com/customer/group/edit ' ]
247
+ [
248
+ 'customer/group/edit ' ,
249
+ [
250
+ 'id ' => static ::STUB_GENERAL_CUSTOMER_GROUP_ID
251
+ ],
252
+ static ::STUB_GROUP_EDIT_URL
253
+ ],
254
+ [
255
+ 'customer/group/edit ' ,
256
+ [
257
+ 'id ' => static ::STUB_NOT_LOGGED_IN_CUSTOMER_GROUP_ID
258
+ ],
259
+ static ::STUB_GROUP_EDIT_URL
260
+ ]
201
261
]
202
262
);
203
263
@@ -216,23 +276,23 @@ public function customerGroupsDataProvider(): array
216
276
[
217
277
[
218
278
[
219
- 'customer_group_id ' => 1 ,
220
- 'customer_group_code ' => ' General ' ,
279
+ 'customer_group_id ' => static :: STUB_GENERAL_CUSTOMER_GROUP_ID ,
280
+ 'customer_group_code ' => static :: STUB_GENERAL_CUSTOMER_GROUP_NAME ,
221
281
],
222
282
],
223
283
false ,
224
284
[
225
285
[
226
- 'customer_group_id ' => 1 ,
227
- 'customer_group_code ' => ' General ' ,
286
+ 'customer_group_id ' => static :: STUB_GENERAL_CUSTOMER_GROUP_ID ,
287
+ 'customer_group_code ' => static :: STUB_GENERAL_CUSTOMER_GROUP_NAME ,
228
288
'name ' => [
229
289
'edit ' => [
230
- 'href ' => ' http://magento.com/customer/group/edit ' ,
290
+ 'href ' => static :: STUB_GROUP_EDIT_URL ,
231
291
'label ' => __ ('Edit ' ),
232
292
'__disableTmpl ' => true ,
233
293
],
234
294
'delete ' => [
235
- 'href ' => ' http://magento.com/customer/group/delete ' ,
295
+ 'href ' => static :: STUB_GROUP_DELETE_URL ,
236
296
'label ' => __ ('Delete ' ),
237
297
'post ' => true ,
238
298
'__disableTmpl ' => true ,
0 commit comments