Skip to content

Commit 736edc7

Browse files
committed
Toolbar: Split tests added in [38660] and add a multisite specific test.
See #37949. git-svn-id: https://develop.svn.wordpress.org/trunk@38663 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3387a83 commit 736edc7

1 file changed

Lines changed: 48 additions & 11 deletions

File tree

tests/phpunit/tests/adminbar.php

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,28 +411,65 @@ public function test_admin_bar_has_no_archives_link_for_post_types_without_archi
411411
/**
412412
* @ticket 37949
413413
*/
414-
public function test_admin_bar_does_not_add_about_page_url() {
414+
public function test_admin_bar_contains_correct_about_link_for_users_with_role() {
415+
if ( is_multisite() ) {
416+
$this->markTestSkipped( 'Test does not run in multisite' );
417+
}
418+
419+
wp_set_current_user( self::$editor_id );
420+
421+
$wp_admin_bar = $this->get_standard_admin_bar();
422+
$wp_logo_node = $wp_admin_bar->get_node( 'wp-logo' );
423+
$about_node = $wp_admin_bar->get_node( 'about' );
424+
425+
$this->assertNotNull( $wp_logo_node );
426+
$this->assertSame( admin_url( 'about.php' ), $wp_logo_node->href );
427+
$this->assertArrayNotHasKey( 'tabindex', $wp_logo_node->meta );
428+
$this->assertNotNull( $about_node );
429+
}
430+
431+
/**
432+
* @ticket 37949
433+
*/
434+
public function test_admin_bar_contains_correct_about_link_for_users_with_no_role() {
415435
if ( is_multisite() ) {
416436
$this->markTestSkipped( 'Test does not run in multisite' );
417437
}
418438

419439
wp_set_current_user( self::$no_role_id );
420440

421441
$wp_admin_bar = $this->get_standard_admin_bar();
422-
$node = $wp_admin_bar->get_node( 'wp-logo' );
442+
$wp_logo_node = $wp_admin_bar->get_node( 'wp-logo' );
443+
$about_node = $wp_admin_bar->get_node( 'about' );
444+
445+
$this->assertNotNull( $wp_logo_node );
446+
$this->assertSame( false, $wp_logo_node->href );
447+
$this->assertArrayHasKey( 'tabindex', $wp_logo_node->meta );
448+
$this->assertSame( 0, $wp_logo_node->meta['tabindex'] );
449+
$this->assertNull( $about_node );
450+
}
423451

424-
$this->assertNotNull( $node );
425-
$this->assertSame( false, $node->href );
426-
$this->assertArrayHasKey( 'tabindex', $node->meta );
427-
$this->assertSame( 0, $node->meta['tabindex'] );
452+
/**
453+
* @ticket 37949
454+
* @group multisite
455+
*/
456+
public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite() {
457+
if ( ! is_multisite() ) {
458+
$this->markTestSkipped( 'Test only runs in multisite' );
459+
}
428460

429-
wp_set_current_user( self::$editor_id );
461+
// User is not a member of a site.
462+
remove_user_from_blog( self::$no_role_id, get_current_blog_id() );
463+
464+
wp_set_current_user( self::$no_role_id );
430465

431466
$wp_admin_bar = $this->get_standard_admin_bar();
432-
$node = $wp_admin_bar->get_node( 'wp-logo' );
467+
$wp_logo_node = $wp_admin_bar->get_node( 'wp-logo' );
468+
$about_node = $wp_admin_bar->get_node( 'about' );
433469

434-
$this->assertNotNull( $node );
435-
$this->assertSame( admin_url( 'about.php' ), $node->href );
436-
$this->assertArrayNotHasKey( 'tabindex', $node->meta );
470+
$this->assertNotNull( $wp_logo_node );
471+
$this->assertSame( user_admin_url( 'about.php' ), $wp_logo_node->href );
472+
$this->assertArrayNotHasKey( 'tabindex', $wp_logo_node->meta );
473+
$this->assertNotNull( $about_node );
437474
}
438475
}

0 commit comments

Comments
 (0)