Make WordPress Core

Changeset 40564


Ignore:
Timestamp:
05/01/2017 08:34:10 PM (7 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Automatically skip tests in the ms-required and ms-excluded groups.

This removes the need to manually call $this->skipWithMultisite() and $this->skipWithoutMultisite() from within the test when the test only runs without Multisite or only runs on Multisite, respectively.

Props jdgrimes for the suggestion.

Fixes #40531

Location:
trunk/tests/phpunit
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r40543 r40564  
    577577    protected function checkRequirements() {
    578578        parent::checkRequirements();
     579
     580        $annotations = $this->getAnnotations();
     581
     582        if ( ! empty( $annotations['group'] ) ) {
     583            if ( in_array( 'ms-required', $annotations['group'], true ) ) {
     584                $this->skipWithoutMultisite();
     585            }
     586            if ( in_array( 'ms-excluded', $annotations['group'], true ) ) {
     587                $this->skipWithMultisite();
     588            }
     589        }
    579590
    580591        // Core tests no longer check against open Trac tickets, but others using WP_UnitTestCase may do so.
  • trunk/tests/phpunit/tests/adminbar.php

    r40543 r40564  
    7676     */
    7777    public function test_admin_bar_contains_correct_links_for_users_with_no_role() {
    78         $this->skipWithMultisite();
    79 
    8078        $this->assertFalse( user_can( self::$no_role_id, 'read' ) );
    8179
     
    103101     */
    104102    public function test_admin_bar_contains_correct_links_for_users_with_role() {
    105         $this->skipWithMultisite();
    106 
    107103        $this->assertTrue( user_can( self::$editor_id, 'read' ) );
    108104
     
    133129     */
    134130    public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_blog() {
    135         $this->skipWithoutMultisite();
    136 
    137131        $blog_id = self::factory()->blog->create( array(
    138132            'user_id' => self::$admin_id,
     
    182176     */
    183177    public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_network() {
    184         $this->skipWithoutMultisite();
    185 
    186178        $this->assertTrue( user_can( self::$admin_id, 'read' ) );
    187179        $this->assertFalse( user_can( self::$no_role_id, 'read' ) );
     
    425417     */
    426418    public function test_admin_bar_contains_correct_about_link_for_users_with_role() {
    427         $this->skipWithMultisite();
    428 
    429419        wp_set_current_user( self::$editor_id );
    430420
     
    444434     */
    445435    public function test_admin_bar_contains_correct_about_link_for_users_with_no_role() {
    446         $this->skipWithMultisite();
    447 
    448436        wp_set_current_user( self::$no_role_id );
    449437
     
    465453     */
    466454    public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite() {
    467         $this->skipWithoutMultisite();
    468 
    469455        // User is not a member of a site.
    470456        remove_user_from_blog( self::$no_role_id, get_current_blog_id() );
     
    583569     */
    584570    public function test_my_sites_network_menu_for_regular_user() {
    585         $this->skipWithoutMultisite();
    586 
    587571        wp_set_current_user( self::$editor_id );
    588572
     
    600584     */
    601585    public function test_my_sites_network_menu_for_super_admin() {
    602         $this->skipWithoutMultisite();
    603 
    604586        wp_set_current_user( self::$editor_id );
    605587
     
    619601     */
    620602    public function test_my_sites_network_menu_for_regular_user_with_network_caps() {
    621         $this->skipWithoutMultisite();
    622 
    623603        global $current_user;
    624604
  • trunk/tests/phpunit/tests/customize/setting.php

    r40543 r40564  
    565565     */
    566566    function test_previewing_with_switch_to_blog() {
    567         $this->skipWithoutMultisite();
    568 
    569567        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    570568        $type = 'option';
  • trunk/tests/phpunit/tests/functions.php

    r40543 r40564  
    939939     */
    940940    function test_wp_check_filetype_and_ext_with_filtered_svg() {
    941         $this->skipWithMultisite();
    942 
    943941        if ( ! extension_loaded( 'fileinfo' ) ) {
    944942            $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
     
    966964     */
    967965    function test_wp_check_filetype_and_ext_with_filtered_woff() {
    968         $this->skipWithMultisite();
    969 
    970966        if ( ! extension_loaded( 'fileinfo' ) ) {
    971967            $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
  • trunk/tests/phpunit/tests/general/template.php

    r40543 r40564  
    7676     */
    7777    function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() {
    78         $this->skipWithoutMultisite();
    79 
    8078        $blog_id = $this->factory->blog->create();
    8179        switch_to_blog( $blog_id );
     
    9290     */
    9391    function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() {
    94         $this->skipWithoutMultisite();
    95 
    9692        $blog_id = $this->factory->blog->create();
    9793
     
    266262     */
    267263    function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() {
    268         $this->skipWithoutMultisite();
    269 
    270264        $blog_id = $this->factory->blog->create();
    271265        switch_to_blog( $blog_id );
     
    282276     */
    283277    function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() {
    284         $this->skipWithoutMultisite();
    285 
    286278        $blog_id = $this->factory->blog->create();
    287279
     
    312304     */
    313305    function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() {
    314         $this->skipWithoutMultisite();
    315 
    316306        $blog_id = $this->factory->blog->create();
    317307        switch_to_blog( $blog_id );
     
    533523     */
    534524    function test_get_site_icon_url_preserves_switched_state() {
    535         $this->skipWithoutMultisite();
    536 
    537525        $blog_id = $this->factory->blog->create();
    538526        switch_to_blog( $blog_id );
     
    554542     */
    555543    function test_has_custom_logo_preserves_switched_state() {
    556         $this->skipWithoutMultisite();
    557 
    558544        $blog_id = $this->factory->blog->create();
    559545        switch_to_blog( $blog_id );
     
    575561     */
    576562    function test_get_custom_logo_preserves_switched_state() {
    577         $this->skipWithoutMultisite();
    578 
    579563        $blog_id = $this->factory->blog->create();
    580564        switch_to_blog( $blog_id );
  • trunk/tests/phpunit/tests/l10n/getLocale.php

    r40543 r40564  
    2222     */
    2323    public function test_local_option_should_take_precedence_on_multisite() {
    24         $this->skipWithoutMultisite();
    25 
    2624        global $locale;
    2725        $old_locale = $locale;
  • trunk/tests/phpunit/tests/link/getDashboardUrl.php

    r40543 r40564  
    4242     */
    4343    public function test_get_dashboard_url_for_network_administrator_with_no_sites() {
    44         $this->skipWithoutMultisite();
    45 
    4644        grant_super_admin( self::$user_id );
    4745
     
    6159     */
    6260    public function test_get_dashboard_url_for_administrator_of_different_site() {
    63         $this->skipWithoutMultisite();
    64 
    6561        $site_id = self::factory()->blog->create( array( 'user_id' => self::$user_id ) );
    6662
  • trunk/tests/phpunit/tests/oembed/controller.php

    r40543 r40564  
    257257     */
    258258    function test_request_ms_child_in_root_blog() {
    259         $this->skipWithoutMultisite();
    260 
    261259        $child = self::factory()->blog->create();
    262260        switch_to_blog( $child );
  • trunk/tests/phpunit/tests/option/networkOption.php

    r40543 r40564  
    1717     */
    1818    function test_add_network_option_not_available_on_other_network() {
    19         $this->skipWithoutMultisite();
    20 
    2119        $id = self::factory()->network->create();
    2220        $option = __FUNCTION__;
     
    3129     */
    3230    function test_add_network_option_available_on_same_network() {
    33         $this->skipWithoutMultisite();
    34 
    3531        $id = self::factory()->network->create();
    3632        $option = __FUNCTION__;
     
    4541     */
    4642    function test_delete_network_option_on_only_one_network() {
    47         $this->skipWithoutMultisite();
    48 
    4943        $id = self::factory()->network->create();
    5044        $option = __FUNCTION__;
     
    6256     */
    6357    public function test_add_network_option_is_not_stored_as_autoload_option() {
    64         $this->skipWithMultisite();
    65 
    6658        $key = __FUNCTION__;
    6759
     
    7870     */
    7971    public function test_update_network_option_is_not_stored_as_autoload_option() {
    80         $this->skipWithMultisite();
    81 
    8272        $key = __FUNCTION__;
    8373
  • trunk/tests/phpunit/tests/option/siteTransient.php

    r40543 r40564  
    4848     */
    4949    public function test_set_site_transient_is_not_stored_as_autoload_option() {
    50         $this->skipWithMultisite();
    51 
    5250        $key = 'not_autoloaded';
    5351
  • trunk/tests/phpunit/tests/rest-api/rest-users-controller.php

    r40543 r40564  
    997997     */
    998998    public function test_create_new_network_user_on_site_does_not_add_user_to_sub_site() {
    999         $this->skipWithoutMultisite();
    1000 
    1001999        $this->allow_user_to_manage_multisite();
    10021000
     
    10271025     */
    10281026    public function test_create_new_network_user_on_sub_site_adds_user_to_site() {
    1029         $this->skipWithoutMultisite();
    1030 
    10311027        $this->allow_user_to_manage_multisite();
    10321028
     
    10611057     */
    10621058    public function test_create_existing_network_user_on_sub_site_has_error() {
    1063         $this->skipWithoutMultisite();
    1064 
    10651059        $this->allow_user_to_manage_multisite();
    10661060
     
    14491443     */
    14501444    public function test_update_user_role_invalid_privilege_deescalation() {
    1451         $this->skipWithMultisite();
    1452 
    14531445        $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
    14541446
     
    14801472     */
    14811473    public function test_update_user_role_privilege_deescalation_multisite() {
    1482         $this->skipWithoutMultisite();
    1483 
    14841474        $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
    14851475
     
    22292219     */
    22302220    public function test_get_item_from_different_site_as_site_administrator() {
    2231         $this->skipWithoutMultisite();
    2232 
    22332221        switch_to_blog( self::$site );
    22342222        $user_id = $this->factory->user->create( array(
     
    22492237     */
    22502238    public function test_get_item_from_different_site_as_network_administrator() {
    2251         $this->skipWithoutMultisite();
    2252 
    22532239        switch_to_blog( self::$site );
    22542240        $user_id = $this->factory->user->create( array(
     
    22692255     */
    22702256    public function test_update_item_from_different_site_as_site_administrator() {
    2271         $this->skipWithoutMultisite();
    2272 
    22732257        switch_to_blog( self::$site );
    22742258        $user_id = $this->factory->user->create( array(
     
    22912275     */
    22922276    public function test_update_item_from_different_site_as_network_administrator() {
    2293         $this->skipWithoutMultisite();
    2294 
    22952277        switch_to_blog( self::$site );
    22962278        $user_id = $this->factory->user->create( array(
     
    23132295     */
    23142296    public function test_delete_item_from_different_site_as_site_administrator() {
    2315         $this->skipWithoutMultisite();
    2316 
    23172297        switch_to_blog( self::$site );
    23182298        $user_id = $this->factory->user->create( array(
     
    23352315     */
    23362316    public function test_delete_item_from_different_site_as_network_administrator() {
    2337         $this->skipWithoutMultisite();
    2338 
    23392317        switch_to_blog( self::$site );
    23402318        $user_id = $this->factory->user->create( array(
  • trunk/tests/phpunit/tests/rewrite.php

    r40543 r40564  
    123123     */
    124124    function test_url_to_postid_of_http_site_when_current_site_uses_https() {
    125         $this->skipWithoutMultisite();
    126 
    127125        $_SERVER['HTTPS'] = 'on';
    128126
     
    318316     */
    319317    function test_url_to_postid_ms_home_url_collision() {
    320         $this->skipWithoutMultisite();
    321 
    322318        $blog_id = self::factory()->blog->create( array( 'path' => '/example' ) );
    323319        switch_to_blog( $blog_id );
  • trunk/tests/phpunit/tests/theme/WPTheme.php

    r40543 r40564  
    149149     */
    150150    function test_wp_theme_network_enable_single_theme() {
    151         $this->skipWithoutMultisite();
    152 
    153151        $theme = 'testtheme-1';
    154152        $current_allowed_themes = get_site_option( 'allowedthemes' );
     
    168166     */
    169167    function test_wp_theme_network_enable_multiple_themes() {
    170         $this->skipWithoutMultisite();
    171 
    172168        $themes = array( 'testtheme-2', 'testtheme-3' );
    173169        $current_allowed_themes = get_site_option( 'allowedthemes' );
     
    187183     */
    188184    function test_network_disable_single_theme() {
    189         $this->skipWithoutMultisite();
    190 
    191185        $current_allowed_themes = get_site_option( 'allowedthemes' );
    192186
     
    210204     */
    211205    function test_network_disable_multiple_themes() {
    212         $this->skipWithoutMultisite();
    213 
    214206        $current_allowed_themes = get_site_option( 'allowedthemes' );
    215207
  • trunk/tests/phpunit/tests/user.php

    r40543 r40564  
    653653     */
    654654    function test_illegal_user_logins_multisite() {
    655         $this->skipWithoutMultisite();
    656 
    657655        $user_data = array(
    658656            'user_login' => 'testuser',
  • trunk/tests/phpunit/tests/user/capabilities.php

    r40563 r40564  
    616616     */
    617617    function test_super_admin_caps() {
    618         $this->skipWithoutMultisite();
    619 
    620618        $caps = $this->getAllCapsAndRoles();
    621619        $user = self::$super_admin;
     
    13611359     */
    13621360    function test_borked_current_user_can_for_blog() {
    1363         $this->skipWithoutMultisite();
    1364 
    13651361        $orig_blog_id = get_current_blog_id();
    13661362        $blog_id = self::factory()->blog->create();
     
    14221418     */
    14231419    function test_multisite_administrator_can_not_edit_users() {
    1424         $this->skipWithoutMultisite();
    1425 
    14261420        $user = self::$users['administrator'];
    14271421        $other_user = self::$users['subscriber'];
     
    14561450     */
    14571451    public function test_only_super_admins_can_delete_users_on_multisite() {
    1458         $this->skipWithoutMultisite();
    1459 
    14601452        $this->assertTrue( user_can( self::$super_admin->ID,             'delete_user', self::$users['subscriber']->ID ) );
    14611453
     
    14711463     */
    14721464    public function test_only_admins_can_delete_users_on_single_site() {
    1473         $this->skipWithMultisite();
    1474 
    14751465        $this->assertTrue( user_can( self::$users['administrator']->ID, 'delete_user', self::$users['subscriber']->ID ) );
    14761466
     
    15301520     */
    15311521    function test_multisite_administrator_with_manage_network_users_can_edit_users() {
    1532         $this->skipWithoutMultisite();
    1533 
    15341522        $user = self::$users['administrator'];
    15351523        $user->add_cap( 'manage_network_users' );
     
    15491537     */
    15501538    function test_multisite_administrator_with_manage_network_users_can_not_edit_super_admin() {
    1551         $this->skipWithoutMultisite();
    1552 
    15531539        $user = self::$users['administrator'];
    15541540        $user->add_cap( 'manage_network_users' );
     
    17751761     */
    17761762    public function test_only_super_admins_can_remove_themselves_on_multisite() {
    1777         $this->skipWithoutMultisite();
    1778 
    17791763        $this->assertTrue( user_can( self::$super_admin->ID, 'remove_user', self::$super_admin->ID ) );
    17801764
  • trunk/tests/phpunit/tests/user/countUsers.php

    r40560 r40564  
    1313     */
    1414    public function test_count_users_is_accurate( $strategy ) {
    15         $this->skipWithMultisite();
    16 
    1715        // Setup users
    1816        $admin = self::factory()->user->create( array(
     
    6159     */
    6260    public function test_count_users_multisite_is_accurate( $strategy ) {
    63         $this->skipWithoutMultisite();
    64 
    6561        // Setup users
    6662        $admin = self::factory()->user->create( array(
  • trunk/tests/phpunit/tests/user/query.php

    r40543 r40564  
    556556     */
    557557    public function test_roles_and_caps_should_be_populated_for_explicit_value_of_blog_id_on_nonms() {
    558         $this->skipWithMultisite();
    559 
    560558        $query = new WP_User_Query( array(
    561559            'include' => self::$author_ids[0],
     
    575573     */
    576574    public function test_roles_and_caps_should_be_populated_for_explicit_value_of_current_blog_id_on_ms() {
    577         $this->skipWithoutMultisite();
    578 
    579575        $query = new WP_User_Query( array(
    580576            'include' => self::$author_ids[0],
     
    594590     */
    595591    public function test_roles_and_caps_should_be_populated_for_explicit_value_of_different_blog_id_on_ms_when_fields_all_with_meta() {
    596         $this->skipWithoutMultisite();
    597 
    598592        $b = self::factory()->blog->create();
    599593
     
    619613     */
    620614    public function test_roles_and_caps_should_be_populated_for_explicit_value_of_different_blog_id_on_ms_when_fields_all() {
    621         $this->skipWithoutMultisite();
    622 
    623615        $b = self::factory()->blog->create();
    624616        add_user_to_blog( $b, self::$author_ids[0], 'author' );
     
    643635     */
    644636    public function test_who_authors() {
    645         $this->skipWithoutMultisite();
    646 
    647637        $b = self::factory()->blog->create();
    648638
     
    668658     */
    669659    public function test_who_authors_should_work_alongside_meta_query() {
    670         $this->skipWithoutMultisite();
    671 
    672660        $b = self::factory()->blog->create();
    673661
     
    702690     */
    703691    public function test_who_authors_should_work_alongside_meta_params() {
    704         $this->skipWithoutMultisite();
    705 
    706692        $b = self::factory()->blog->create();
    707693
     
    794780     */
    795781    public function test_has_published_posts_should_respect_blog_id() {
    796         $this->skipWithoutMultisite();
    797 
    798782        $blogs = self::factory()->blog->create_many( 2 );
    799783
     
    13601344     */
    13611345    public function test_blog_id_should_restrict_by_blog_without_requiring_a_named_role() {
    1362         $this->skipWithoutMultisite();
    1363 
    13641346        $sites = self::factory()->blog->create_many( 2 );
    13651347
     
    13811363     */
    13821364    public function test_calling_prepare_query_a_second_time_should_not_add_another_cap_query_on_multisite() {
    1383         $this->skipWithoutMultisite();
    1384 
    13851365        $site_id = get_current_blog_id();
    13861366        add_user_to_blog( $site_id, self::$author_ids[0], 'author' );
  • trunk/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php

    r40543 r40564  
    1010     */
    1111    function test_wp_authenticate_spam_check_returns_user_when_single_site() {
    12         $this->skipWithMultisite();
    13 
    1412        $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
    1513        $user = new WP_User( $user_id );
     
    2422     */
    2523    function test_wp_authenticate_spam_check_returns_user_when_not_flagged() {
    26         $this->skipWithoutMultisite();
    27 
    2824        $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
    2925        $user = new WP_User( $user_id );
     
    3834     */
    3935    function test_wp_authenticate_spam_check_returns_wp_error_when_flagged() {
    40         $this->skipWithoutMultisite();
    41 
    4236        $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
    4337        update_user_status( $user_id, 'spam', 1 );
  • trunk/tests/phpunit/tests/user/wpDeleteUser.php

    r40543 r40564  
    128128     */
    129129    public function test_numeric_string_user_id() {
    130         $this->skipWithMultisite();
    131 
    132130        $u = self::factory()->user->create();
    133131
     
    149147     */
    150148    public function test_should_return_false_for_object_user_id() {
    151         $this->skipWithMultisite();
    152 
    153149        $u_obj = self::factory()->user->create_and_get();
    154150        $this->assertFalse( wp_delete_user( $u_obj ) );
  • trunk/tests/phpunit/tests/user/wpGetUsersWithNoRole.php

    r40543 r40564  
    1111     */
    1212    public function test_get_users_with_no_role_is_accurate() {
    13         $this->skipWithMultisite();
    14 
    1513        // Setup users
    1614        $admin = self::factory()->user->create( array(
     
    4341     */
    4442    public function test_get_users_with_no_role_multisite_is_accurate() {
    45         $this->skipWithoutMultisite();
    46 
    4743        // Setup users
    4844        $admin = self::factory()->user->create( array(
Note: See TracChangeset for help on using the changeset viewer.