Make WordPress Core

Changeset 56227


Ignore:
Timestamp:
07/13/2023 12:39:42 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Add tests to ensure the contribute Toolbar node is added when appropriate.

Follow-up to [56220].

Props costdev.
See #23348.

File:
1 edited

Legend:

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

    r55580 r56227  
    470470         */
    471471        public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite() {
    472                 // User is not a member of a site.
     472                // User is not a member of the site.
    473473                remove_user_from_blog( self::$no_role_id, get_current_blog_id() );
    474474
     
    483483                $this->assertArrayNotHasKey( 'tabindex', $wp_logo_node->meta );
    484484                $this->assertNotNull( $about_node );
     485        }
     486
     487        /**
     488         * Tests that the 'contribute' node is added for users with a role in single site.
     489         *
     490         * @ticket 23348
     491         *
     492         * @group ms-excluded
     493         *
     494         * @covers ::wp_admin_bar_wp_menu
     495         */
     496        public function test_admin_bar_contains_contribute_node_for_users_with_role() {
     497                wp_set_current_user( self::$editor_id );
     498
     499                $wp_admin_bar = $this->get_standard_admin_bar();
     500
     501                $this->assertNotNull( $wp_admin_bar->get_node( 'contribute' ) );
     502        }
     503
     504        /**
     505         * Tests that the 'contribute' node is not added for users with no role in single site.
     506         *
     507         * @ticket 23348
     508         *
     509         * @group ms-excluded
     510         *
     511         * @covers ::wp_admin_bar_wp_menu
     512         */
     513        public function test_admin_bar_does_not_contain_contribute_node_for_users_with_no_role() {
     514                wp_set_current_user( self::$no_role_id );
     515
     516                $wp_admin_bar = $this->get_standard_admin_bar();
     517
     518                $this->assertNull( $wp_admin_bar->get_node( 'contribute' ) );
     519        }
     520
     521        /**
     522         * Tests that the 'contribute' node is added for users with no role in multisite.
     523         *
     524         * @ticket 23348
     525         *
     526         * @group multisite
     527         * @group ms-required
     528         *
     529         * @covers ::wp_admin_bar_wp_menu
     530         */
     531        public function test_admin_bar_contains_contribute_node_for_users_with_no_role_in_multisite() {
     532                // User is not a member of the site.
     533                remove_user_from_blog( self::$no_role_id, get_current_blog_id() );
     534
     535                wp_set_current_user( self::$no_role_id );
     536
     537                $wp_admin_bar = $this->get_standard_admin_bar();
     538
     539                $this->assertNotNull( $wp_admin_bar->get_node( 'contribute' ) );
    485540        }
    486541
Note: See TracChangeset for help on using the changeset viewer.