WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/27/2016 08:10:31 PM (5 years ago)
Author:
ocean90
Message:

Toolbar: Split tests added in [38660] and add a multisite specific test.

See #37949.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/adminbar.php

    r38661 r38663  
    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() {
    415415        if ( is_multisite() ) {
    416416            $this->markTestSkipped( 'Test does not run in multisite' );
    417417        }
    418418
     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() {
     435        if ( is_multisite() ) {
     436            $this->markTestSkipped( 'Test does not run in multisite' );
     437        }
     438
    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' );
    423 
    424         $this->assertNotNull( $node );
    425         $this->assertSame( false, $node->href );
    426         $this->assertArrayHasKey( 'tabindex', $node->meta );
    427         $this->assertSame( 0, $node->meta['tabindex'] );
    428 
    429         wp_set_current_user( self::$editor_id );
    430 
    431         $wp_admin_bar = $this->get_standard_admin_bar();
    432         $node         = $wp_admin_bar->get_node( 'wp-logo' );
    433 
    434         $this->assertNotNull( $node );
    435         $this->assertSame( admin_url( 'about.php' ), $node->href );
    436         $this->assertArrayNotHasKey( 'tabindex', $node->meta );
     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    }
     451
     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        }
     460
     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 );
     465
     466        $wp_admin_bar = $this->get_standard_admin_bar();
     467        $wp_logo_node = $wp_admin_bar->get_node( 'wp-logo' );
     468        $about_node   = $wp_admin_bar->get_node( 'about' );
     469
     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}
Note: See TracChangeset for help on using the changeset viewer.