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

Test_WPcom_Admin_Menu   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 525
Duplicated Lines 31.43 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 165
loc 525
rs 10
c 0
b 0
f 0
wmc 20
lcom 1
cbo 2

16 Methods

Rating   Name   Duplication   Size   Complexity  
A wpSetUpBeforeClass() 7 7 1
A setUp() 12 12 1
A test_get_instance() 9 9 1
A test_add_browse_sites_link() 0 29 2
A test_add_new_site_link() 0 16 1
A test_add_site_card_menu() 0 26 2
A test_set_site_card_menu_class() 0 24 2
A wpcomsh_site_icon_url() 0 3 1
A custom_site_icon_url() 0 3 1
A test_add_wpcom_upgrades_menu() 42 42 1
A test_jetpack_parent_file() 9 9 1
A test_add_plugins_menu() 0 30 2
A mock_update_data() 0 11 1
B test_add_users_menu() 0 81 1
B test_add_tools_menu() 76 76 1
A test_add_options_menu() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Tests for WPcom_Admin_Menu class.
4
 *
5
 * @package Jetpack
6
 */
7
8
use Automattic\Jetpack\Dashboard_Customizations\WPcom_Admin_Menu;
9
use Automattic\Jetpack\Status;
10
11
require_jetpack_file( 'modules/masterbar/admin-menu/class-admin-menu.php' );
12
require_jetpack_file( 'modules/masterbar/admin-menu/class-wpcom-admin-menu.php' );
13
require_jetpack_file( 'tests/php/modules/masterbar/data/admin-menu.php' );
14
15
/**
16
 * Class Test_WPcom_Admin_Menu.
17
 *
18
 * @coversDefaultClass Automattic\Jetpack\Dashboard_Customizations\WPcom_Admin_Menu
19
 */
