Completed
Push — add/jp-search-sync ( 4d1654...438834 )
by
unknown
19:40 queued 10:03
created

admin-menu.php ➔ get_wpcom_menu_fixture()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 23
rs 9.552
c 0
b 0
f 0
1
<?php
2
/**
3
 * Fixture data for admin menu tests.
4
 *
5
 * @package automattic/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
 * WPCom Menu fixture data.
142
 *
143
 * @return \string[][]
144
 */
145
function get_wpcom_menu_fixture() {
146
	$gutenberg_menus = array(
147
		100 => array(
148
			'Site Editor <span class="awaiting-mod">beta</span>',
149
			'edit_theme_options',
150
			'gutenberg-edit-site',
151
			'Site Editor (beta)',
152
			'menu-top toplevel_page_gutenberg-edit-site',
153
			'toplevel_page_gutenberg-edit-site',
154
			'dashicons-layout',
155
		),
156
		101 => array(
157
			'Gutenberg',
158
			'edit_posts',
159
			'gutenberg',
160
			'Gutenberg',
161
			'menu-top toplevel_page_gutenberg',
162
			'toplevel_page_gutenberg',
163
			'dashicons-edit',
164
		),
165
	);
166
	return get_menu_fixture() + $gutenberg_menus;
167
}
168
169
/**
170
 * Submenu fixture data.
171
 *
172
 * @return \string[][][]
173
 */
