Completed
Push — feature/reorg ( 2e8e86...35db6f )
by
unknown
25:00 queued 15:50
created

admin-menu.php ➔ get_menu_fixture()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 126

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 126
rs 8
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Fixture data for admin menu tests.
4
 *
5
 * @package Jetpack
6
 */
7
8
/**
9
 * Menu fixture data.
10
 *
11
 * @return \string[][]
12
 */
13
function get_menu_fixture() {
14
	return array(
15
		2  => array(
16
			'Dashboard',
17
			'read',
18
			'index.php',
19
			'',
20
			'menu-top menu-top-first menu-icon-dashboard',
21
			'menu-dashboard',
22
			'dashicons-dashboard',
23
		),
24
		3  => array(
25
			'Jetpack',
26
			'jetpack_admin_page',
27
			'jetpack',
28
			'Jetpack',
29
			'menu-top toplevel_page_jetpack',
30
			'toplevel_page_jetpack',
31
			'div',
32
		),
33
		4  => array(
34
			'',
35
			'read',
36
			'separator1',
37
			'',
38
			'wp-menu-separator',
39
		),
40
		10 => array(
41
			'Media',
42
			'upload_files',
43
			'upload.php',
44
			'',
45
			'menu-top menu-icon-media',
46
			'menu-media',
47
			'dashicons-admin-media',
48
		),
49
		15 => array(
50
			'Links',
51
			'manage_links',
52
			'edit-tags.php?taxonomy=link_category',
53
			'',
54
			'menu-top menu-icon-links',
55
			'menu-links',
56
			'dashicons-admin-links',
57
		),
58
		25 => array(
59
			'Comments <span class="awaiting-mod count-3"><span class="pending-count" aria-hidden="true">3</span><span class="comments-in-moderation-text screen-reader-text">3 Comments in moderation</span></span>',
60
			'edit_posts',
61
			'edit-comments.php',
62
			'',
63
			'menu-top menu-icon-comments',
64
			'menu-comments',
65
			'dashicons-admin-comments',
66
		),
67
		5  => array(
68
			'Posts',
69
			'edit_posts',
70
			'edit.php',
71
			'',
72
			'menu-top menu-icon-post open-if-no-js',
73
			'menu-posts',
74
			'dashicons-admin-post',
75
		),
76
		20 => array(
77
			'Pages',
78
			'edit_pages',
79
			'edit.php?post_type=page',
80
			'',
81
			'menu-top menu-icon-page',
82
			'menu-pages',
83
			'dashicons-admin-page',
84
		),
85
		59 => array(
86
			'',
87
			'read',
88
			'separator2',
89
			'',
90
			'wp-menu-separator',
91
		),
92
		60 => array(
93
			'Appearance',
94
			'switch_themes',
95
			'themes.php',
96
			'',
97
			'menu-top menu-icon-appearance',
98
			'menu-appearance',
99
			'dashicons-admin-appearance',
100
		),
101
		65 => array(
102
			'Plugins <span class="update-plugins count-4"><span class="plugin-count">4</span></span>',
103
			'activate_plugins',
104
			'plugins.php',
105
			'',
106
			'menu-top menu-icon-plugins',
107
			'menu-plugins',
108
			'dashicons-admin-plugins',
109
		),
110
		70 => array(
111
			'Users <span class="update-plugins count-0"><span class="plugin-count">0</span></span>',
112
			'list_users',
113
			'users.php',
114
			'',
115
			'menu-top menu-icon-users',
116
			'menu-users',
117
			'dashicons-admin-users',
118
		),
119
		75 => array(
120
			'Tools',
121
			'edit_posts',
122
			'tools.php',
123
			'',
124
			'menu-top menu-icon-tools',
125
			'menu-tools',
126
			'dashicons-admin-tools',
127
		),
128
		80 => array(
129
			'Settings',
130
			'manage_options',
131
			'options-general.php',
132
			'',
133
			'menu-top menu-icon-settings',
134
			'menu-settings',
135
			'dashicons-admin-settings',
136
		),
137
	);
138
}
139
140
/**
141
 * Submenu fixture data.
142
 *
143
 * @return \string[][][]
144
 */