20
class Test_WPcom_Admin_Menu extends WP_UnitTestCase {
21
22
	/**
23
	 * Menu data fixture.
24
	 *
25
	 * @var array
26
	 */
27
	public static $menu_data;
28
29
	/**
30
	 * Submenu data fixture.
31
	 *
32
	 * @var array
33
	 */
34
	public static $submenu_data;
35
36
	/**
37
	 * Test domain.
38
	 *
39
	 * @var string
40
	 */
41
	public static $domain;
42
43
	/**
44
	 * Whether this testsuite is run on WP.com.
45
	 *
46
	 * @var bool
47
	 */
48
	public static $is_wpcom;
49
50
	/**
51
	 * Admin menu instance.
52
	 *
53
	 * @var WPcom_Admin_Menu
54
	 */
55
	public static $admin_menu;
56
57
	/**
58
	 * Mock user ID.
59
	 *
60
	 * @var int
61
	 */
62
	private static $user_id = 0;
63
64
	/**
65
	 * Create shared fixtures.
66
	 *
67
	 * @param WP_UnitTest_Factory $factory Fixture factory.
68
	 */
69 View Code Duplication
	public static function wpSetUpBeforeClass( $factory ) {
70
		static::$domain  = ( new Status() )->get_site_suffix();
71
		static::$user_id = $factory->user->create( array( 'role' => 'administrator' ) );
0 ignored issues
show
Bug introduced by
Since $user_id is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $user_id to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
72
73
		static::$menu_data    = get_menu_fixture();
74
		static::$submenu_data = get_submenu_fixture();
75
	}
76
77
	/**
78
	 * Set up data.
79
	 */
80 View Code Duplication
	public function setUp() {
81
		parent::setUp();
82
		global $menu, $submenu;
83
84
		// Initialize in setUp so it registers hooks for every test.
85
		static::$admin_menu = WPcom_Admin_Menu::get_instance();
86
87
		$menu    = static::$menu_data;
88
		$submenu = static::$submenu_data;
89
90
		wp_set_current_user( static::$user_id );
0 ignored issues
show
Bug introduced by
Since $user_id is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $user_id to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
91
	}
92
93
	/**
94
	 * Test get_instance.
95
	 *
96
	 * @covers ::get_instance
97
	 * @covers ::__construct
98
	 */
99 View Code Duplication
	public function test_get_instance() {
100
		$instance = WPcom_Admin_Menu::get_instance();
101
102
		$this->assertInstanceOf( WPcom_Admin_Menu::class, $instance );
103
		$this->assertSame( $instance, static::$admin_menu );
104
105
		$this->assertSame( 99999, has_action( 'admin_menu', array( $instance, 'reregister_menu_items' ) ) );
106
		$this->assertSame( 10, has_action( 'admin_enqueue_scripts', array( $instance, 'enqueue_scripts' ) ) );
107
	}
108
109
	/**
110
	 * Tests add_browse_sites_link.
111
	 *
112
	 * @covers ::add_browse_sites_link
113
	 */
114
	public function test_add_browse_sites_link() {
115
		if ( ! function_exists( 'add_user_to_blog' ) ) {
116
			$this->markTestSkipped( 'Only used on multisite' );
117
		}
118
		global $menu;
119
120
		// No output when user has just one site.
121
		static::$admin_menu->add_browse_sites_link();
122
		$this->assertArrayNotHasKey( 0, $menu );
123
124
		// Give user a second site.
125
		$blog_id = $this->factory->blog->create();
126
		add_user_to_blog( $blog_id, get_current_user_id(), 'editor' );
127
128
		static::$admin_menu->add_browse_sites_link();
129
130
		$browse_sites_menu_item = array(
131
			'Browse sites',
132
			'read',
133
			'https://wordpress.com/home',
134
			'site-switcher',
135
			'menu-top toplevel_page_https://wordpress.com/home',
136
			'toplevel_page_https://wordpress.com/home',
137
			'dashicons-arrow-left-alt2',
138
		);
139
		$this->assertSame( $menu[0], $browse_sites_menu_item );
140
141
		remove_user_from_blog( get_current_user_id(), $blog_id );
142
	}
143
144
	/**
145
	 * Tests add_new_site_link.
146
	 *
147
	 * @covers ::add_new_site_link
148
	 */
149
	public function test_add_new_site_link() {
150
		global $menu;
151
152
		static::$admin_menu->add_new_site_link();
153
154
		$new_site_menu_item = array(
155
			'Add new site',
156
			'read',
157
			'https://wordpress.com/start?ref=calypso-sidebar',
158
			'Add new site',
159
			'menu-top toplevel_page_https://wordpress.com/start?ref=calypso-sidebar',
160
			'toplevel_page_https://wordpress.com/start?ref=calypso-sidebar',
161
			'dashicons-plus-alt',
162
		);
163
		$this->assertSame( $menu[1002], $new_site_menu_item ); // 1001 is the separator position, 1002 is the link position
164
	}
165
166
	/**
167
	 * Tests add_site_card_menu
168
	 *
169
	 * @covers ::add_site_card_menu
170
	 */
171
	public function test_add_site_card_menu() {
172
		global $menu;
173
174
		if ( ! static::$is_wpcom ) {
175
			$this->markTestSkipped( 'Only used on WP.com.' );
176
		}
177
178
		static::$admin_menu->add_site_card_menu();
179
180
		$home_url            = home_url();
181
		$site_card_menu_item = array(
182
			// phpcs:ignore Squiz.Strings.DoubleQuoteUsage.NotRequired
183
			'
184
<div class="site__info">
185
	<div class="site__title">' . get_option( 'blogname' ) . '</div>
186
	<div class="site__domain">' . static::$domain . "</div>\n\t</div>",
187
			'read',
188
			$home_url,
189
			'site-card',
190
			'menu-top toplevel_page_' . $home_url,
191
			'toplevel_page_' . $home_url,
192
			'data:image/svg+xml,%3Csvg%20class%3D%22gridicon%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Ctitle%3EGlobe%3C%2Ftitle%3E%3Crect%20fill-opacity%3D%220%22%20x%3D%220%22%20width%3D%2224%22%20height%3D%2224%22%2F%3E%3Cg%3E%3Cpath%20fill%3D%22%23fff%22%20d%3D%22M12%202C6.477%202%202%206.477%202%2012s4.477%2010%2010%2010%2010-4.477%2010-10S17.523%202%2012%202zm0%2018l2-2%201-1v-2h-2v-1l-1-1H9v3l2%202v1.93c-3.94-.494-7-3.858-7-7.93l1%201h2v-2h2l3-3V6h-2L9%205v-.41C9.927%204.21%2010.94%204%2012%204s2.073.212%203%20.59V6l-1%201v2l1%201%203.13-3.13c.752.897%201.304%201.964%201.606%203.13H18l-2%202v2l1%201h2l.286.286C18.03%2018.06%2015.24%2020%2012%2020z%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E',
193
		);
194
195
		$this->assertEquals( $menu[1], $site_card_menu_item );
196
	}
197
198
	/**
199
	 * Tests set_site_card_menu_class
200
	 *
201
	 * @covers ::set_site_card_menu_class
202
	 */
203
	public function test_set_site_card_menu_class() {
204
		global $menu;
205
206
		if ( ! static::$is_wpcom ) {
207
			$this->markTestSkipped( 'Only used on WP.com.' );
208
		}
209
210
		static::$admin_menu->add_site_card_menu();
211
212
		$menu = static::$admin_menu->set_site_card_menu_class( $menu );
213
		$this->assertNotContains( 'has-site-icon', $menu[1][4] );
214
215
		// Atomic fallback site icon counts as no site icon.
216
		add_filter( 'get_site_icon_url', array( $this, 'wpcomsh_site_icon_url' ) );
217
		$menu = static::$admin_menu->set_site_card_menu_class( $menu );
218
		remove_filter( 'get_site_icon_url', array( $this, 'wpcomsh_site_icon_url' ) );
219
		$this->assertNotContains( 'has-site-icon', $menu[1][4] );
220
221
		// Custom site icon triggers CSS class.
222
		add_filter( 'get_site_icon_url', array( $this, 'custom_site_icon_url' ) );
223
		$menu = static::$admin_menu->set_site_card_menu_class( $menu );
224
		remove_filter( 'get_site_icon_url', array( $this, 'custom_site_icon_url' ) );
225
		$this->assertContains( 'has-site-icon', $menu[1][4] );
226
	}
227
228
	/**
229
	 * Shim wpcomsh fallback site icon.
230
	 *
231
	 * @return string
232
	 */
233
	public function wpcomsh_site_icon_url() {
234
		return 'https://s0.wp.com/i/webclip.png';
235
	}
236
237
	/**
238
	 * Custom site icon.
239
	 *
240
	 * @return string
241
	 */
242
	public function custom_site_icon_url() {
243
		return 'https://s0.wp.com/i/jetpack.png';
244
	}
245
246
	/**
247
	 * Tests add_upgrades_menu
248
	 *
249
	 * @covers ::add_upgrades_menu
250
	 */
251 View Code Duplication
	public function test_add_wpcom_upgrades_menu() {
252
		global $menu, $submenu;
253
254
		static::$admin_menu->add_upgrades_menu();
255
256
		$slug = 'https://wordpress.com/plans/' . static::$domain;
257
258
		$upgrades_menu_item = array(
259
			'Upgrades',
260
			'manage_options',
261
			$slug,
262
			'Upgrades',
263
			'menu-top toplevel_page_https://wordpress.com/plans/' . static::$domain,
264
			'toplevel_page_https://wordpress.com/plans/' . static::$domain,
265
			'dashicons-cart',
266
		);
267
		$this->assertSame( $menu['4.80608'], $upgrades_menu_item );
268
269
		$plans_submenu_item = array(
270
			'Plans',
271
			'manage_options',
272
			$slug,
273
			'Plans',
274
		);
275
		$this->assertContains( $plans_submenu_item, $submenu[ $slug ] );
276
277
		$domains_submenu_item = array(
278
			'Domains',
279
			'manage_options',
280
			'https://wordpress.com/domains/manage/' . static::$domain,
281
			'Domains',
282
		);
283
		$this->assertContains( $domains_submenu_item, $submenu[ $slug ] );
284
285
		$purchases_submenu_item = array(
286
			'Purchases',
287
			'manage_options',
288
			'https://wordpress.com/purchases/subscriptions/' . static::$domain,
289
			'Purchases',
290
		);
291
		$this->assertContains( $purchases_submenu_item, $submenu[ $slug ] );
292
	}
293
294
	/**
295
	 * Tests jetpack_parent_file
296
	 *
297
	 * @covers ::jetpack_parent_file
298
	 */
299 View Code Duplication
	public function test_jetpack_parent_file() {
300
		$parent_file = 'edit.php';
301
		$this->assertSame( $parent_file, static::$admin_menu->jetpack_parent_file( $parent_file ) );
302
303
		$this->assertSame(
304
			'https://wordpress.com/activity-log/' . static::$domain,
305
			static::$admin_menu->jetpack_parent_file( 'jetpack' )
306
		);
307
	}
308
309
	/**
310
	 * Tests add_plugins_menu
311
	 *
312
	 * @covers ::add_plugins_menu
313
	 */
314
	public function test_add_plugins_menu() {
315
		global $menu, $submenu;
316
317
		add_filter( 'wp_get_update_data', array( $this, 'mock_update_data' ) );
318
		static::$admin_menu->add_plugins_menu( static::$domain );
0 ignored issues
show
Unused Code introduced by
The call to WPcom_Admin_Menu::add_plugins_menu() has too many arguments starting with static::$domain.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
319
		remove_filter( 'wp_get_update_data', array( $this, 'mock_update_data' ) );
320
321
		$slug  = 'https://wordpress.com/plugins/' . static::$domain;
322
		$label = is_multisite() ? 'Plugins ' : 'Plugins <span class="update-plugins count-0"><span class="plugin-count">0</span></span>';
323
324
		$plugins_menu_item = array(
325
			$label,
326
			'activate_plugins',
327
			$slug,
328
			'Plugins',
329
			'menu-top toplevel_page_' . $slug,
330
			'toplevel_page_' . $slug,
331
			'dashicons-admin-plugins',
332
		);
333
334
		$this->assertEquals( $plugins_menu_item, $menu[65] );
335
		$this->assertArrayNotHasKey( 'plugins.php', $submenu );
336
337
		$editor_submenu_item = array(
338
			'Plugin Editor',
339
			'edit_plugins',
340
			'plugin-editor.php',
341
		);
342
		$this->assertNotContains( $editor_submenu_item, $submenu[ $slug ] );
343
	}
344
345
	/**
346
	 * Filters the returned array of update data for plugins, themes, and WordPress core.
347
	 */
348
	public function mock_update_data() {
349
		return array(
350
			'counts' => array(
351
				'plugins'      => 0,
352
				'themes'       => 0,
353
				'translations' => 0,
354
				'wordpress'    => 0,
355
			),
356
			'title'  => '',
357
		);
358
	}
359
360
	/**
361
	 * Tests add_users_menu
362
	 *
363
	 * @covers ::add_users_menu
364
	 */
365
	public function test_add_users_menu() {
366
		global $menu, $submenu;
367
368
		// Current user can't list users.
369
		wp_set_current_user( $this->factory->user->create( array( 'role' => 'editor' ) ) );
370
		$menu = array();
371
372
		static::$admin_menu->add_users_menu( true );
373
374
		$profile_menu_item = array(
375
			'My Profile',
376
			'read',
377
			'https://wordpress.com/me',
378
			'My Profile',
379
			'menu-top toplevel_page_https://wordpress.com/me',
380
			'toplevel_page_https://wordpress.com/me',
381
			'dashicons-admin-users',
382
		);
383
		$this->assertSame( $menu[70], $profile_menu_item );
384
385
		$account_submenu_item = array(
386
			'Account Settings',
387
			'read',
388
			'https://wordpress.com/me/account',
389
			'Account Settings',
390
		);
391
		$this->assertContains( $account_submenu_item, $submenu['https://wordpress.com/me'] );
392
		$this->assertArrayNotHasKey( 'profile.php', $submenu );
393
394
		// Reset.
395
		wp_set_current_user( static::$user_id );
0 ignored issues
show
Bug introduced by
Since $user_id is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $user_id to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
396
		$menu = static::$menu_data;
397
398
		static::$admin_menu->add_users_menu( static::$domain );
0 ignored issues
show
Documentation introduced by
static::$domain is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
399
400
		$slug = 'https://wordpress.com/people/team/' . static::$domain;
401
402
		$users_menu_item = array(
403
			'Users',
404
			'list_users',
405
			$slug,
406
			'Users',
407
			'menu-top toplevel_page_' . $slug,
408
			'toplevel_page_' . $slug,
409
			'dashicons-admin-users',
410
		);
411
		$this->assertSame( $menu[70], $users_menu_item );
412
		$this->assertEmpty( $submenu['users.php'] );
413
414
		$all_people_submenu_item = array(
415
			'All People',
416
			'list_users',
417
			$slug,
418
			'All People',
419
		);
420
		$this->assertContains( $all_people_submenu_item, $submenu[ $slug ] );
421
422
		$add_new_submenu_item = array(
423
			'Add New',
424
			'promote_users',
425
			'https://wordpress.com/people/new/' . static::$domain,
426
			'Add New',
427
		);
428
		$this->assertContains( $add_new_submenu_item, $submenu[ $slug ] );
429
430
		$profile_submenu_item = array(
431
			'My Profile',
432
			'read',
433
			'https://wordpress.com/me',
434
			'My Profile',
435
		);
436
		$this->assertContains( $profile_submenu_item, $submenu[ $slug ] );
437
438
		$account_submenu_item = array(
439
			'Account Settings',
440
			'read',
441
			'https://wordpress.com/me/account',
442
			'Account Settings',
443
		);
444
		$this->assertContains( $account_submenu_item, $submenu[ $slug ] );
445
	}
446
447
	/**
448
	 * Tests add_tools_menu
449
	 *
450
	 * @covers ::add_tools_menu
451
	 */
452 View Code Duplication
	public function test_add_tools_menu() {
453
		global $menu, $submenu;
454
455
		$slug = 'https://wordpress.com/marketing/tools/' . static::$domain;
456
		static::$admin_menu->add_tools_menu( static::$domain );
0 ignored issues
show
Documentation introduced by
static::$domain is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
457
458
		$tools_menu_item = array(
459
			'Tools',
460
			'manage_options',
461
			$slug,
462
			'Tools',
463
			'menu-top toplevel_page_' . $slug,
464
			'toplevel_page_' . $slug,
465
			'dashicons-admin-tools',
466
		);
467
468
		$this->assertSame( $menu[75], $tools_menu_item );
469
		$this->assertArrayNotHasKey( 'tools.php', $submenu );
470
471
		// Contains the following menu items.
472
473
		$marketing_submenu_item = array(
474
			'Marketing',
475
			'manage_options',
476
			'https://wordpress.com/marketing/tools/' . static::$domain,
477
			'Marketing',
478
		);
479
		$this->assertContains( $marketing_submenu_item, $submenu[ $slug ] );
480
481
		$earn_submenu_item = array(
482
			'Earn',
483
			'manage_options',
484
			'https://wordpress.com/earn/' . static::$domain,
485
			'Earn',
486
		);
487
		$this->assertContains( $earn_submenu_item, $submenu[ $slug ] );
488
489
		$import_submenu_item = array(
490
			'Import',
491
			'import',
492
			'https://wordpress.com/import/' . static::$domain,
493
			'Import',
494
		);
495
		$this->assertContains( $import_submenu_item, $submenu[ $slug ] );
496
497
		$export_submenu_item = array(
498
			'Export',
499
			'export',
500
			'https://wordpress.com/export/' . static::$domain,
501
			'Export',
502
		);
503
		$this->assertContains( $export_submenu_item, $submenu[ $slug ] );
504
505
		// NOT contains the following menu items.
506
507
		$tools_submenu_item = array(
508
			'Available Tools',
509
			'edit_posts',
510
			'tools.php',
511
		);
512
		$this->assertNotContains( $tools_submenu_item, $submenu[ $slug ] );
513
514
		$import_submenu_item = array(
515
			'Import',
516
			'import',
517
			'import.php',
518
		);
519
		$this->assertNotContains( $import_submenu_item, $submenu[ $slug ] );
520
521
		$export_submenu_item = array(
522
			'Export',
523
			'export',
524
			'export.php',
525
		);
526
		$this->assertNotContains( $export_submenu_item, $submenu[ $slug ] );
527
	}
528
529
	/**
530
	 * Tests add_options_menu
531
	 *
532
	 * @covers ::add_options_menu
533
	 */
534 View Code Duplication
	public function test_add_options_menu() {
535
		global $submenu;
536
537
		static::$admin_menu->add_options_menu( static::$domain );
0 ignored issues
show
Documentation introduced by
static::$domain is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
538
539
		$this->assertNotContains( 'options-discussion.php', $submenu['options-general.php'] );
540
		$this->assertNotContains( 'options-writing.php', $submenu['options-general.php'] );
541
542
		$this->assertContains( 'Hosting Configuration', $submenu['options-general.php'][6] );
543
	}
544
}
545