174
function get_submenu_fixture() {
175
	return array(
176
		'index.php'                            => array(
177
			0  => array(
178
				'Home',
179
				'read',
180
				'index.php',
181
			),
182
			10 => array(
183
				'Updates <span class="update-plugins count-4"><span class="update-count">4</span></span>',
184
				'update_core',
185
				'update-core.php',
186
			),
187
		),
188
		'upload.php'                           => array(
189
			5  => array(
190
				'Library',
191
				'upload_files',
192
				'upload.php',
193
			),
194
			10 => array(
195
				'Add New',
196
				'upload_files',
197
				'media-new.php',
198
			),
199
		),
200
		'edit-comments.php'                    => array(
201
			0 => array(
202
				'All Comments',
203
				'edit_posts',
204
				'edit-comments.php',
205
			),
206
		),
207
		'edit.php'                             => array(
208
			5  => array(
209
				'All Posts',
210
				'edit_posts',
211
				'edit.php',
212
			),
213
			10 => array(
214
				'Add New',
215
				'edit_posts',
216
				'post-new.php',
217
			),
218
			15 => array(
219
				'Categories',
220
				'manage_categories',
221
				'edit-tags.php?taxonomy=category',
222
			),
223
			16 => array(
224
				'Tags',
225
				'manage_post_tags',
226
				'edit-tags.php?taxonomy=post_tag',
227
			),
228
		),
229
		'edit.php?post_type=page'              => array(
230
			5  => array(
231
				'All Pages',
232
				'edit_pages',
233
				'edit.php?post_type=page',
234
			),
235
			10 => array(
236
				'Add New',
237
				'edit_pages',
238
				'post-new.php?post_type=page',
239
			),
240
		),
241
		'themes.php'                           => array(
242
			5  => array(
243
				'Themes',
244
				'switch_themes',
245
				'themes.php',
246
			),
247
			6  => array(
248
				'Customize',
249
				'customize',
250
				'customize.php?return=%2Ftrunk%2Fwp-admin%2Fadmin.php%3Fpage%3Djetpack',
251
				'',
252
				'hide-if-no-customize',
253
			),
254
			10 => array(
255
				'Menus',
256
				'edit_theme_options',
257
				'nav-menus.php',
258
			),
259
			11 => array(
260
				'Widgets',
261
				'edit_theme_options',
262
				'gutenberg-widgets',
263
				'Widgets',
264
			),
265
			13 => array(
266
				'Theme Editor',
267
				'edit_themes',
268
				'theme-editor.php',
269
				'Theme Editor',
270
			),
271
		),
272
		'plugins.php'                          => array(
273
			5  => array(
274
				'Installed Plugins',
275
				'activate_plugins',
276
				'plugins.php',
277
			),
278
			10 => array(
279
				'Add New',
280
				'install_plugins',
281
				'plugin-install.php',
282
			),
283
			15 => array(
284
				'Plugin Editor',
285
				'edit_plugins',
286
				'plugin-editor.php',
287
			),
288
		),
289
		'users.php'                            => array(
290
			5  => array(
291
				'All Users',
292
				'list_users',
293
				'users.php',
294
			),
295
			10 => array(
296
				'Add New',
297
				'create_users',
298
				'user-new.php',
299
			),
300
			15 => array(
301
				'Profile',
302
				'read',
303
				'profile.php',
304
			),
305
		),
306
		'tools.php'                            => array(
307
			5  => array(
308
				'Available Tools',
309
				'edit_posts',
310
				'tools.php',
311
			),
312
			10 => array(
313
				'Import',
314
				'import',
315
				'import.php',
316
			),
317
			15 => array(
318
				'Export',
319
				'export',
320
				'export.php',
321
			),
322
			20 => array(
323
				'Site Health',
324
				'view_site_health_checks',
325
				'site-health.php',
326
			),
327
			25 => array(
328
				'Export Personal Data',
329
				'export_others_personal_data',
330
				'export-personal-data.php',
331
			),
332
			30 => array(
333
				'Erase Personal Data',
334
				'erase_others_personal_data',
335
				'erase-personal-data.php',
336
			),
337
		),
338
		'options-general.php'                  => array(
339
			10 => array(
340
				'General',
341
				'manage_options',
342
				'options-general.php',
343
			),
344
			15 => array(
345
				'Writing',
346
				'manage_options',
347
				'options-writing.php',
348
			),
349
			20 => array(
350
				'Reading',
351
				'manage_options',
352
				'options-reading.php',
353
			),
354
			25 => array(
355
				'Discussion',
356
				'manage_options',
357
				'options-discussion.php',
358
			),
359
			30 => array(
360
				'Media',
361
				'manage_options',
362
				'options-media.php',
363
			),
364
			40 => array(
365
				'Permalinks',
366
				'manage_options',
367
				'options-permalink.php',
368
			),
369
			45 => array(
370
				'Privacy',
371
				'manage_privacy_options',
372
				'options-privacy.php',
373
			),
374
			46 => array(
375
				'Approve User',
376
				'promote_users',
377
				'wp-approve-user',
378
				'Approve User',
379
			),
380
			47 => array(
381
				'',
382
				'manage_options',
383
				'sharing',
384
				'',
385
			),
386
		),
387
		'edit-tags.php?taxonomy=link_category' => array(
388
			15 => array(
389
				'Link Categories',
390
				'manage_categories',
391
				'edit-tags.php?taxonomy=link_category',
392
			),
393
		),
394
395
		''                                     => array(
396
			0 => array(
397
				'',
398
				'manage_options',
399
				'jetpack-debugger',
400
				'Debugging Center',
401
			),
402
			1 => array(
403
				'Settings',
404
				'jetpack_manage_modules',
405
				'jetpack_modules',
406
				'Jetpack Settings',
407
			),
408
			2 => array(
409
				'',
410
				'jetpack_admin_page',
411
				'jetpack_about',
412
				'About Jetpack',
413
			),
414
		),
415
		'edit.php?post_type=feedback'          => array(
416
			0 => array(
417
				'Feedback',
418
				'edit_pages',
419
				'edit.php?post_type=feedback',
420
				'',
421
			),
422
			1 => array(
423
				'Export CSV',
424
				'export',
425
				'feedback-export',
426
				'Export feedback as CSV',
427
			),
428
		),
429
		'jetpack'                              => array(
430
			1 => array(
431
				'Dashboard',
432
				'jetpack_admin_page',
433
				'jetpack#/dashboard',
434
				'Dashboard',
435
			),
436
			2 => array(
437
				'Settings',
438
				'jetpack_admin_page',
439
				'jetpack#/settings',
440
				'Settings',
441
			),
442
		),
443
	);
444
}
445
446
/**
447
 * Mock for testing
448
 */
449
function gutenberg_is_fse_theme() {
450
	return true;
451
}
452