Skip to content

Commit

Permalink
Add check for multisites as My Jetpack will not show there
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-karen committed Oct 1, 2024
1 parent 29a105a commit 04f1e3a
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public function set_up() {
)
);
$user_id->add_cap( 'jetpack_connect_user' );
$user_id->add_cap( 'jetpack_manage_modules' );
$user_id->add_cap( 'jetpack_configure_modules' );
wp_set_current_user( $user_id->ID );

// Mock a connection
Expand All @@ -29,8 +31,10 @@ public function set_up() {
*/
public function tear_down() {
Jetpack_Options::delete_option( array( 'id', 'user_tokens' ) );
$user = wp_get_current_user();
$user->remove_cap( 'jetpack_connect_user' );
$user_id = wp_get_current_user();
$user_id->remove_cap( 'jetpack_connect_user' );
$user_id->remove_cap( 'jetpack_manage_modules' );
$user_id->remove_cap( 'jetpack_configure_modules' );
}

public function test_jetpack_admin_menu_order() {
Expand All @@ -52,6 +56,10 @@ public function test_jetpack_admin_menu_order() {
$settings_submenu_position = array_search( 'http://example.org/wp-admin/admin.php?page=jetpack#/settings', $submenu_slugs, true );
$dashboard_submenu_position = array_search( 'http://example.org/wp-admin/admin.php?page=jetpack#/dashboard', $submenu_slugs, true );

// Multisites do not show the My Jetpack menu item
if ( ! is_multisite() ) {
$this->assertTrue( $my_jetpack_submenu_position < $search_submenu_position, 'My Jetpack should be above Search in the submenu order.' );
}
$this->assertTrue( $my_jetpack_submenu_position < $search_submenu_position, 'My Jetpack should be above Search in the submenu order.' );
$this->assertTrue( $search_submenu_position < $settings_submenu_position, 'Search should be above Settings in the submenu order.' );
$this->assertTrue( $settings_submenu_position < $dashboard_submenu_position, 'Settings should be above Dashboard in the submenu order.' );
Expand Down

0 comments on commit 04f1e3a

Please sign in to comment.