Skip to content

Commit 5d0e12b

Browse files
committed
Adjusting the Unit Test
1 parent 86ff8fa commit 5d0e12b

File tree

1 file changed

+86
-26
lines changed

1 file changed

+86
-26
lines changed

app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php

Lines changed: 86 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,36 @@
2222
*/
2323
class GroupActionsTest extends TestCase
2424
{
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+
2555
/**
2656
* @var GroupActions
2757
*/
@@ -97,7 +127,6 @@ public function setUp()
97127
*/
98128
public function testPrepareDataSourceWithNonDefaultGroup(array $items, bool $isDefaultGroup, array $expected)
99129
{
100-
$customerGroup = 'General';
101130
$dataSource = [
102131
'data' => [
103132
'items' => $items
@@ -111,18 +140,29 @@ public function testPrepareDataSourceWithNonDefaultGroup(array $items, bool $isD
111140

112141
$this->groupManagementMock->expects($this->any())
113142
->method('isReadonly')
114-
->with(1)
143+
->with(static::STUB_GENERAL_CUSTOMER_GROUP_ID)
115144
->willReturn($isDefaultGroup);
116145
$this->escaperMock->expects($this->any())
117146
->method('escapeHtml')
118-
->with($customerGroup)
119-
->willReturn($customerGroup);
147+
->with(static::STUB_GENERAL_CUSTOMER_GROUP_NAME)
148+
->willReturn(static::STUB_GENERAL_CUSTOMER_GROUP_NAME);
120149
$this->urlBuilderMock->expects($this->any())
121150
->method('getUrl')
122151
->willReturnMap(
123152
[
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+
]
126166
]
127167
);
128168

@@ -142,12 +182,12 @@ public function testPrepareDataSourceWithDefaultGroup()
142182
'data' => [
143183
'items' => [
144184
[
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,
147187
],
148188
[
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,
151191
],
152192
]
153193
]
@@ -156,22 +196,22 @@ public function testPrepareDataSourceWithDefaultGroup()
156196
'data' => [
157197
'items' => [
158198
[
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,
161201
'name' => [
162202
'edit' => [
163-
'href' => 'http://magento.com/customer/group/edit',
203+
'href' => static::STUB_GROUP_EDIT_URL,
164204
'label' => __('Edit'),
165205
'__disableTmpl' => true,
166206
]
167207
]
168208
],
169209
[
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,
172212
'name' => [
173213
'edit' => [
174-
'href' => 'http://magento.com/customer/group/edit',
214+
'href' => static::STUB_GROUP_EDIT_URL,
175215
'label' => __('Edit'),
176216
'__disableTmpl' => true,
177217
]
@@ -188,16 +228,36 @@ public function testPrepareDataSourceWithDefaultGroup()
188228
->method('escapeHtml')
189229
->willReturnMap(
190230
[
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+
]
193241
]
194242
);
195243
$this->urlBuilderMock->expects($this->any())
196244
->method('getUrl')
197245
->willReturnMap(
198246
[
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+
]
201261
]
202262
);
203263

@@ -216,23 +276,23 @@ public function customerGroupsDataProvider(): array
216276
[
217277
[
218278
[
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,
221281
],
222282
],
223283
false,
224284
[
225285
[
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,
228288
'name' => [
229289
'edit' => [
230-
'href' => 'http://magento.com/customer/group/edit',
290+
'href' => static::STUB_GROUP_EDIT_URL,
231291
'label' => __('Edit'),
232292
'__disableTmpl' => true,
233293
],
234294
'delete' => [
235-
'href' => 'http://magento.com/customer/group/delete',
295+
'href' => static::STUB_GROUP_DELETE_URL,
236296
'label' => __('Delete'),
237297
'post' => true,
238298
'__disableTmpl' => true,

0 commit comments

Comments
 (0)