145
function get_submenu_fixture() {
146
	return array(
147
		'index.php'                            => array(
148
			0  => array(
149
				'Home',
150
				'read',
151
				'index.php',
152
			),
153
			10 => array(
154
				'Updates <span class="update-plugins count-4"><span class="update-count">4</span></span>',
155
				'update_core',
156
				'update-core.php',
157
			),
158
		),
159
		'upload.php'                           => array(
160
			5  => array(
161
				'Library',
162
				'upload_files',
163
				'upload.php',
164
			),
165
			10 => array(
166
				'Add New',
167
				'upload_files',
168
				'media-new.php',
169
			),
170
		),
171
		'edit-comments.php'                    => array(
172
			0 => array(
173
				'All Comments',
174
				'edit_posts',
175
				'edit-comments.php',
176
			),
177
		),
178
		'edit.php'                             => array(
179
			5  => array(
180
				'All Posts',
181
				'edit_posts',
182
				'edit.php',
183
			),
184
			10 => array(
185
				'Add New',
186
				'edit_posts',
187
				'post-new.php',
188
			),
189
			15 => array(
190
				'Categories',
191
				'manage_categories',
192
				'edit-tags.php?taxonomy=category',
193
			),
194
			16 => array(
195
				'Tags',
196
				'manage_post_tags',
197
				'edit-tags.php?taxonomy=post_tag',
198
			),
199
		),
200
		'edit.php?post_type=page'              => array(
201
			5  => array(
202
				'All Pages',
203
				'edit_pages',
204
				'edit.php?post_type=page',
205
			),
206
			10 => array(
207
				'Add New',
208
				'edit_pages',
209
				'post-new.php?post_type=page',
210
			),
211
		),
212
		'themes.php'                           => array(
213
			5  => array(
214
				'Themes',
215
				'switch_themes',
216
				'themes.php',
217
			),
218
			6  => array(
219
				'Customize',
220
				'customize',
221
				'customize.php?return=%2Ftrunk%2Fwp-admin%2Fadmin.php%3Fpage%3Djetpack',
222
				'',
223
				'hide-if-no-customize',
224
			),
225
			10 => array(
226
				'Menus',
227
				'edit_theme_options',
228
				'nav-menus.php',
229
			),
230
			11 => array(
231
				'Widgets',
232
				'edit_theme_options',
233
				'gutenberg-widgets',
234
				'Widgets',
235
			),
236
			13 => array(
237
				'Theme Editor',
238
				'edit_themes',
239
				'theme-editor.php',
240
				'Theme Editor',
241
			),
242
		),
243
		'plugins.php'                          => array(
244
			5  => array(
245
				'Installed Plugins',
246
				'activate_plugins',
247
				'plugins.php',
248
			),
249
			10 => array(
250
				'Add New',
251
				'install_plugins',
252
				'plugin-install.php',
253
			),
254
			15 => array(
255
				'Plugin Editor',
256
				'edit_plugins',
257
				'plugin-editor.php',
258
			),
259
		),
260
		'users.php'                            => array(
261
			5  => array(
262
				'All Users',
263
				'list_users',
264
				'users.php',
265
			),
266
			10 => array(
267
				'Add New',
268
				'create_users',
269
				'user-new.php',
270
			),
271
			15 => array(
272
				'Profile',
273
				'read',
274
				'profile.php',
275
			),
276
		),
277
		'tools.php'                            => array(
278
			5  => array(
279
				'Available Tools',
280
				'edit_posts',
281
				'tools.php',
282
			),
283
			10 => array(
284
				'Import',
285
				'import',
286
				'import.php',
287
			),
288
			15 => array(
289
				'Export',
290
				'export',
291
				'export.php',
292
			),
293
			20 => array(
294
				'Site Health',
295
				'view_site_health_checks',
296
				'site-health.php',
297
			),
298
			25 => array(
299
				'Export Personal Data',
300
				'export_others_personal_data',
301
				'export-personal-data.php',
302
			),
303
			30 => array(
304
				'Erase Personal Data',
305
				'erase_others_personal_data',
306
				'erase-personal-data.php',
307
			),
308
		),
309
		'options-general.php'                  => array(
310
			10 => array(
311
				'General',
312
				'manage_options',
313
				'options-general.php',
314
			),
315
			15 => array(
316
				'Writing',
317
				'manage_options',
318
				'options-writing.php',
319
			),
320
			20 => array(
321
				'Reading',
322
				'manage_options',
323
				'options-reading.php',
324
			),
325
			25 => array(
326
				'Discussion',
327
				'manage_options',
328
				'options-discussion.php',
329
			),
330
			30 => array(
331
				'Media',
332
				'manage_options',
333
				'options-media.php',
334
			),
335
			40 => array(
336
				'Permalinks',
337
				'manage_options',
338
				'options-permalink.php',
339
			),
340
			45 => array(
341
				'Privacy',
342
				'manage_privacy_options',
343
				'options-privacy.php',
344
			),
345
			46 => array(
346
				'Approve User',
347
				'promote_users',
348
				'wp-approve-user',
349
				'Approve User',
350
			),
351
			47 => array(
352
				'',
353
				'manage_options',
354
				'sharing',
355
				'',
356
			),
357
		),
358
		'edit-tags.php?taxonomy=link_category' => array(
359
			15 => array(
360
				'Link Categories',
361
				'manage_categories',
362
				'edit-tags.php?taxonomy=link_category',
363
			),
364
		),
365
366
		''                                     => array(
367
			0 => array(
368
				'',
369
				'manage_options',
370
				'jetpack-debugger',
371
				'Debugging Center',
372
			),
373
			1 => array(
374
				'Settings',
375
				'jetpack_manage_modules',
376
				'jetpack_modules',
377
				'Jetpack Settings',
378
			),
379
			2 => array(
380
				'',
381
				'jetpack_admin_page',
382
				'jetpack_about',
383
				'About Jetpack',
384
			),
385
		),
386
		'edit.php?post_type=feedback'          => array(
387
			0 => array(
388
				'Feedback',
389
				'edit_pages',
390
				'edit.php?post_type=feedback',
391
				'',
392
			),
393
			1 => array(
394
				'Export CSV',
395
				'export',
396
				'feedback-export',
397
				'Export feedback as CSV',
398
			),
399
		),
400
		'jetpack'                              => array(
401
			1 => array(
402
				'Dashboard',
403
				'jetpack_admin_page',
404
				'jetpack#/dashboard',
405
				'Dashboard',
406
			),
407
			2 => array(
408
				'Settings',
409
				'jetpack_admin_page',
410
				'jetpack#/settings',
411
				'Settings',
412
			),
413
		),
414
	);
415
}
416