Make WordPress Core

Ticket #39265: root.2.patch

File root.2.patch, 260.0 KB (added by pbearne, 5 years ago)

updated root patch

  • tests/phpunit/tests/actions.php

     
    77 */
    88class Tests_Actions extends WP_UnitTestCase {
    99
     10        /**
     11         *
     12         * @covers ::do_action
     13         */
    1014        function test_simple_action() {
    1115                $a   = new MockAction();
    1216                $tag = __FUNCTION__;
     
    2428                $this->assertEquals( array( '' ), $args );
    2529        }
    2630
     31        /**
     32         * @covers ::remove_action
     33         */
    2734        function test_remove_action() {
    2835                $a   = new MockAction();
    2936                $tag = __FUNCTION__;
     
    4350
    4451        }
    4552
     53        /**
     54         * @covers ::has_action
     55         */
    4656        function test_has_action() {
    4757                $tag  = __FUNCTION__;
    4858                $func = __FUNCTION__ . '_func';
     
    5767                $this->assertFalse( has_action( $tag ) );
    5868        }
    5969
    60         // One tag with multiple actions.
     70        /**
     71         * One tag with multiple actions.
     72         *
     73         * @covers ::add_action
     74         */
    6175        function test_multiple_actions() {
    6276                $a1  = new MockAction();
    6377                $a2  = new MockAction();
     
    7488                $this->assertEquals( 1, $a2->get_call_count() );
    7589        }
    7690
     91        /**
     92         * One tag with multiple actions.
     93         *
     94         * @covers ::do_action
     95         */
    7796        function test_action_args_1() {
    7897                $a   = new MockAction();
    7998                $tag = __FUNCTION__;
     
    89108                $this->assertEquals( array( $val ), array_pop( $argsvar ) );
    90109        }
    91110
     111        /**
     112         * One tag with multiple actions.
     113         *
     114         * @covers ::do_action
     115         */
    92116        function test_action_args_2() {
    93117                $a1   = new MockAction();
    94118                $a2   = new MockAction();
     
    120144         *
    121145         * @see https://core.trac.wordpress.org/ticket/17817#comment:72
    122146         * @ticket 17817
     147         *
     148         * @covers ::do_action
    123149         */
    124150        function test_action_args_3() {
    125151                $a1   = new MockAction();
     
    157183         * Tests PHP 4 notation for calling actions while passing in an object by reference.
    158184         *
    159185         * @ticket 48312
     186         *
     187         * @covers ::do_action
    160188         */
    161189        function test_action_args_with_php4_syntax() {
    162190                $a   = new MockAction();
     
    201229                $this->assertEquals( $expected, $a->get_events() );
    202230        }
    203231
     232        /**
     233         * @covers ::did_action
     234         */
    204235        function test_did_action() {
    205236                $tag1 = 'action1';
    206237                $tag2 = 'action2';
     
    222253
    223254        }
    224255
     256        /**
     257         * @covers ::add_action
     258         */
    225259        function test_all_action() {
    226260                $a    = new MockAction();
    227261                $tag1 = __FUNCTION__ . '_1';
     
    246280
    247281        }
    248282
     283        /**
     284         * @covers ::remove_action
     285         */
    249286        function test_remove_all_action() {
    250287                $a   = new MockAction();
    251288                $tag = __FUNCTION__;
     
    266303                $this->assertEquals( array( $tag ), $a->get_tags() );
    267304        }
    268305
     306        /**
     307         * @covers ::do_action_ref_array
     308         */
    269309        function test_action_ref_array() {
    270310                $obj = new stdClass();
    271311                $a   = new MockAction();
     
    284324
    285325        /**
    286326         * @ticket 11241
     327         *
     328         * @covers ::add_action
    287329         */
    288330        function test_action_keyed_array() {
    289331                $a = new MockAction();
     
    309351
    310352        }
    311353
     354        /**
     355         * @covers ::do_action
     356         */
    312357        function test_action_self_removal() {
    313358                add_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) );
    314359                do_action( 'test_action_self_removal' );
     
    321366
    322367        /**
    323368         * @ticket 17817
     369         *
     370         * @covers ::do_action
    324371         */
    325372        function test_action_recursion() {
    326373                $tag = __FUNCTION__;
     
    336383                $this->assertEquals( 2, $b->get_call_count(), 'recursive actions should call callbacks with later priority' );
    337384        }
    338385
     386        /**
     387         * @covers ::do_action
     388         */
    339389        function action_that_causes_recursion( $tag ) {
    340390                static $recursing = false;
    341391                if ( ! $recursing ) {
     
    348398        /**
    349399         * @ticket 9968
    350400         * @ticket 17817
     401         *
     402         * @covers ::add_action
    351403         */
    352404        function test_action_callback_manipulation_while_running() {
    353405                $tag = __FUNCTION__;
     
    383435         *
    384436         * This specificaly addresses the concern raised at
    385437         * https://core.trac.wordpress.org/ticket/17817#comment:52
     438         *
     439         * @covers ::remove_filter
    386440         */
    387441        function test_remove_anonymous_callback() {
    388442                $tag = __FUNCTION__;
     
    416470         * Test the ArrayAccess methods of WP_Hook
    417471         *
    418472         * @ticket 17817
     473         *
     474         * @covers ::has_action
    419475         */
    420476        function test_array_access_of_wp_filter_global() {
    421477                global $wp_filter;
     
    442498         * Make sure current_action() behaves as current_filter()
    443499         *
    444500         * @ticket 14994
     501         *
     502         * @covers ::current_action
    445503         */
    446504        function test_current_action() {
    447505                global $wp_current_filter;
     
    453511
    454512        /**
    455513         * @ticket 14994
     514         *
     515         * @covers ::doing_filter
    456516         */
    457517        function test_doing_filter() {
    458518                global $wp_current_filter;
     
    472532
    473533        /**
    474534         * @ticket 14994
     535         *
     536         * @covers ::doing_filter
    475537         */
    476538        function test_doing_action() {
    477539                global $wp_current_filter;
     
    491553
    492554        /**
    493555         * @ticket 14994
     556         *
     557         * @covers ::doing_filter
    494558         */
    495559        function test_doing_filter_real() {
    496560                $this->assertFalse( doing_filter() );            // No filter is passed in, and no filter is being processed.
     
    509573                $this->assertFalse( doing_filter( 'testing' ) ); // No longer doing this filter.
    510574        }
    511575
     576        /**
     577         * @covers ::doing_filter
     578         */
    512579        function apply_testing_filter() {
    513580                $this->apply_testing_filter = true;
    514581
     
    530597                $this->assertFalse( doing_filter( 'testing_nested' ) );
    531598        }
    532599
     600        /**
     601         * @covers ::doing_filter
     602         */
    533603        function apply_testing_nested_filter() {
    534604                $this->apply_testing_nested_filter = true;
    535605                $this->assertTrue( doing_filter() );
     
    541611        /**
    542612         * @ticket 10441
    543613         * @expectedDeprecated tests_do_action_deprecated
     614         *
     615         * @covers ::do_action_deprecated
    544616         */
    545617        public function test_do_action_deprecated() {
    546618                $p = new WP_Post( (object) array( 'post_title' => 'Foo' ) );
     
    559631        /**
    560632         * @ticket 10441
    561633         * @expectedDeprecated tests_do_action_deprecated
     634         *
     635         * @covers ::do_action_deprecated
    562636         */
    563637        public function test_do_action_deprecated_with_multiple_params() {
    564638                $p1 = new WP_Post( (object) array( 'post_title' => 'Foo1' ) );
  • tests/phpunit/tests/adminbar.php

     
    3131
    3232        /**
    3333         * @ticket 21117
     34         *
     35         * @covers WP_Admin_Bar::get_nodes
    3436         */
    3537        function test_content_post_type() {
    3638                wp_set_current_user( self::$editor_id );
     
    5052
    5153        /**
    5254         * @ticket 21117
     55         *
     56         * @covers WP_Admin_Bar::add_node
    5357         */
    5458        function test_merging_existing_meta_values() {
    5559                wp_set_current_user( self::$editor_id );
     
    8690        /**
    8791         * @ticket 25162
    8892         * @group ms-excluded
     93         *
     94         * @covers ::_wp_admin_bar_init
    8995         */
    9096        public function test_admin_bar_contains_correct_links_for_users_with_no_role() {
    9197                $this->assertFalse( user_can( self::$no_role_id, 'read' ) );
     
    111117        /**
    112118         * @ticket 25162
    113119         * @group ms-excluded
     120         *
     121         * @covers ::_wp_admin_bar_init
    114122         */
    115123        public function test_admin_bar_contains_correct_links_for_users_with_role() {
    116124                $this->assertTrue( user_can( self::$editor_id, 'read' ) );
     
    139147         * @ticket 25162
    140148         * @group multisite
    141149         * @group ms-required
     150         *
     151         * @covers ::_wp_admin_bar_init
    142152         */
    143153        public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_blog() {
    144154                $blog_id = self::factory()->blog->create(
     
    188198         * @ticket 25162
    189199         * @group multisite
    190200         * @group ms-required
     201         *
     202         * @covers ::_wp_admin_bar_init
    191203         */
    192204        public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_network() {
    193205                $this->assertTrue( user_can( self::$admin_id, 'read' ) );
     
    239251                restore_current_blog();
    240252        }
    241253
     254        /**
     255         * @return mixed
     256         */
    242257        protected function get_standard_admin_bar() {
    243258                global $wp_admin_bar;
    244259
     
    259274         *
    260275         * @param array  $node_data     The data for a node, passed to `WP_Admin_Bar::add_node()`.
    261276         * @param string $expected_html The expected HTML when admin menu is rendered.
     277         *
     278         * @covers WP_Admin_Bar::add_node
    262279         */
    263280        public function test_admin_bar_with_tabindex_meta( $node_data, $expected_html ) {
    264281                $admin_bar = new WP_Admin_Bar();
     
    347364
    348365        /**
    349366         * @ticket 22247
     367         *
     368         * @covers ::_wp_admin_bar_init
     369         * @covers WP_Admin_Bar::get_node
    350370         */
    351371        public function test_admin_bar_has_edit_link_for_existing_posts() {
    352372                wp_set_current_user( self::$editor_id );
     
    374394
    375395        /**
    376396         * @ticket 22247
     397         *
     398         * @covers WP_Admin_Bar::get_node
    377399         */
    378400        public function test_admin_bar_has_no_edit_link_for_non_existing_posts() {
    379401                wp_set_current_user( self::$editor_id );
     
    393415
    394416        /**
    395417         * @ticket 34113
     418         *
     419         * @covers WP_Admin_Bar::get_node
    396420         */
    397421        public function test_admin_bar_has_no_archives_link_if_no_static_front_page() {
    398422                set_current_screen( 'edit-post' );
     
    407431
    408432        /**
    409433         * @ticket 34113
     434         *
     435         * @covers WP_Admin_Bar::get_node
    410436         */
    411437        public function test_admin_bar_contains_view_archive_link_if_static_front_page() {
    412438                update_option( 'show_on_front', 'page' );
     
    422448
    423449        /**
    424450         * @ticket 34113
     451         *
     452         * @covers WP_Admin_Bar::get_node
    425453         */
    426454        public function test_admin_bar_has_no_archives_link_for_pages() {
    427455                set_current_screen( 'edit-page' );
     
    437465        /**
    438466         * @ticket 37949
    439467         * @group ms-excluded
     468         *
     469         * @covers WP_Admin_Bar::get_node
    440470         */
    441471        public function test_admin_bar_contains_correct_about_link_for_users_with_role() {
    442472                wp_set_current_user( self::$editor_id );
     
    454484        /**
    455485         * @ticket 37949
    456486         * @group ms-excluded
     487         *
     488         * @covers WP_Admin_Bar::get_node
    457489         */
    458490        public function test_admin_bar_contains_correct_about_link_for_users_with_no_role() {
    459491                wp_set_current_user( self::$no_role_id );
     
    473505         * @ticket 37949
    474506         * @group multisite
    475507         * @group ms-required
     508         *
     509         * @covers WP_Admin_Bar::get_node
    476510         */
    477511        public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite() {
    478512                // User is not a member of a site.
     
    492526
    493527        /**
    494528         * @ticket 34113
     529         *
     530         * @covers WP_Admin_Bar::get_node
    495531         */
    496532        public function test_admin_bar_has_no_archives_link_for_non_public_cpt() {
    497533                register_post_type(
     
    516552
    517553        /**
    518554         * @ticket 34113
     555         *
     556         * @covers WP_Admin_Bar::get_node
    519557         */
    520558        public function test_admin_bar_has_no_archives_link_for_cpt_without_archive() {
    521559                register_post_type(
     
    540578
    541579        /**
    542580         * @ticket 34113
     581         *
     582         * @covers WP_Admin_Bar::get_node
    543583         */
    544584        public function test_admin_bar_has_no_archives_link_for_cpt_not_shown_in_admin_bar() {
    545585                register_post_type(
     
    596636
    597637        /**
    598638         * @ticket 39252
     639         *
     640         * @covers WP_Admin_Bar::get_node
    599641         */
    600642        public function test_new_user_link_exists_for_user_with_create_users() {
    601643                wp_set_current_user( self::$admin_id );
     
    615657
    616658        /**
    617659         * @ticket 39252
     660         *
     661         * @covers WP_Admin_Bar::get_node
    618662         */
    619663        public function test_new_user_link_existence_for_user_with_promote_users() {
    620664                wp_set_current_user( self::$admin_id );
     
    638682
    639683        /**
    640684         * @ticket 39252
     685         *
     686         * @covers WP_Admin_Bar::get_node
    641687         */
    642688        public function test_new_user_link_does_not_exist_for_user_without_create_or_promote_users() {
    643689                wp_set_current_user( self::$admin_id );
     
    657703        /**
    658704         * @ticket 30937
    659705         * @covers ::wp_admin_bar_customize_menu
     706         *
     707         * @covers WP_Admin_Bar::get_node
    660708         */
    661709        public function test_customize_link() {
    662710                global $wp_customize;
     
    694742        /**
    695743         * @ticket 39082
    696744         * @group ms-required
     745         *
     746         * @covers WP_Admin_Bar::get_nodes
    697747         */
    698748        public function test_my_sites_network_menu_for_regular_user() {
    699749                wp_set_current_user( self::$editor_id );
     
    709759        /**
    710760         * @ticket 39082
    711761         * @group ms-required
     762         *
     763         * @covers WP_Admin_Bar::get_nodes
    712764         */
    713765        public function test_my_sites_network_menu_for_super_admin() {
    714766                wp_set_current_user( self::$editor_id );
     
    726778        /**
    727779         * @ticket 39082
    728780         * @group ms-required
     781         *
     782         * @covers WP_Admin_Bar::get_nodes
    729783         */
    730784        public function test_my_sites_network_menu_for_regular_user_with_network_caps() {
    731785                global $current_user;
  • tests/phpunit/tests/auth.php

     
    3535                wp_set_current_user( self::$user_id );
    3636        }
    3737
     38        /**
     39         * @covers ::wp_validate_auth_cookie
     40         */
    3841        function test_auth_cookie_valid() {
    3942                $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'auth' );
    4043                $this->assertEquals( self::$user_id, wp_validate_auth_cookie( $cookie, 'auth' ) );
    4144        }
    4245
     46        /**
     47         * @covers ::wp_validate_auth_cookie
     48         */
    4349        function test_auth_cookie_invalid() {
    4450                // 3600 or less and +3600 may occur in wp_validate_auth_cookie(),
    4551                // as an ajax test may have defined DOING_AJAX, failing the test.
     
    5662                $this->assertEquals( false, wp_validate_auth_cookie( self::$user_id, 'auth' ), 'altered cookie' );
    5763        }
    5864
     65        /**
     66         * @covers ::wp_validate_auth_cookie
     67         */
    5968        function test_auth_cookie_scheme() {
    6069                // Arbitrary scheme name.
    6170                $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' );
     
    6877
    6978        /**
    7079         * @ticket 23494
     80         *
     81         * @covers ::wp_authenticate
    7182         */
    7283        function test_password_trimming() {
    7384                $passwords_to_test = array(
     
    93104         * wp_hash_password function
    94105         *
    95106         * @ticket 24973
     107         *
     108         * @covers ::wp_hash_password
    96109         */
    97110        function test_wp_hash_password_trimming() {
    98111
    99112                $password = ' pass with leading whitespace';
    100                 $this->assertTrue( wp_check_password( 'pass with leading whitespace', wp_hash_password( $password ) ) );
     113                $this->assertTrue( wp_check_password( 'pass with leading whitespace', ( $password ) ) );
    101114
    102115                $password = 'pass with trailing whitespace ';
    103116                $this->assertTrue( wp_check_password( 'pass with trailing whitespace', wp_hash_password( $password ) ) );
     
    114127
    115128        /**
    116129         * @ticket 29217
     130         *
     131         * @covers ::wp_verify_nonce
    117132         */
    118133        function test_wp_verify_nonce_with_empty_arg() {
    119134                $this->assertFalse( wp_verify_nonce( '' ) );
     
    122137
    123138        /**
    124139         * @ticket 29542
     140         *
     141         * @covers ::wp_verify_nonce
    125142         */
    126143        function test_wp_verify_nonce_with_integer_arg() {
    127144                $this->assertFalse( wp_verify_nonce( 1 ) );
     
    129146
    130147        /**
    131148         * @ticket 24030
     149         *
     150         * @covers ::wp_verify_nonce
    132151         */
    133152        function test_wp_nonce_verify_failed() {
    134153                $nonce = substr( md5( uniqid() ), 0, 10 );
     
    141160
    142161        /**
    143162         * @ticket 24030
     163         *
     164         * @covers ::wp_verify_nonce
    144165         */
    145166        function test_wp_nonce_verify_success() {
    146167                $nonce = wp_create_nonce( 'nonce_test_action' );
     
    153174
    154175        /**
    155176         * @ticket 36361
     177         *
     178         * @covers ::check_admin_referer
    156179         */
    157180        public function test_check_admin_referer_with_no_action_triggers_doing_it_wrong() {
    158181                $this->setExpectedIncorrectUsage( 'check_admin_referer' );
     
    165188                unset( $_REQUEST['_wpnonce'] );
    166189        }
    167190
     191        /**
     192         * @covers ::check_admin_referer
     193         */
    168194        public function test_check_admin_referer_with_default_action_as_string_not_doing_it_wrong() {
    169195                // A valid nonce needs to be set so the check doesn't die().
    170196                $_REQUEST['_wpnonce'] = wp_create_nonce( '-1' );
     
    176202
    177203        /**
    178204         * @ticket 36361
     205        /**
     206         *
     207         * @c    *
     208         * @covers ::check_ajax_referer
    179209         */
    180210        public function test_check_ajax_referer_with_no_action_triggers_doing_it_wrong() {
    181211                $this->setExpectedIncorrectUsage( 'check_ajax_referer' );
     
    188218                unset( $_REQUEST['_wpnonce'] );
    189219        }
    190220
     221        /**
     222         * @covers ::wp_authenticate
     223         */
    191224        function test_password_length_limit() {
    192225                $limit = str_repeat( 'a', 4096 );
    193226
     
    237270
    238271        /**
    239272         * @ticket 45746
     273         *
     274         * @covers ::check_password_reset_key
    240275         */
    241276        function test_user_activation_key_is_saved() {
    242277                $user = get_userdata( $this->user->ID );
     
    251286
    252287        /**
    253288         * @ticket 32429
     289         *
     290         * @covers ::check_password_reset_key
    254291         */
    255292        function test_user_activation_key_is_checked() {
    256293                global $wpdb;
     
    289326
    290327        /**
    291328         * @ticket 32429
     329         *
     330         * @covers ::check_password_reset_key
    292331         */
    293332        function test_expired_user_activation_key_is_rejected() {
    294333                global $wpdb;
     
    312351
    313352        /**
    314353         * @ticket 32429
     354         *
     355         * @covers ::check_password_reset_key
    315356         */
    316357        function test_empty_user_activation_key_fails_key_check() {
    317358                // An empty user_activation_key should not allow any key to be accepted.
     
    325366
    326367        /**
    327368         * @ticket 32429
     369         *
     370         * @covers ::check_password_reset_key
    328371         */
    329372        function test_legacy_user_activation_key_is_rejected() {
    330373                global $wpdb;
     
    355398        /**
    356399         * @ticket 32429
    357400         * @ticket 24783
     401         *
     402         * @covers ::check_password_reset_key
    358403         */
    359404        function test_plaintext_user_activation_key_is_rejected() {
    360405                global $wpdb;
     
    386431         * Ensure users can log in using both their username and their email address.
    387432         *
    388433         * @ticket 9568
     434         *
     435         * @covers ::wp_authenticate
    389436         */
    390437        public function test_log_in_using_email() {
    391438                $user_args = array(
     
    401448
    402449        /**
    403450         * @ticket 38744
     451         *
     452         * @covers ::wp_signon
    404453         */
    405454        public function test_wp_signon_using_email_with_an_apostrophe() {
    406455                $user_args = array(
  • tests/phpunit/tests/avatar.php

     
    88class Tests_Avatar extends WP_UnitTestCase {
    99        /**
    1010         * @ticket 21195
     11         *
     12         * @covers ::get_avatar_url
    1113         */
    1214        public function test_get_avatar_url_gravatar_url() {
    1315                $url = get_avatar_url( 1 );
     
    1618
    1719        /**
    1820         * @ticket 21195
     21         *
     22         * @covers ::get_avatar_url
    1923         */
    2024        public function test_get_avatar_url_size() {
    2125                $url = get_avatar_url( 1 );
     
    2832
    2933        /**
    3034         * @ticket 21195
     35         *
     36         * @covers ::get_avatar_url
    3137         */
    3238        public function test_get_avatar_url_default() {
    3339                $url = get_avatar_url( 1 );
     
    4551
    4652        /**
    4753         * @ticket 21195
     54         *
     55         * @covers ::get_avatar_url
    4856         */
    4957        public function test_get_avatar_url_rating() {
    5058                $url = get_avatar_url( 1 );
     
    5765
    5866        /**
    5967         * @ticket 21195
     68         *
     69         * @covers ::get_avatar_url
    6070         */
    6171        public function test_get_avatar_url_scheme() {
    6272                $url = get_avatar_url( 1 );
     
    7383
    7484        /**
    7585         * @ticket 21195
     86         *
     87         * @covers ::get_avatar_url
    7688         */
    7789        public function test_get_avatar_url_user() {
    7890                $url = get_avatar_url( 1 );
     
    106118        protected $fake_url;
    107119        /**
    108120         * @ticket 21195
     121         *
     122         * @covers ::get_avatar_url
    109123         */
    110124        public function test_pre_get_avatar_url_filter() {
    111125                $this->fake_url = 'haha wat';
     
    116130
    117131                $this->assertEquals( $url, $this->fake_url );
    118132        }
     133
    119134        public function pre_get_avatar_url_filter( $args ) {
    120135                $args['url'] = $this->fake_url;
    121136                return $args;
     
    123138
    124139        /**
    125140         * @ticket 21195
     141         *
     142         * @covers ::get_avatar_url
    126143         */
    127144        public function test_get_avatar_url_filter() {
    128145                $this->fake_url = 'omg lol';
     
    139156
    140157        /**
    141158         * @ticket 21195
     159         *
     160         * @covers ::get_avatar_url
    142161         */
    143162        public function test_get_avatar_comment_types_filter() {
    144163                $url = get_avatar_url( 1 );
     
    167186                return $comment_types;
    168187        }
    169188
     189        /**
     190         * @covers ::get_avatar
     191         */
    170192        public function test_get_avatar() {
    171193                $img = get_avatar( 1 );
    172194                $this->assertEquals( preg_match( "|^<img alt='[^']*' src='[^']*' srcset='[^']*' class='[^']*' height='[^']*' width='[^']*' loading='lazy'/>$|", $img ), 1 );
    173195        }
    174196
     197        /**
     198         * @covers ::get_avatar
     199         */
    175200        public function test_get_avatar_size() {
    176201                $size = '100';
    177202                $img  = get_avatar( 1, $size );
     
    178203                $this->assertEquals( preg_match( "|^<img .*height='$size'.*width='$size'|", $img ), 1 );
    179204        }
    180205
     206        /**
     207         * @covers ::get_avatar
     208         */
    181209        public function test_get_avatar_alt() {
    182210                $alt = 'Mr Hyde';
    183211                $img = get_avatar( 1, 96, '', $alt );
     
    184212                $this->assertEquals( preg_match( "|^<img alt='$alt'|", $img ), 1 );
    185213        }
    186214
     215        /**
     216         * @covers ::get_avatar
     217         */
    187218        public function test_get_avatar_class() {
    188219                $class = 'first';
    189220                $img   = get_avatar( 1, 96, '', '', array( 'class' => $class ) );
     
    190221                $this->assertEquals( preg_match( "|^<img .*class='[^']*{$class}[^']*'|", $img ), 1 );
    191222        }
    192223
     224        /**
     225         * @covers ::get_avatar
     226         */
    193227        public function test_get_avatar_default_class() {
    194228                $img = get_avatar( 1, 96, '', '', array( 'force_default' => true ) );
    195229                $this->assertEquals( preg_match( "|^<img .*class='[^']*avatar-default[^']*'|", $img ), 1 );
    196230        }
    197231
     232        /**
     233         * @covers ::get_avatar
     234         */
    198235        public function test_get_avatar_force_display() {
    199236                $old = get_option( 'show_avatars' );
    200237                update_option( 'show_avatars', false );
     
    210247        protected $fake_img;
    211248        /**
    212249         * @ticket 21195
     250         *
     251         * @covers ::get_avatar
    213252         */
    214253        public function test_pre_get_avatar_filter() {
    215254                $this->fake_img = 'YOU TOO?!';
     
    226265
    227266        /**
    228267         * @ticket 21195
     268         *
     269         * @covers ::get_avatar
    229270         */
    230271        public function test_get_avatar_filter() {
    231272                $this->fake_url = 'YA RLY';
     
    244285         * The `get_avatar_data()` function should return gravatar url when comment type allowed to retrieve avatars.
    245286         *
    246287         * @ticket 44033
     288         *
     289         * @covers ::is_avatar_comment_type
     290         * @covers ::get_avatar
    247291         */
    248292        public function test_get_avatar_data_should_return_gravatar_url_when_input_avatar_comment_type() {
    249293                $comment_type = 'comment';
     
    264308         * The `get_avatar_data()` function should return invalid url when comment type not allowed to retrieve avatars.
    265309         *
    266310         * @ticket 44033
     311         *
     312         * @covers ::is_avatar_comment_type
     313         * @covers ::get_avatar
    267314         */
    268315        public function test_get_avatar_data_should_return_invalid_url_when_input_not_avatar_comment_type() {
    269316                $comment_type = 'review';
  • tests/phpunit/tests/basic.php

     
    33/**
    44 * just make sure the test framework is working
    55 *
     6 * No Covers as this checks for content in files
     7 *
    68 * @group testsuite
    79 */
    810class Tests_Basic extends WP_UnitTestCase {
    911
     12        /**
     13         * @coversNothing
     14         */
    1015        function test_license() {
    1116                // This test is designed to only run on trunk/master.
    1217                $this->skipOnAutomatedBranches();
     
    1722                $this->assertEquals( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." );
    1823        }
    1924
     25        /**
     26         * @coversNothing
     27         */
    2028        function test_security_md() {
    2129                // This test is designed to only run on trunk/master.
    2230                $this->skipOnAutomatedBranches();
     
    2836                $this->assertEquals( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." );
    2937        }
    3038
     39        /**
     40         * @coversNothing
     41         */
    3142        function test_package_json() {
    3243                $package_json    = file_get_contents( dirname( ABSPATH ) . '/package.json' );
    3344                $package_json    = json_decode( $package_json, true );
     
    4253
    4354        /**
    4455         * @depends test_package_json
     56         *
     57         * @coversNothing
    4558         */
    4659        function test_package_json_node_engine( $package_json ) {
    4760                $this->assertArrayHasKey( 'engines', $package_json );
     
    5063                $this->assertRegExp( '~^=?\d+\.\d+\.\d+$~', $node, "package.json's node version cannot be a range." );
    5164        }
    5265
    53         // Test some helper utility functions.
    54 
     66        /**
     67         * Test some helper utility functions.
     68         *
     69         * @coversNothing
     70         */
    5571        function test_strip_ws() {
    5672                $this->assertEquals( '', strip_ws( '' ) );
    5773                $this->assertEquals( 'foo', strip_ws( 'foo' ) );
     
    7995
    8096        }
    8197
     98        /**
     99         * @coversNothing
     100         */
    82101        function test_mask_input_value() {
    83102                $in = <<<EOF
    84103<h2>Assign Authors</h2>
  • tests/phpunit/tests/cache.php

     
    2626                return $cache;
    2727        }
    2828
     29        /**
     30         *
     31         * @covers WP_Object_Cache::test_miss
     32         */
    2933        function test_miss() {
    3034                $this->assertEquals( null, $this->cache->get( 'test_miss' ) );
    3135        }
    3236
     37        /**
     38         *
     39         * @covers WP_Object_Cache::add
     40         */
    3341        function test_add_get() {
    3442                $key = __FUNCTION__;
    3543                $val = 'val';
     
    3846                $this->assertEquals( $val, $this->cache->get( $key ) );
    3947        }
    4048
     49        /**
     50         *
     51         * @covers WP_Object_Cache::add
     52         */
    4153        function test_add_get_0() {
    4254                $key = __FUNCTION__;
    4355                $val = 0;
     
    4759                $this->assertEquals( $val, $this->cache->get( $key ) );
    4860        }
    4961
     62        /**
     63         *
     64         * @covers WP_Object_Cache::add
     65         */
    5066        function test_add_get_null() {
    5167                $key = __FUNCTION__;
    5268                $val = null;
     
    5672                $this->assertEquals( '', $this->cache->get( $key ) );
    5773        }
    5874
     75        /**
     76         *
     77         * @covers WP_Object_Cache::add
     78         */
    5979        function test_add() {
    6080                $key  = __FUNCTION__;
    6181                $val1 = 'val1';
     
    6989                $this->assertEquals( $val1, $this->cache->get( $key ) );
    7090        }
    7191
     92        /**
     93         *
     94         * @covers WP_Object_Cache::replace
     95         */
    7296        function test_replace() {
    7397                $key  = __FUNCTION__;
    7498                $val  = 'val1';
     
    83107                $this->assertEquals( $val2, $this->cache->get( $key ) );
    84108        }
    85109
     110        /**
     111         *
     112         * @covers WP_Object_Cache::set
     113         */
    86114        function test_set() {
    87115                $key  = __FUNCTION__;
    88116                $val1 = 'val1';
     
    96124                $this->assertEquals( $val2, $this->cache->get( $key ) );
    97125        }
    98126
     127        /**
     128         *
     129         * @covers WP_Object_Cache::flush
     130         */
    99131        function test_flush() {
    100132                global $_wp_using_ext_object_cache;
    101133
     
    114146                $this->assertFalse( $this->cache->get( $key ) );
    115147        }
    116148
    117         // Make sure objects are cloned going to and from the cache.
     149        /**
     150         * Make sure objects are cloned going to and from the cache.
     151         *
     152         * @covers WP_Object_Cache::set
     153         * @covers WP_Object_Cache::get
     154         */
    118155        function test_object_refs() {
    119156                $key           = __FUNCTION__ . '_1';
    120157                $object_a      = new stdClass;
     
    137174                $this->assertEquals( 'bravo', $object_a->foo );
    138175        }
    139176
     177        /**
     178         *
     179         * @covers WP_Object_Cache::incr
     180         */
    140181        function test_incr() {
    141182                $key = __FUNCTION__;
    142183
     
    150191                $this->assertEquals( 3, $this->cache->get( $key ) );
    151192        }
    152193
     194        /**
     195         *
     196         * @covers ::wp_cache_incr
     197         */
    153198        function test_wp_cache_incr() {
    154199                $key = __FUNCTION__;
    155200
     
    163208                $this->assertEquals( 3, wp_cache_get( $key ) );
    164209        }
    165210
     211        /**
     212         *
     213         * @covers WP_Object_Cache::decr
     214         */
    166215        function test_decr() {
    167216                $key = __FUNCTION__;
    168217
     
    182231
    183232        /**
    184233         * @ticket 21327
     234         *
     235         * @covers ::wp_cache_decr
    185236         */
    186237        function test_wp_cache_decr() {
    187238                $key = __FUNCTION__;
     
    200251                $this->assertEquals( 0, wp_cache_get( $key ) );
    201252        }
    202253
     254        /**
     255         *
     256         * @covers WP_Object_Cache::delete
     257         */
    203258        function test_delete() {
    204259                $key = __FUNCTION__;
    205260                $val = 'val';
     
    215270                $this->assertFalse( $this->cache->delete( $key, 'default' ) );
    216271        }
    217272
     273        /**
     274         *
     275         * @covers ::wp_cache_delete
     276         * @covers ::wp_cache_get
     277         * @covers ::wp_cache_set
     278         */
    218279        function test_wp_cache_delete() {
    219280                $key = __FUNCTION__;
    220281                $val = 'val';
     
    234295                $this->assertFalse( wp_cache_delete( $key, 'default' ) );
    235296        }
    236297
     298        /**
     299         *
     300         * @covers WP_Object_Cache::switch_to_blog
     301         */
    237302        function test_switch_to_blog() {
    238303                if ( ! method_exists( $this->cache, 'switch_to_blog' ) ) {
    239304                        return;
     
    280345                $this->assertEquals( $val2, $this->cache->get( $key, 'global-cache-test' ) );
    281346        }
    282347
     348        /**
     349         *
     350         * @covers ::wp_cache_init
     351         */
    283352        function test_wp_cache_init() {
    284353                $new_blank_cache_object = new WP_Object_Cache();
    285354                wp_cache_init();
     
    294363                }
    295364        }
    296365
     366        /**
     367         *
     368         * @covers ::wp_cache_replace
     369         */
    297370        function test_wp_cache_replace() {
    298371                $key  = 'my-key';
    299372                $val1 = 'first-val';
     
    318391
    319392        /**
    320393         * @ticket 20875
     394         *
     395         * @covers ::wp_cache_get_multiple
    321396         */
    322397        public function test_get_multiple() {
    323398                wp_cache_set( 'foo1', 'bar', 'group1' );
  • tests/phpunit/tests/canonical.php

     
    1717
    1818        /**
    1919         * @dataProvider data_canonical
     20         *
     21         * @covers ::redirect_canonical
    2022         */
    2123        function test_canonical( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
    2224
     
    232234
    233235        /**
    234236         * @ticket 16557
     237         *
     238         * @covers ::redirect_guess_404_permalink
    235239         */
    236240        public function test_do_redirect_guess_404_permalink() {
    237241                // Test disable do_redirect_guess_404_permalink().
     
    242246
    243247        /**
    244248         * @ticket 16557
     249         *
     250         * @covers ::redirect_guess_404_permalink
    245251         */
    246252        public function test_pre_redirect_guess_404_permalink() {
    247253                // Test short-circuit filter.
     
    257263
    258264        /**
    259265         * @ticket 16557
     266         *
     267         * @covers ::redirect_guess_404_permalink
    260268         */
    261269        public function test_strict_redirect_guess_404_permalink() {
    262270                $post = self::factory()->post->create(
     
    277285
    278286        /**
    279287         * @ticket 43745
     288         *
     289         * @covers ::redirect_canonical
    280290         */
    281291        public function test_utf8_query_keys_canonical() {
    282292                $p = self::factory()->post->create(
  • tests/phpunit/tests/category.php

     
    1818         * Validate get_all_category_ids
    1919         *
    2020         * @expectedDeprecated get_all_category_ids
     21         *
     22         * @covers ::get_all_category_ids
    2123         */
    2224        function test_get_all_category_ids() {
    2325                // Ccreate categories.
     
    3436
    3537        /**
    3638         * Validate get_category_by_slug function
     39         *
     40         * @covers ::get_category_by_slug
    3741         */
    3842        function test_get_category_by_slug() {
    3943
     
    6468
    6569        /**
    6670         * Validate _make_cat_compat function
     71         *
     72         * @covers ::_make_cat_compat
    6773         */
    6874        function test__make_cat_compat() {
    6975
     
    141147
    142148        /**
    143149         * Validate get_cat_name function
     150         *
     151         * @covers ::get_cat_name
    144152         */
    145153        function test_get_cat_name() {
    146154
     
    161169
    162170        /**
    163171         * Validate get_cat_name function
     172         *
     173         * @covers ::get_cat_ID
    164174         */
    165175        function test_get_cat_ID() {
    166176
     
    181191
    182192        /**
    183193         * Validate get_category_by_path function
     194         *
     195         * @covers ::get_category_by_path
    184196         */
    185197        function test_get_category_by_path() {
    186198
  • tests/phpunit/tests/comment-submission.php

     
    3939                require_once ABSPATH . WPINC . '/class-phpass.php';
    4040        }
    4141
     42        /**
     43         * @covers ::wp_handle_comment_submission
     44         */
    4245        public function test_submitting_comment_to_invalid_post_returns_error() {
    4346                $error = 'comment_id_not_found';
    4447
     
    5558
    5659        }
    5760
     61        /**
     62         * @covers ::wp_handle_comment_submission
     63         */
    5864        public function test_submitting_comment_to_post_with_closed_comments_returns_error() {
    5965
    6066                $error = 'comment_closed';
     
    7884
    7985        }
    8086
     87        /**
     88         * @covers ::wp_handle_comment_submission
     89         */
    8190        public function test_submitting_comment_to_trashed_post_returns_error() {
    8291
    8392                $error = 'comment_on_trash';
     
    99108
    100109        }
    101110
     111        /**
     112         * @covers ::wp_handle_comment_submission
     113         */
    102114        public function test_submitting_comment_to_draft_post_returns_error() {
    103115                $error = 'comment_on_draft';
    104116
     
    124136
    125137        /**
    126138         * @ticket 39650
     139         *
     140         * @covers ::wp_handle_comment_submission
    127141         */
    128142        public function test_submitting_comment_to_draft_post_returns_error_message_for_user_with_correct_caps() {
    129143                $error = 'comment_on_draft';
     
    150164                $this->assertNotEmpty( $comment->get_error_message() );
    151165        }
    152166
     167        /**
     168         * @covers ::wp_handle_comment_submission
     169         */
    153170        public function test_submitting_comment_to_scheduled_post_returns_error() {
    154171
    155172                // Same error as commenting on a draft.
     
    176193
    177194        }
    178195
     196        /**
     197         * @covers ::wp_handle_comment_submission
     198         */
    179199        public function test_submitting_comment_to_password_required_post_returns_error() {
    180200
    181201                $error = 'comment_on_password_protected';
     
    199219
    200220        }
    201221
     222        /**
     223         * @covers ::wp_handle_comment_submission
     224         */
    202225        public function test_submitting_comment_to_password_protected_post_succeeds() {
    203226
    204227                $password = 'password';
     
    227250
    228251        }
    229252
     253        /**
     254         * @covers ::wp_handle_comment_submission
     255         */
    230256        public function test_submitting_valid_comment_as_logged_in_user_succeeds() {
    231257
    232258                $user = self::factory()->user->create_and_get(
     
    254280
    255281        }
    256282
     283        /**
     284         * @covers ::wp_handle_comment_submission
     285         */
    257286        public function test_submitting_valid_comment_anonymously_succeeds() {
    258287
    259288                $data    = array(
     
    280309         * wp_handle_comment_submission() expects un-slashed data.
    281310         *
    282311         * @group slashes
     312         *
     313         * @covers ::wp_handle_comment_submission
    283314         */
    284315        public function test_submitting_comment_handles_slashes_correctly_handles_slashes() {
    285316
     
    300331
    301332        }
    302333
     334        /**
     335         * @covers ::wp_handle_comment_submission
     336         */
    303337        public function test_submitting_comment_anonymously_to_private_post_returns_error() {
    304338
    305339                $error = 'comment_id_not_found';
     
    321355
    322356        }
    323357
     358        /**
     359         * @covers ::wp_handle_comment_submission
     360         */
    324361        public function test_submitting_comment_as_logged_in_user_to_inaccessible_private_post_returns_error() {
    325362
    326363                $error = 'comment_id_not_found';
     
    351388
    352389        }
    353390
     391        /**
     392         * @covers ::wp_handle_comment_submission
     393         */
    354394        public function test_submitting_comment_to_private_post_with_closed_comments_returns_correct_error() {
    355395
    356396                $error = 'comment_id_not_found';
     
    382422
    383423        }
    384424
     425        /**
     426         * @covers ::wp_handle_comment_submission
     427         */
    385428        public function test_submitting_comment_to_own_private_post_succeeds() {
    386429
    387430                wp_set_current_user( self::$author_id );
     
    405448
    406449        }
    407450
     451        /**
     452         * @covers ::wp_handle_comment_submission
     453         */
    408454        public function test_submitting_comment_to_accessible_private_post_succeeds() {
    409455
    410456                wp_set_current_user( self::$editor_id );
     
    428474
    429475        }
    430476
     477        /**
     478         * @covers ::wp_handle_comment_submission
     479         */
    431480        public function test_anonymous_user_cannot_comment_unfiltered_html() {
    432481
    433482                $data    = array(
     
    444493
    445494        }
    446495
     496        /**
     497         * @covers ::wp_handle_comment_submission
     498         */
    447499        public function test_unprivileged_user_cannot_comment_unfiltered_html() {
    448500
    449501                wp_set_current_user( self::$author_id );
     
    462514
    463515        }
    464516
     517        /**
     518         * @covers ::wp_handle_comment_submission
     519         */
    465520        public function test_unprivileged_user_cannot_comment_unfiltered_html_even_with_valid_nonce() {
    466521
    467522                wp_set_current_user( self::$author_id );
     
    486541
    487542        }
    488543
     544        /**
     545         * @covers ::wp_handle_comment_submission
     546         */
    489547        public function test_privileged_user_can_comment_unfiltered_html_with_valid_nonce() {
    490548
    491549                $this->assertFalse( defined( 'DISALLOW_UNFILTERED_HTML' ) );
     
    518576
    519577        }
    520578
     579        /**
     580         * @covers ::wp_handle_comment_submission
     581         */
    521582        public function test_privileged_user_cannot_comment_unfiltered_html_without_valid_nonce() {
    522583
    523584                if ( is_multisite() ) {
     
    542603
    543604        }
    544605
     606        /**
     607         * @covers ::wp_handle_comment_submission
     608         */
    545609        public function test_submitting_comment_as_anonymous_user_when_registration_required_returns_error() {
    546610
    547611                $error = 'not_logged_in';
     
    561625
    562626        }
    563627
     628        /**
     629         * @covers ::wp_handle_comment_submission
     630         */
    564631        public function test_submitting_comment_with_no_name_when_name_email_required_returns_error() {
    565632
    566633                $error = 'require_name_email';
     
    582649
    583650        }
    584651
     652        /**
     653         * @covers ::wp_handle_comment_submission
     654         */
    585655        public function test_submitting_comment_with_no_email_when_name_email_required_returns_error() {
    586656
    587657                $error = 'require_name_email';
     
    603673
    604674        }
    605675
     676        /**
     677         * @covers ::wp_handle_comment_submission
     678         */
    606679        public function test_submitting_comment_with_invalid_email_when_name_email_required_returns_error() {
    607680
    608681                $error = 'require_valid_email';
     
    625698
    626699        }
    627700
     701        /**
     702         * @covers ::wp_handle_comment_submission
     703         */
    628704        public function test_submitting_comment_with_no_comment_content_returns_error() {
    629705
    630706                $error = 'require_valid_comment';
     
    644720
    645721        /**
    646722         * @ticket 10377
     723         *
     724         * @covers ::wp_handle_comment_submission
    647725         */
    648726        public function test_submitting_comment_with_content_too_long_returns_error() {
    649727                $error = 'comment_content_column_length';
     
    662740
    663741        /**
    664742         * @ticket 10377
     743         *
     744         * @covers ::wp_handle_comment_submission
    665745         */
    666746        public function test_submitting_comment_with_author_too_long_returns_error() {
    667747                $error = 'comment_author_column_length';
     
    680760
    681761        /**
    682762         * @ticket 10377
     763         *
     764         * @covers ::wp_handle_comment_submission
    683765         */
    684766        public function test_submitting_comment_with_email_too_long_returns_error() {
    685767                $error = 'comment_author_email_column_length';
     
    698780
    699781        /**
    700782         * @ticket 10377
     783         *
     784         * @covers ::wp_handle_comment_submission
    701785         */
    702786        public function test_submitting_comment_with_url_too_long_returns_error() {
    703787                $error = 'comment_author_url_column_length';
     
    717801
    718802        /**
    719803         * @ticket 49236
     804         *
     805         * @covers ::wp_handle_comment_submission
    720806         */
    721807        public function test_submitting_comment_with_empty_type_results_in_correct_type() {
    722808                $data    = array(
     
    736822
    737823        /**
    738824         * @ticket 49236
     825         *
     826         * @covers ::wp_handle_comment_submission
    739827         */
    740828        public function test_inserting_comment_with_empty_type_results_in_correct_type() {
    741829                $data       = array(
     
    756844
    757845        /**
    758846         * @ticket 34997
     847         *
     848         * @covers ::wp_handle_comment_submission
    759849         */
    760850        public function test_comment_submission_sends_all_expected_parameters_to_preprocess_comment_filter() {
    761851
     
    798888
    799889        /**
    800890         * @ticket 36901
     891         *
     892         * @covers ::wp_handle_comment_submission
    801893         */
    802894        public function test_submitting_duplicate_comments() {
    803895                $data           = array(
     
    814906
    815907        /**
    816908         * @ticket 36901
     909         *
     910         * @covers ::wp_handle_comment_submission
    817911         */
    818912        public function test_comments_flood() {
    819913                $data          = array(
     
    833927
    834928        /**
    835929         * @ticket 36901
     930         *
     931         * @covers ::wp_handle_comment_submission
    836932         */
    837933        public function test_comments_flood_user_is_admin() {
    838934                $user = self::factory()->user->create_and_get(
  • tests/phpunit/tests/comment.php

     
    3030                );
    3131        }
    3232
     33        /**
     34         *
     35         *
     36         * @covers ::wp_update_comment
     37         */
    3338        public function test_wp_update_comment() {
    3439                $post  = self::factory()->post->create_and_get(
    3540                        array(
     
    7883
    7984        /**
    8085         * @ticket 30627
     86         *
     87         * @covers ::wp_update_comment
    8188         */
    8289        public function test_wp_update_comment_updates_comment_type() {
    8390                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     
    95102
    96103        /**
    97104         * @ticket 36784
     105         *
     106         * @covers ::wp_update_comment
    98107         */
    99108        public function test_wp_update_comment_updates_comment_meta() {
    100109                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     
    114123
    115124        /**
    116125         * @ticket 30307
     126         *
     127         * @covers ::wp_update_comment
    117128         */
    118129        public function test_wp_update_comment_updates_user_id() {
    119130                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     
    131142
    132143        /**
    133144         * @ticket 34954
     145         *
     146         * @covers ::wp_update_comment
    134147         */
    135148        public function test_wp_update_comment_with_no_post_id() {
    136149                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => 0 ) );
     
    152165
    153166        /**
    154167         * @ticket 39732
     168         *
     169         * @covers ::wp_update_comment
    155170         */
    156171        public function test_wp_update_comment_returns_false_for_invalid_comment_or_post_id() {
    157172                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     
    175190
    176191        /**
    177192         * @ticket 39732
     193         *
     194         * @covers ::wp_update_comment
    178195         */
    179196        public function test_wp_update_comment_is_wp_error() {
    180197                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     
    201218                return new WP_Error( 'comment_wrong', 'wp_update_comment_data filter fails for this comment.', 500 );
    202219        }
    203220
     221        /**
     222         *
     223         *
     224         * @covers ::get_approved_comments
     225         */
    204226        public function test_get_approved_comments() {
    205227                $ca1 = self::factory()->comment->create(
    206228                        array(
     
    257279
    258280        /**
    259281         * @ticket 30412
     282         *
     283         * @covers ::get_approved_comments
    260284         */
    261285        public function test_get_approved_comments_with_post_id_0_should_return_empty_array() {
    262286                $ca1 = self::factory()->comment->create(
     
    273297
    274298        /**
    275299         * @ticket 14279
     300         *
     301         * @covers ::wp_new_comment
    276302         */
    277303        public function test_wp_new_comment_respects_dates() {
    278304                $data = array(
     
    296322
    297323        /**
    298324         * @ticket 14601
     325         *
     326         * @covers ::wp_new_comment
    299327         */
    300328        public function test_wp_new_comment_respects_author_ip() {
    301329                $data = array(
     
    317345
    318346        /**
    319347         * @ticket 14601
     348         *
     349         * @covers ::wp_new_comment
    320350         */
    321351        public function test_wp_new_comment_respects_author_ip_empty_string() {
    322352                $data = array(
     
    338368
    339369        /**
    340370         * @ticket 14601
     371         *
     372         * @covers ::wp_new_comment
    341373         */
    342374        public function test_wp_new_comment_respects_comment_agent() {
    343375                $data = array(
     
    360392
    361393        /**
    362394         * @ticket 14601
     395         *
     396         * @covers ::wp_new_comment
    363397         */
    364398        public function test_wp_new_comment_should_trim_provided_comment_agent_to_254_chars() {
    365399                $data = array(
     
    382416
    383417        /**
    384418         * @ticket 14601
     419         *
     420         * @covers ::wp_new_comment
    385421         */
    386422        public function test_wp_new_comment_respects_comment_agent_empty_string() {
    387423                $data = array(
     
    402438                $this->assertEquals( $data['comment_agent'], $comment->comment_agent );
    403439        }
    404440
    405 
     441        /**
     442         * @covers ::wp_new_comment
     443         */
    406444        public function test_comment_field_lengths() {
    407445                $data = array(
    408446                        'comment_post_ID'      => self::$post_id,
     
    424462
    425463        /**
    426464         * @ticket 32566
     465         *
     466         * @covers ::wp_notify_moderator
    427467         */
    428468        public function test_wp_notify_moderator_should_not_throw_notice_when_post_author_is_0() {
    429469                $p = self::factory()->post->create(
     
    441481                $this->assertTrue( wp_notify_moderator( $c ) );
    442482        }
    443483
     484        /**
     485         *
     486         *
     487         * @covers ::wp_new_comment_notify_postauthor
     488         */
    444489        public function test_wp_new_comment_notify_postauthor_should_send_email_when_comment_is_approved() {
    445490                $c = self::factory()->comment->create(
    446491                        array(
     
    452497                $this->assertTrue( $sent );
    453498        }
    454499
     500        /**
     501         *
     502         *
     503         * @covers ::wp_new_comment_notify_postauthor
     504         */
    455505        public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_is_unapproved() {
    456506                $c = self::factory()->comment->create(
    457507                        array(
     
    466516
    467517        /**
    468518         * @ticket 33587
     519         *
     520         * @covers ::wp_new_comment_notify_postauthor
    469521         */
    470522        public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() {
    471523                $c = self::factory()->comment->create(
     
    481533
    482534        /**
    483535         * @ticket 35006
     536         *
     537         * @covers ::wp_new_comment_notify_postauthor
    484538         */
    485539        public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_trashed() {
    486540                $c = self::factory()->comment->create(
     
    496550
    497551        /**
    498552         * @ticket 43805
     553         *
     554         * @covers ::wp_new_comment_notify_postauthor
    499555         */
    500556        public function test_wp_new_comment_notify_postauthor_content_should_include_link_to_parent() {
    501557                $c1 = self::factory()->comment->create(
     
    520576
    521577        /**
    522578         * @ticket 43805
     579         *
     580         * @covers ::wp_new_comment_notify_moderator
    523581         */
    524582        public function test_wp_new_comment_notify_moderator_content_should_include_link_to_parent() {
    525583                $c1 = self::factory()->comment->create(
     
    556614
    557615        /**
    558616         * @ticket 12431
     617         *
     618         * @covers ::get_comment_meta
    559619         */
    560620        public function test_wp_new_comment_with_meta() {
    561621                $c = self::factory()->comment->create(
     
    573633
    574634        /**
    575635         * @ticket 8071
     636         *
     637         * @covers WP_Comment::get_children
    576638         */
    577639        public function test_wp_comment_get_children_should_fill_children() {
    578640                $c1 = self::factory()->comment->create(
     
    633695
    634696        /**
    635697         * @ticket 27571
     698         *
     699         * @covers ::get_comment
    636700         */
    637701        public function test_post_properties_should_be_lazyloaded() {
    638702                $c = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     
    684748
    685749        /**
    686750         * @ticket 761
     751         *
     752         * @covers ::wp_new_comment
    687753         */
    688754        public function test_wp_notify_moderator_filter_moderation_notify_option_true_filter_false() {
    689755                $comment_data = $this->setup_notify_comment();
     
    705771
    706772        /**
    707773         * @ticket 761
     774         *
     775         * @covers ::wp_new_comment
    708776         */
    709777        public function test_wp_notify_moderator_filter_moderation_notify_option_false_filter_true() {
    710778                $comment_data = $this->setup_notify_comment();
     
    726794
    727795        /**
    728796         * @ticket 761
     797         *
     798         * @covers ::wp_new_comment
    729799         */
    730800        public function test_wp_notify_post_author_filter_comments_notify_option_true_filter_false() {
    731801
     
    748818
    749819        /**
    750820         * @ticket 761
     821         *
     822         * @covers ::wp_new_comment
    751823         */
    752824        public function test_wp_notify_post_author_filter_comments_notify_option_false_filter_true() {
    753825                $comment_data = $this->setup_notify_comment();
     
    852924                return $email_sent_when_comment_approved || $email_sent_when_comment_added;
    853925        }
    854926
     927        /**
     928         *
     929         *
     930         * @covers ::_close_comments_for_old_post
     931         */
    855932        public function test_close_comments_for_old_post() {
    856933                update_option( 'close_comments_for_old_posts', true );
    857934                // Close comments more than one day old.
     
    867944                $this->assertTrue( $new_post_comment_status );
    868945        }
    869946
     947        /**
     948         *
     949         *
     950         * @covers ::_close_comments_for_old_post
     951         */
    870952        public function test_close_comments_for_old_post_undated_draft() {
    871953                $draft_id             = self::factory()->post->create(
    872954                        array(
     
    881963
    882964        /**
    883965         * @ticket 35276
     966         *
     967         * @covers ::wp_update_comment
    884968         */
    885969        public function test_wp_update_comment_author_id_and_agent() {
    886970
     
    9171001                $this->assertSame( 'SHIELD_AGENT', $updated->comment_agent );
    9181002        }
    9191003
     1004        /**
     1005         * @covers ::wp_get_comment_fields_max_lengths
     1006         */
    9201007        public function test_wp_get_comment_fields_max_lengths() {
    9211008                $expected = array(
    9221009                        'comment_author'       => 245,
     
    9371024         *
    9381025         * @group privacy
    9391026         * @ticket 43442
     1027         *
     1028         * @covers ::wp_comments_personal_data_eraser
    9401029         */
    9411030        public function test_wp_comments_personal_data_eraser() {
    9421031
     
    9941083         *
    9951084         * @group privacy
    9961085         * @ticket 43442
     1086         *
     1087         * @covers ::wp_comments_personal_data_eraser
    9971088         */
    9981089        public function test_wp_comments_personal_data_eraser_empty_first_page_output() {
    9991090
     
    10131104         *
    10141105         * @group privacy
    10151106         * @ticket 43442
     1107         *
     1108         * @covers ::wp_comments_personal_data_eraser
    10161109         */
    10171110        public function test_wp_comments_personal_data_eraser_non_empty_first_page_output() {
    10181111
     
    10451138         *
    10461139         * @group privacy
    10471140         * @ticket 43442
     1141         *
     1142         * @covers ::wp_comments_personal_data_eraser
    10481143         */
    10491144        public function test_wp_comments_personal_data_eraser_empty_second_page_output() {
    10501145
     
    10771172         *
    10781173         * @group privacy
    10791174         * @ticket 43442
     1175         *
     1176         * @covers ::wp_comments_personal_data_eraser
    10801177         */
    10811178        public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization() {
    10821179
     
    11141211         *
    11151212         * @group privacy
    11161213         * @ticket 43442
     1214         *
     1215         * @covers ::wp_comments_personal_data_eraser
    11171216         */
    11181217        public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization_with_custom_message() {
    11191218
     
    11791278                $this->assertSame( 'Bar', $comment->comment_author );
    11801279        }
    11811280
     1281        /**
     1282         *
     1283         *
     1284         * @covers ::wp_trash_comment
     1285         */
    11821286        public function test_trash_should_invalidate_comment_cache() {
    11831287                global $wpdb;
    11841288
     
    11931297                $this->assertSame( 'trash', $comment->comment_approved );
    11941298        }
    11951299
     1300        /**
     1301         *
     1302         *
     1303         * @covers ::wp_untrash_comment
     1304         */
    11961305        public function test_untrash_should_invalidate_comment_cache() {
    11971306                global $wpdb;
    11981307
     
    12091318                $this->assertSame( '1', $comment->comment_approved );
    12101319        }
    12111320
     1321        /**
     1322         *
     1323         *
     1324         * @covers ::wp_spam_comment
     1325         */
    12121326        public function test_spam_should_invalidate_comment_cache() {
    12131327                global $wpdb;
    12141328
     
    12231337                $this->assertSame( 'spam', $comment->comment_approved );
    12241338        }
    12251339
     1340        /**
     1341         *
     1342         *
     1343         * @covers ::wp_unspam_comment
     1344         */
    12261345        public function test_unspam_should_invalidate_comment_cache() {
    12271346                global $wpdb;
    12281347
     
    12441363         *
    12451364         * @group privacy
    12461365         * @ticket 43440
     1366         *
     1367         * @covers ::wp_comments_personal_data_exporter
    12471368         */
    12481369        public function test_wp_comments_personal_data_exporter() {
    12491370                $args = array(
     
    12901411         *
    12911412         * @group privacy
    12921413         * @ticket 43440
     1414         *
     1415         * @covers ::wp_comments_personal_data_exporter
    12931416         */
    12941417        public function test_wp_comments_personal_data_exporter_no_comments_found() {
    12951418
     
    13081431         *
    13091432         * @group privacy
    13101433         * @ticket 43440
     1434         *
     1435         * @covers ::wp_comments_personal_data_exporter
    13111436         */
    13121437        public function test_wp_comments_personal_data_exporter_empty_comment_prop() {
    13131438                $args = array(
     
    13391464         *
    13401465         * @group privacy
    13411466         * @ticket 43440
     1467         *
     1468         * @covers ::wp_comments_personal_data_exporter
    13421469         */
    13431470        public function test_wp_comments_personal_data_exporter_empty_second_page() {
    13441471                $args = array(
  • tests/phpunit/tests/compat.php

     
    3434
    3535        /**
    3636         * @dataProvider utf8_string_lengths
     37         *
     38         * @covers ::_mb_strlen
    3739         */
    3840        function test_mb_strlen( $string, $expected_character_length ) {
    3941                $this->assertEquals( $expected_character_length, _mb_strlen( $string, 'UTF-8' ) );
     
    4143
    4244        /**
    4345         * @dataProvider utf8_string_lengths
     46         *
     47         * @covers ::_mb_strlen
    4448         */
    4549        function test_mb_strlen_via_regex( $string, $expected_character_length ) {
    4650                _wp_can_use_pcre_u( false );
     
    5054
    5155        /**
    5256         * @dataProvider utf8_string_lengths
     57         *
     58         * @covers ::_mb_strlen
    5359         */
    5460        function test_8bit_mb_strlen( $string, $expected_character_length, $expected_byte_length ) {
    5561                $this->assertEquals( $expected_byte_length, _mb_strlen( $string, '8bit' ) );
     
    5763
    5864        /**
    5965         * @dataProvider utf8_substrings
     66         *
     67         * @covers ::_mb_substr
    6068         */
    6169        function test_mb_substr( $string, $start, $length, $expected_character_substring ) {
    6270                $this->assertEquals( $expected_character_substring, _mb_substr( $string, $start, $length, 'UTF-8' ) );
     
    6472
    6573        /**
    6674         * @dataProvider utf8_substrings
     75         *
     76         * @covers ::_mb_substr
    6777         */
    6878        function test_mb_substr_via_regex( $string, $start, $length, $expected_character_substring ) {
    6979                _wp_can_use_pcre_u( false );
     
    7383
    7484        /**
    7585         * @dataProvider utf8_substrings
     86         *
     87         * @covers ::_mb_substr
    7688         */
    7789        function test_8bit_mb_substr( $string, $start, $length, $expected_character_substring, $expected_byte_substring ) {
    7890                $this->assertEquals( $expected_byte_substring, _mb_substr( $string, $start, $length, '8bit' ) );
    7991        }
    8092
     93        /**
     94         *
     95         * @covers ::_mb_substr
     96         */
    8197        function test_mb_substr_phpcore() {
    8298                /* https://github.com/php/php-src/blob/php-5.6.8/ext/mbstring/tests/mb_substr_basic.phpt */
    8399                $string_ascii = 'ABCDEF';
     
    164180
    165181        }
    166182
     183        /**
     184         *
     185         * @covers ::_hash_hmac
     186         */
    167187        function test_hash_hmac_simple() {
    168188                $this->assertEquals( '140d1cb79fa12e2a31f32d35ad0a2723', _hash_hmac( 'md5', 'simple', 'key' ) );
    169189                $this->assertEquals( '993003b95758e0ac2eba451a4c5877eb1bb7b92a', _hash_hmac( 'sha1', 'simple', 'key' ) );
    170190        }
    171191
     192        /**
     193         *
     194         * @covers ::_hash_hmac
     195         */
    172196        function test_hash_hmac_padding() {
    173197                $this->assertEquals( '3c1399103807cf12ec38228614416a8c', _hash_hmac( 'md5', 'simple', '65 character key 65 character key 65 character key 65 character k' ) );
    174198                $this->assertEquals( '4428826d20003e309d6c2a6515891370daf184ea', _hash_hmac( 'sha1', 'simple', '65 character key 65 character key 65 character key 65 character k' ) );
    175199        }
    176200
     201        /**
     202         *
     203         * @covers ::_hash_hmac
     204         */
    177205        function test_hash_hmac_output() {
    178206                $this->assertEquals( array( 1 => '140d1cb79fa12e2a31f32d35ad0a2723' ), unpack( 'H32', _hash_hmac( 'md5', 'simple', 'key', true ) ) );
    179207                $this->assertEquals( array( 1 => '993003b95758e0ac2eba451a4c5877eb1bb7b92a' ), unpack( 'H40', _hash_hmac( 'sha1', 'simple', 'key', true ) ) );
     
    181209
    182210        /**
    183211         * @expectedException PHPUnit_Framework_Error_Deprecated
     212         *
     213         * @covers Services_JSON::encodeUnsafe
     214         * @covers Services_JSON::decode
    184215         */
    185216        function test_json_encode_decode() {
    186217                require_once ABSPATH . WPINC . '/class-json.php';
     
    194225         * Test that is_countable() is always available (either from PHP or WP).
    195226         *
    196227         * @ticket 43583
     228         *
     229         * @covers ::is_countable
    197230         */
    198231        function test_is_countable_availability() {
    199232                $this->assertTrue( function_exists( 'is_countable' ) );
     
    208241         *
    209242         * @param mixed $variable     Variable to check.
    210243         * @param bool  $is_countable The expected return value of PHP 7.3 is_countable() function.
     244         *
     245         * @covers ::is_countable
    211246         */
    212247        function test_is_countable_functionality( $variable, $is_countable ) {
    213248                $this->assertSame( is_countable( $variable ), $is_countable );
     
    243278         * Test is_countable() polyfill for ResourceBundle.
    244279         *
    245280         * @ticket 43583
     281         *
     282         * @covers ::is_countable
    246283         */
    247284        function test_is_countable_ResourceBundle() {
    248285                if ( ! class_exists( 'ResourceBundle' ) ) {
     
    256293         * Test is_countable() polyfill for SimpleXMLElement.
    257294         *
    258295         * @ticket 43583
     296         *
     297         * @covers ::is_countable
    259298         */
    260299        function test_is_countable_SimpleXMLElement() {
    261300                if ( ! class_exists( 'SimpleXMLElement' ) ) {
     
    269308         * Test that is_iterable() is always available (either from PHP or WP).
    270309         *
    271310         * @ticket 43619
     311         *
     312         * @covers ::is_iterable
    272313         */
    273314        function test_is_iterable_availability() {
    274315                $this->assertTrue( function_exists( 'is_iterable' ) );
     
    283324         *
    284325         * @param mixed $variable    Variable to check.
    285326         * @param bool  $is_iterable The expected return value of PHP 7.1 is_iterable() function.
     327         *
     328         * @covers ::is_iterable
    286329         */
    287330        function test_is_iterable_functionality( $variable, $is_iterable ) {
    288331                $this->assertSame( is_iterable( $variable ), $is_iterable );
  • tests/phpunit/tests/cron.php

     
    3030                parent::tearDown();
    3131        }
    3232
     33        /**
     34         *
     35         * @covers ::wp_get_schedule
     36         */
    3337        function test_wp_get_schedule_empty() {
    3438                // Nothing scheduled.
    3539                $hook = __FUNCTION__;
     
    3640                $this->assertFalse( wp_get_schedule( $hook ) );
    3741        }
    3842
     43        /**
     44         *
     45         * @covers ::wp_schedule_single_event
     46         */
    3947        function test_schedule_event_single() {
    4048                // Schedule an event and make sure it's returned by wp_next_scheduled().
    4149                $hook      = __FUNCTION__;
     
    5058
    5159        }
    5260
     61        /**
     62         *
     63         * @covers ::wp_schedule_single_event
     64         */
    5365        function test_schedule_event_single_args() {
    5466                // Schedule an event with arguments and make sure it's returned by wp_next_scheduled().
    5567                $hook      = 'event';
     
    6880                $this->assertEquals( '', wp_get_schedule( $hook, $args ) );
    6981        }
    7082
     83        /**
     84         *
     85         * @covers ::wp_schedule_event
     86         */
    7187        function test_schedule_event() {
    7288                // Schedule an event and make sure it's returned by wp_next_scheduled().
    7389                $hook      = __FUNCTION__;
     
    8298                $this->assertEquals( $recur, wp_get_schedule( $hook ) );
    8399        }
    84100
     101        /**
     102         *
     103         * @covers ::wp_schedule_event
     104         */
    85105        function test_schedule_event_args() {
    86106                // Schedule an event and make sure it's returned by wp_next_scheduled().
    87107                $hook      = 'event';
     
    101121
    102122        }
    103123
     124        /**
     125         *
     126         * @covers ::wp_unschedule_event
     127         */
    104128        function test_unschedule_event() {
    105129                // Schedule an event and make sure it's returned by wp_next_scheduled().
    106130                $hook      = __FUNCTION__;
     
    115139                $this->assertEquals( false, wp_next_scheduled( $hook ) );
    116140        }
    117141
     142        /**
     143         *
     144         * @covers ::wp_clear_scheduled_hook
     145         */
    118146        function test_clear_schedule() {
    119147                $hook = __FUNCTION__;
    120148                $args = array( 'arg1' );
     
    142170                $this->assertFalse( wp_next_scheduled( $hook, $args ) );
    143171        }
    144172
     173        /**
     174         *
     175         * @covers ::wp_clear_scheduled_hook
     176         */
    145177        function test_clear_undefined_schedule() {
    146178                $hook = __FUNCTION__;
    147179                $args = array( 'arg1' );
     
    154186                $this->assertSame( 0, $hook_unscheduled );
    155187        }
    156188
     189        /**
     190         *
     191         * @covers ::wp_clear_scheduled_hook
     192         */
    157193        function test_clear_schedule_multiple_args() {
    158194                $hook = __FUNCTION__;
    159195                $args = array( 'arg1', 'arg2' );
     
    182218
    183219        /**
    184220         * @ticket 10468
     221         *
     222         * @covers ::wp_clear_scheduled_hook
    185223         */
    186224        function test_clear_schedule_new_args() {
    187225                $hook       = __FUNCTION__;
     
    220258
    221259        /**
    222260         * @ticket 18997
     261         *
     262         * @covers ::wp_clear_scheduled_hook
    223263         */
    224264        function test_unschedule_hook() {
    225265                $hook = __FUNCTION__;
     
    240280                $this->assertSame( 4, $unschedule_hook );
    241281                $this->assertFalse( wp_next_scheduled( $hook ) );
    242282        }
    243 
     283        /**
     284         *
     285         * @covers ::wp_clear_scheduled_hook
     286         */
    244287        function test_unschedule_undefined_hook() {
    245288                $hook           = __FUNCTION__;
    246289                $unrelated_hook = __FUNCTION__ . '_two';
     
    261304
    262305        /**
    263306         * @ticket 6966
     307         *
     308         * @covers ::wp_schedule_single_event
    264309         */
    265310        function test_duplicate_event() {
    266311                // Duplicate events close together should be skipped.
     
    280325
    281326        /**
    282327         * @ticket 6966
     328         *
     329         * @covers ::wp_schedule_single_event
    283330         */
    284331        function test_not_duplicate_event() {
    285332                // Duplicate events far apart should work normally.
     
    300347                $this->assertEquals( $ts1, wp_next_scheduled( $hook, $args ) );
    301348        }
    302349
     350        /**
     351         *
     352         * @covers ::wp_schedule_single_event
     353         */
    303354        function test_not_duplicate_event_reversed() {
    304355                // Duplicate events far apart should work normally regardless of order.
    305356                $hook = __FUNCTION__;
     
    324375         * modification of the cron_array_option.
    325376         *
    326377         * @ticket 32656
     378         *
     379         * @covers ::wp_schedule_single_event
    327380         */
    328381        function test_pre_schedule_event_filter() {
    329382                $hook = __FUNCTION__;
     
    376429         * modification of the cron_array_option.
    377430         *
    378431         * @ticket 32656
     432         *
     433         * @covers ::wp_schedule_event
    379434         */
    380435        function test_pre_reschedule_event_filter() {
    381436                $hook = __FUNCTION__;
     
    400455         * modification of the cron_array_option.
    401456         *
    402457         * @ticket 32656
     458         *
     459         * @covers ::wp_unschedule_event
    403460         */
    404461        function test_pre_unschedule_event_filter() {
    405462                $hook = __FUNCTION__;
     
    424481         * modification of the cron_array_option.
    425482         *
    426483         * @ticket 32656
     484         *
     485         * @covers ::wp_clear_scheduled_hook
    427486         */
    428487        function test_pre_clear_scheduled_hook_filters() {
    429488                $hook = __FUNCTION__;
     
    455514         * return a filtered value as expected.
    456515         *
    457516         * @ticket 32656
     517         *
     518         * @covers ::wp_get_scheduled_event
    458519         */
    459520        function test_pre_scheduled_event_hooks() {
    460521                add_filter( 'pre_get_scheduled_event', array( $this, 'filter_pre_scheduled_event_hooks' ) );
     
    489550         * When a timestamp is specified, a particular event should be returned.
    490551         *
    491552         * @ticket 45976.
     553         *
     554         * @covers ::wp_get_scheduled_event
    492555         */
    493556        function test_get_scheduled_event_singles() {
    494557                $hook    = __FUNCTION__;
     
    532595         * When a timestamp is specified, a particular event should be returned.
    533596         *
    534597         * @ticket 45976.
     598         *
     599         * @covers ::wp_get_scheduled_event
    535600         */
    536601        function test_get_scheduled_event_recurring() {
    537602                $hook     = __FUNCTION__;
     
    576641         * Ensure wp_get_scheduled_event() returns false when expected.
    577642         *
    578643         * @ticket 45976.
     644         *
     645         * @covers ::wp_get_scheduled_event
    579646         */
    580647        function test_get_scheduled_event_false() {
    581648                $hook = __FUNCTION__;
     
    601668         * Ensure any past event counts as a duplicate.
    602669         *
    603670         * @ticket 44818
     671         *
     672         * @covers ::wp_get_scheduled_event
    604673         */
    605674        function test_duplicate_past_event() {
    606675                $hook = __FUNCTION__;
     
    623692         * Ensure any near future event counts as a duplicate.
    624693         *
    625694         * @ticket 44818
     695         *
     696         * @covers ::wp_get_scheduled_event
    626697         */
    627698        function test_duplicate_near_future_event() {
    628699                $hook = __FUNCTION__;
     
    645716         * Duplicate future events are disallowed.
    646717         *
    647718         * @ticket 44818
     719         *
     720         * @covers ::wp_get_scheduled_event
    648721         */
    649722        function test_duplicate_future_event() {
    650723                $hook = __FUNCTION__;
     
    665738         * Future events are allowed.
    666739         *
    667740         * @ticket 44818
     741         *
     742         * @covers ::wp_get_scheduled_event
    668743         */
    669744        function test_not_duplicate_future_event() {
    670745                $hook = __FUNCTION__;
  • tests/phpunit/tests/db.php

     
    5858         * Test that WPDB will reconnect when the DB link dies
    5959         *
    6060         * @ticket 5932
     61         *
     62         * @covers wpdb::db_connect
    6163         */
    6264        public function test_db_reconnect() {
    6365                global $wpdb;
     
    8284         * @global mixed $wpdb
    8385         *
    8486         * @ticket 19861
     87         *
     88         * @covers wpdb::update
    8589         */
    8690        public function test_locale_floats() {
    8791                global $wpdb;
     
    128132
    129133        /**
    130134         * @ticket 10041
     135         *
     136         * @covers wpdb::esc_like
    131137         */
    132138        function test_esc_like() {
    133139                global $wpdb;
     
    164170         * @param $data string The haystack, raw.
    165171         * @param $like string The like phrase, raw.
    166172         * @param $result string The expected comparison result; '1' = true, '0' = false
     173         *
     174         * @covers wpdb::esc_like
    167175         */
    168176        function test_like_query( $data, $like, $result ) {
    169177                global $wpdb;
     
    227235
    228236        /**
    229237         * @ticket 18510
     238         *
     239         * @coversNothing
    230240         */
    231241        function test_wpdb_supposedly_protected_properties() {
    232242                global $wpdb;
     
    243253
    244254        /**
    245255         * @ticket 21212
     256         *
     257         * @coversNothing
    246258         */
    247259        function test_wpdb_actually_protected_properties() {
    248260                global $wpdb;
     
    274286         * Test that an escaped %%f is not altered
    275287         *
    276288         * @ticket 19861
     289         *
     290         * @covers wpdb::placeholder_escape
     291         * @covers wpdb::remove_placeholder_escape
    277292         */
    278293        public function test_double_escaped_placeholders() {
    279294                global $wpdb;
     
    289304         * Test that SQL modes are set correctly
    290305         *
    291306         * @ticket 26847
     307         *
     308         * @covers wpdb::set_sql_mode
    292309         */
    293310        function test_set_sql_mode() {
    294311                global $wpdb;
     
    309326         * Test that incompatible SQL modes are blocked
    310327         *
    311328         * @ticket 26847
     329         *
     330         * @covers wpdb::set_sql_mode
    312331         */
    313332        function test_set_incompatible_sql_mode() {
    314333                global $wpdb;
     
    327346         * Test that incompatible SQL modes can be changed
    328347         *
    329348         * @ticket 26847
     349         *
     350         * @covers wpdb::set_sql_mode
    330351         */
    331352        function test_set_allowed_incompatible_sql_mode() {
    332353                global $wpdb;
     
    360381        /**
    361382         * @ticket 25604
    362383         * @expectedIncorrectUsage wpdb::prepare
     384         *
     385         * @covers wpdb::prepare
    363386         */
    364387        function test_prepare_without_arguments() {
    365388                global $wpdb;
     
    370393                $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0", $prepared );
    371394        }
    372395
     396        /**
     397         *
     398         * @covers wpdb::prepare
     399         */
    373400        function test_prepare_sprintf() {
    374401                global $wpdb;
    375402
     
    379406
    380407        /**
    381408         * @expectedIncorrectUsage wpdb::prepare
     409         *
     410         * @covers wpdb::prepare
    382411         */
    383412        function test_prepare_sprintf_invalid_args() {
    384413                global $wpdb;
     
    392421                $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared );
    393422        }
    394423
     424        /**
     425         *
     426         * @covers wpdb::prepare
     427         */
    395428        function test_prepare_vsprintf() {
    396429                global $wpdb;
    397430
     
    401434
    402435        /**
    403436         * @expectedIncorrectUsage wpdb::prepare
     437         *
     438         * @covers wpdb::prepare
    404439         */
    405440        function test_prepare_vsprintf_invalid_args() {
    406441                global $wpdb;
     
    418453         * @ticket 42040
    419454         * @dataProvider data_prepare_incorrect_arg_count
    420455         * @expectedIncorrectUsage wpdb::prepare
     456         *
     457         * @covers wpdb::prepare
    421458         */
    422459        public function test_prepare_incorrect_arg_count( $query, $args, $expected ) {
    423460                global $wpdb;
     
    479516                );
    480517        }
    481518
     519        /**
     520         *
     521         * @covers wpdb::db_version
     522         */
    482523        function test_db_version() {
    483524                global $wpdb;
    484525
    485526                $this->assertTrue( version_compare( $wpdb->db_version(), '5.0', '>=' ) );
    486527        }
    487 
     528        /**
     529         *
     530         * @covers wpdb::get_caller
     531         */
    488532        function test_get_caller() {
    489533                global $wpdb;
    490534                $str    = $wpdb->get_caller();
     
    493537                $this->assertEquals( $called, end( $calls ) );
    494538        }
    495539
     540        /**
     541         *
     542         * @covers wpdb::has_cap
     543         */
    496544        function test_has_cap() {
    497545                global $wpdb;
    498546                $this->assertTrue( $wpdb->has_cap( 'collation' ) );
     
    513561
    514562        /**
    515563         * @expectedDeprecated supports_collation
     564         *
     565         * @covers wpdb::supports_collation
    516566         */
    517567        function test_supports_collation() {
    518568                global $wpdb;
     
    519569                $this->assertTrue( $wpdb->supports_collation() );
    520570        }
    521571
     572        /**
     573         *
     574         * @covers wpdb::check_database_version
     575         */
    522576        function test_check_database_version() {
    523577                global $wpdb;
    524578                $this->assertEmpty( $wpdb->check_database_version() );
     
    526580
    527581        /**
    528582         * @expectedException WPDieException
     583         *
     584         * @covers wpdb::bail
    529585         */
    530586        function test_bail() {
    531587                global $wpdb;
    532588                $wpdb->bail( 'Database is dead.' );
    533589        }
    534 
     590        /**
     591         *
     592         * @covers wpdb::timer_start
     593         * @covers wpdb::timer_stop
     594         */
    535595        function test_timers() {
    536596                global $wpdb;
    537597
     
    542602                $this->assertNotEquals( $wpdb->time_start, $stop );
    543603                $this->assertGreaterThan( $stop, $wpdb->time_start );
    544604        }
    545 
     605        /**
     606         *
     607         * @covers wpdb::get_col_info
     608         */
    546609        function test_get_col_info() {
    547610                global $wpdb;
    548611
     
    552615                $this->assertEquals( array( $wpdb->users ), $wpdb->get_col_info( 'table' ) );
    553616                $this->assertEquals( $wpdb->users, $wpdb->get_col_info( 'table', 0 ) );
    554617        }
    555 
     618        /**
     619         *
     620         * @covers wpdb::query
     621         * @covers wpdb::delete
     622         */
    556623        function test_query_and_delete() {
    557624                global $wpdb;
    558625                $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" );
     
    561628                $d_rows = $wpdb->delete( $wpdb->users, array( 'ID' => $wpdb->insert_id ) );
    562629                $this->assertEquals( 1, $d_rows );
    563630        }
    564 
     631        /**
     632         *
     633         * @covers wpdb::query
     634         * @covers wpdb::get_row
     635         */
    565636        function test_get_row() {
    566637                global $wpdb;
    567638                $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" );
     
    584655         * @dataProvider data_test_get_col
    585656         *
    586657         * @ticket 45299
     658         *
     659         * @covers wpdb::get_col
    587660         */
    588661        function test_get_col( $query, $expected, $last_result, $column ) {
    589662                global $wpdb;
     
    664737                );
    665738        }
    666739
     740        /**
     741         *
     742         * @covers wpdb::replace
     743         */
    667744        function test_replace() {
    668745                global $wpdb;
    669746                $rows1 = $wpdb->insert( $wpdb->users, array( 'display_name' => 'Walter Sobchak' ) );
     
    691768         * wpdb::update() requires a WHERE condition.
    692769         *
    693770         * @ticket 26106
     771         *
     772         * @covers wpdb::update
    694773         */
    695774        function test_empty_where_on_update() {
    696775                global $wpdb;
     
    713792         * mysqli_ incorrect flush and further sync issues.
    714793         *
    715794         * @ticket 28155
     795         *
     796         * @coversNothing
    716797         */
    717798        function test_mysqli_flush_sync() {
    718799                global $wpdb;
     
    873954        /**
    874955         * @dataProvider data_get_table_from_query
    875956         * @ticket 21212
     957         *
     958         * @covers wpdb::get_table_from_query
    876959         */
    877960        function test_get_table_from_query( $query, $table ) {
    878961                $this->assertEquals( $table, self::$_wpdb->get_table_from_query( $query ) );
     
    888971        /**
    889972         * @dataProvider data_get_table_from_query_false
    890973         * @ticket 21212
     974         *
     975         * @covers wpdb::get_table_from_query
    891976         */
    892977        function test_get_table_from_query_false( $query ) {
    893978                $this->assertFalse( self::$_wpdb->get_table_from_query( $query ) );
     
    9151000        /**
    9161001         * @dataProvider data_get_escaped_table_from_show_query
    9171002         * @ticket 38751
     1003         *
     1004         * @covers wpdb::get_table_from_query
    9181005         */
    9191006        function test_get_escaped_table_from_show_query( $query, $table ) {
    9201007                $this->assertEquals( $table, self::$_wpdb->get_table_from_query( $query ) );
     
    10301117        /**
    10311118         * @dataProvider data_process_field_formats
    10321119         * @ticket 21212
     1120         *
     1121         * @covers wpdb::process_field_formats
    10331122         */
    10341123        function test_process_field_formats( $data, $format, $expected, $message ) {
    10351124                $actual = self::$_wpdb->process_field_formats( $data, $format );
     
    10381127
    10391128        /**
    10401129         * @ticket 21212
     1130         *
     1131         * @covers wpdb::process_fields
    10411132         */
    10421133        function test_process_fields() {
    10431134                global $wpdb;
     
    10681159        /**
    10691160         * @ticket 21212
    10701161         * @depends test_process_fields
     1162         *
     1163         * @covers wpdb::process_fields
    10711164         */
    10721165        function test_process_fields_on_nonexistent_table( $data ) {
    10731166                self::$_wpdb->suppress_errors( true );
     
    10781171
    10791172        /**
    10801173         * @ticket 21212
     1174         *
     1175         * @covers wpdb::get_table_charset
    10811176         */
    10821177        function test_pre_get_table_charset_filter() {
    10831178                add_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10, 2 );
     
    10921187
    10931188        /**
    10941189         * @ticket 21212
     1190         *
     1191         * @covers wpdb::get_col_charset
    10951192         */
    10961193        function test_pre_get_col_charset_filter() {
    10971194                add_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10, 3 );
     
    11061203
    11071204        /**
    11081205         * @ticket 15158
     1206         *
     1207         * @covers wpdb::insert
    11091208         */
    11101209        function test_null_insert() {
    11111210                global $wpdb;
     
    11281227
    11291228        /**
    11301229         * @ticket 15158
     1230         *
     1231         * @covers wpdb::insert
    11311232         */
    11321233        function test_null_update_value() {
    11331234                global $wpdb;
     
    11661267
    11671268        /**
    11681269         * @ticket 15158
     1270         *
     1271         * @covers wpdb::update
    11691272         */
    11701273        function test_null_update_where() {
    11711274                global $wpdb;
     
    12041307
    12051308        /**
    12061309         * @ticket 15158
     1310         *
     1311         * @covers wpdb::delete
    12071312         */
    12081313        function test_null_delete() {
    12091314                global $wpdb;
     
    12401345
    12411346        /**
    12421347         * @ticket 34903
     1348         *
     1349         * @covers wpdb::close
    12431350         */
    12441351        function test_close() {
    12451352                global $wpdb;
     
    12591366
    12601367        /**
    12611368         * @ticket 36917
     1369         *
     1370         * @covers wpdb::determine_charset
    12621371         */
    12631372        function test_charset_not_determined_when_disconnected() {
    12641373                global $wpdb;
     
    12771386
    12781387        /**
    12791388         * @ticket 36917
     1389         *
     1390         * @covers wpdb::determine_charset
    12801391         */
    12811392        function test_charset_switched_to_utf8mb4() {
    12821393                global $wpdb;
     
    12961407        /**
    12971408         * @ticket 32105
    12981409         * @ticket 36917
     1410         *
     1411         * @covers wpdb::determine_charset
    12991412         */
    13001413        function test_collate_switched_to_utf8mb4_520() {
    13011414                global $wpdb;
     
    13151428        /**
    13161429         * @ticket 32405
    13171430         * @ticket 36917
     1431         *
     1432         * @covers wpdb::determine_charset
    13181433         */
    13191434        function test_non_unicode_collations() {
    13201435                global $wpdb;
     
    13331448
    13341449        /**
    13351450         * @ticket 37982
     1451         *
     1452         * @covers wpdb::determine_charset
    13361453         */
    13371454        function test_charset_switched_to_utf8() {
    13381455                global $wpdb;
     
    13521469
    13531470        /**
    13541471         * @dataProvider data_prepare_with_placeholders
     1472         *
     1473         * @covers wpdb::prepare
    13551474         */
    13561475        function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) {
    13571476                global $wpdb;
     
    13711490
    13721491        /**
    13731492         * @dataProvider data_prepare_with_placeholders
     1493         *
     1494         * @covers wpdb::prepare
    13741495         */
    13751496        function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) {
    13761497                global $wpdb;
     
    15651686
    15661687        /**
    15671688         * @dataProvider data_escape_and_prepare
     1689         *
     1690         * @covers ::esc_sql
     1691        /**
     1692         * @coversNothing
    15681693         */
     1694         */
    15691695        function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) {
    15701696                global $wpdb;
    15711697
     
    16121738
    16131739        /**
    16141740         * @expectedIncorrectUsage wpdb::prepare
     1741         *
     1742         * @covers wpdb::prepare
    16151743         */
    16161744        function test_double_prepare() {
    16171745                global $wpdb;
     
    16231751                $this->assertNull( $query );
    16241752        }
    16251753
     1754        /**
     1755         *
     1756         * @covers wpdb::prepare
     1757         */
    16261758        function test_prepare_numeric_placeholders_float_args() {
    16271759                global $wpdb;
    16281760
     
    16381770                $this->assertContains( ' second=2.2', $actual );
    16391771        }
    16401772
     1773        /**
     1774         *
     1775         * @covers wpdb::prepare
     1776         */
    16411777        function test_prepare_numeric_placeholders_float_array() {
    16421778                global $wpdb;
    16431779
     
    16521788                $this->assertContains( ' second=2.2', $actual );
    16531789        }
    16541790
     1791        /**
     1792         *
     1793         * @covers wpdb::prepare
     1794         */
    16551795        function test_query_unescapes_placeholders() {
    16561796                global $wpdb;
    16571797
     
    16711811                $this->assertEquals( $value, $actual );
    16721812        }
    16731813
     1814        /**
     1815         *
     1816         * @covers wpdb::placeholder_escape
     1817         */
    16741818        function test_esc_sql_with_unsupported_placeholder_type() {
    16751819                global $wpdb;
    16761820
     
    16841828        /**
    16851829         * @dataProvider parse_db_host_data_provider
    16861830         * @ticket 41722
     1831         *
     1832         * @covers wpdb::parse_db_host
    16871833         */
    16881834        public function test_parse_db_host( $host_string, $expect_bail, $host, $port, $socket, $is_ipv6 ) {
    16891835                global $wpdb;
  • tests/phpunit/tests/dbdelta.php

     
    9696
    9797        /**
    9898         * Test table creation.
     99         *
     100         * @covers ::dbDelta
    99101         */
    100102        public function test_creating_a_table() {
    101103
     
    133135
    134136        /**
    135137         * Test that it does nothing for an existing table.
     138         *
     139         * @covers ::dbDelta
    136140         */
    137141        public function test_existing_table() {
    138142
     
    155159
    156160        /**
    157161         * Test the column type is updated.
     162         *
     163         * @covers ::dbDelta
    158164         */
    159165        public function test_column_type_change() {
    160166
     
    184190
    185191        /**
    186192         * Test new column added.
     193         *
     194         * @covers ::dbDelta
    187195         */
    188196        public function test_column_added() {
    189197
     
    218226         * Test that it does nothing when a column is removed.
    219227         *
    220228         * @ticket 26801
     229         *
     230         * @covers ::dbDelta
    221231         */
    222232        public function test_columns_arent_removed() {
    223233
     
    242252
    243253        /**
    244254         * Test that nothing happens with $execute is false.
     255         *
     256         * @covers ::dbDelta
    245257         */
    246258        public function test_no_execution() {
    247259
     
    275287
    276288        /**
    277289         * Test inserting into the database
     290         *
     291         * @covers ::dbDelta
    278292         */
    279293        public function test_insert_into_table() {
    280294                global $wpdb;
     
    296310         * Test that FULLTEXT indexes are detected.
    297311         *
    298312         * @ticket 14445
     313         *
     314         * @covers ::dbDelta
    299315         */
    300316        public function test_fulltext_index() {
    301317                global $wpdb;
     
    401417
    402418        /**
    403419         * @ticket 31869
     420         *
     421         * @covers ::dbDelta
    404422         */
    405423        function test_truncated_index() {
    406424                global $wpdb;
     
    441459
    442460        /**
    443461         * @ticket 36748
     462         *
     463         * @covers ::dbDelta
    444464         */
    445465        function test_dont_downsize_text_fields() {
    446466                global $wpdb;
     
    466486
    467487        /**
    468488         * @ticket 36748
     489         *
     490         * @covers ::dbDelta
    469491         */
    470492        function test_dont_downsize_blob_fields() {
    471493                global $wpdb;
     
    491513
    492514        /**
    493515         * @ticket 36748
     516         *
     517         * @covers ::dbDelta
    494518         */
    495519        function test_upsize_text_fields() {
    496520                global $wpdb;
     
    522546
    523547        /**
    524548         * @ticket 36748
     549         *
     550         * @covers ::dbDelta
    525551         */
    526552        function test_upsize_blob_fields() {
    527553                global $wpdb;
     
    553579
    554580        /**
    555581         * @ticket 20263
     582         *
     583         * @covers ::dbDelta
    556584         */
    557585        function test_query_with_backticks_does_not_throw_an_undefined_index_warning() {
    558586                global $wpdb;
     
    578606
    579607        /**
    580608         * @ticket 36948
     609         *
     610         * @covers ::dbDelta
    581611         */
    582612        function test_spatial_indices() {
    583613                global $wpdb;
     
    639669
    640670        /**
    641671         * @ticket 20263
     672         *
     673         * @covers ::dbDelta
    642674         */
    643675        function test_query_with_backticks_does_not_cause_a_query_to_alter_all_columns_and_indices_to_run_even_if_none_have_changed() {
    644676                global $wpdb;
     
    668700
    669701        /**
    670702         * @ticket 20263
     703         *
     704         * @covers ::dbDelta
    671705         */
    672706        function test_index_with_a_reserved_keyword_can_be_created() {
    673707                global $wpdb;
     
    704738
    705739        /**
    706740         * @ticket 20263
     741         *
     742         * @covers ::dbDelta
    707743         */
    708744        function test_wp_get_db_schema_does_no_alter_queries_on_existing_install() {
    709745                $updates = dbDelta( wp_get_db_schema() );
     
    713749
    714750        /**
    715751         * @ticket 20263
     752         *
     753         * @covers ::dbDelta
    716754         */
    717755        function test_key_and_index_and_fulltext_key_and_fulltext_index_and_unique_key_and_unique_index_indicies() {
    718756                global $wpdb;
     
    751789
    752790        /**
    753791         * @ticket 20263
     792         *
     793         * @covers ::dbDelta
    754794         */
    755795        function test_index_and_key_are_synonyms_and_do_not_recreate_indices() {
    756796                global $wpdb;
     
    775815
    776816        /**
    777817         * @ticket 20263
     818         *
     819         * @covers ::dbDelta
    778820         */
    779821        function test_indices_with_prefix_limits_are_created_and_do_not_recreate_indices() {
    780822                global $wpdb;
     
    809851
    810852        /**
    811853         * @ticket 34959
     854         *
     855         * @covers ::dbDelta
    812856         */
    813857        function test_index_col_names_with_order_do_not_recreate_indices() {
    814858                global $wpdb;
     
    833877
    834878        /**
    835879         * @ticket 34873
     880         *
     881         * @covers ::dbDelta
    836882         */
    837883        function test_primary_key_with_single_space_does_not_recreate_index() {
    838884                global $wpdb;
     
    857903
    858904        /**
    859905         * @ticket 34869
     906         *
     907         * @covers ::dbDelta
    860908         */
    861909        function test_index_definitions_with_spaces_do_not_recreate_indices() {
    862910                global $wpdb;
     
    881929
    882930        /**
    883931         * @ticket 34871
     932         *
     933         * @covers ::dbDelta
    884934         */
    885935        function test_index_types_are_not_case_sensitive_and_do_not_recreate_indices() {
    886936                global $wpdb;
     
    905955
    906956        /**
    907957         * @ticket 34874
     958         *
     959         * @covers ::dbDelta
    908960         */
    909961        function test_key_names_are_not_case_sensitive_and_do_not_recreate_indices() {
    910962                global $wpdb;
     
    930982
    931983        /**
    932984         * @ticket 34870
     985         *
     986         * @covers ::dbDelta
    933987         */
    934988        function test_unchanged_key_lengths_do_not_recreate_index() {
    935989                global $wpdb;
     
    9551009
    9561010        /**
    9571011         * @ticket 34870
     1012         *
     1013         * @covers ::dbDelta
    9581014         */
    9591015        function test_changed_key_lengths_do_not_recreate_index() {
    9601016                global $wpdb;
     
    10391095
    10401096        /**
    10411097         * @ticket 31679
     1098         *
     1099         * @covers ::dbDelta
    10421100         */
    10431101        function test_column_type_change_with_hyphens_in_name() {
    10441102                global $wpdb;
  • tests/phpunit/tests/dependencies.php

     
    44 * @group scripts
    55 */
    66class Tests_Dependencies extends WP_UnitTestCase {
     7
     8        /**
     9         *
     10         * @covers WP_Dependencies::add
     11         */
    712        function test_add() {
    813                $dep = new WP_Dependencies;
    914
     
    1621                // Cannot reuse names.
    1722                $this->assertFalse( $dep->add( 'one', '' ) );
    1823        }
    19 
     24        /**
     25         *
     26         * @covers WP_Dependencies::remove
     27         */
    2028        function test_remove() {
    2129                $dep = new WP_Dependencies;
    2230
     
    2937                $this->assertInstanceOf( '_WP_Dependency', $dep->query( 'two' ) );
    3038
    3139        }
    32 
     40        /**
     41         *
     42         * @covers WP_Dependencies::enqueue
     43         */
    3344        function test_enqueue() {
    3445                $dep = new WP_Dependencies;
    3546
     
    4556                $this->assertTrue( $dep->query( 'one', 'queue' ) );
    4657                $this->assertTrue( $dep->query( 'two', 'queue' ) );
    4758        }
    48 
     59        /**
     60         *
     61         * @covers WP_Dependencies::dequeue
     62         */
    4963        function test_dequeue() {
    5064                $dep = new WP_Dependencies;
    5165
     
    6579                $this->assertFalse( $dep->query( 'one', 'queue' ) );
    6680                $this->assertFalse( $dep->query( 'two', 'queue' ) );
    6781        }
    68 
     82        /**
     83         *
     84         * @covers WP_Dependencies::enqueue
     85         */
    6986        function test_enqueue_args() {
    7087                $dep = new WP_Dependencies;
    7188
     
    83100                $this->assertTrue( $dep->query( 'two', 'queue' ) );
    84101                $this->assertEquals( 'arg', $dep->args['two'] );
    85102        }
    86 
     103        /**
     104         *
     105         * @covers WP_Dependencies::dequeue
     106         */
    87107        function test_dequeue_args() {
    88108                $dep = new WP_Dependencies;
    89109
     
    110130
    111131        /**
    112132         * @ticket 21741
     133         *
     134         * @covers WP_Dependencies::query
    113135         */
    114136        function test_query_and_registered_enqueued() {
    115137                $dep = new WP_Dependencies;
  • tests/phpunit/tests/dependencies/scripts.php

     
    10451045         * Testing `wp_enqueue_code_editor` with file path.
    10461046         *
    10471047         * @ticket 41871
    1048          * @covers ::wp_enqueue_code_editor()
     1048         * @covers ::wp_enqueue_code_editor
    10491049         */
    10501050        public function test_wp_enqueue_code_editor_when_php_file_will_be_passed() {
    10511051                $real_file              = WP_PLUGIN_DIR . '/hello.php';
     
    11321132         * Testing `wp_enqueue_code_editor` with `compact`.
    11331133         *
    11341134         * @ticket 41871
    1135          * @covers ::wp_enqueue_code_editor()
     1135         * @covers ::wp_enqueue_code_editor
    11361136         */
    11371137        public function test_wp_enqueue_code_editor_when_generated_array_by_compact_will_be_passed() {
    11381138                $file                   = '';
     
    12151215         * Testing `wp_enqueue_code_editor` with `array_merge`.
    12161216         *
    12171217         * @ticket 41871
    1218          * @covers ::wp_enqueue_code_editor()
     1218         * @covers ::wp_enqueue_code_editor
    12191219         */
    12201220        public function test_wp_enqueue_code_editor_when_generated_array_by_array_merge_will_be_passed() {
    12211221                $wp_enqueue_code_editor = wp_enqueue_code_editor(
     
    13121312         * Testing `wp_enqueue_code_editor` with `array`.
    13131313         *
    13141314         * @ticket 41871
    1315          * @covers ::wp_enqueue_code_editor()
     1315         * @covers ::wp_enqueue_code_editor
    13161316         */
    13171317        public function test_wp_enqueue_code_editor_when_simple_array_will_be_passed() {
    13181318                $wp_enqueue_code_editor = wp_enqueue_code_editor(
  • tests/phpunit/tests/file.php

     
    1616        /**
    1717         * @group plugins
    1818         * @group themes
     19         *
     20         * @cover ::get_file_data
    1921         */
    2022        function test_get_file_data() {
    2123                $theme_headers = array(
     
    4648        /**
    4749         * @group plugins
    4850         * @group themes
     51         *
     52         * @cover ::get_file_data
    4953         */
    5054        function test_get_file_data_cr_line_endings() {
    5155                $headers  = array(
     
    8892                return $result;
    8993        }
    9094
     95        /**
     96         *
     97         * @cover ::wp_unique_filename
     98         */
    9199        function test_unique_filename_is_valid() {
    92100                // Make sure it produces a valid, writable, unique filename.
    93101                $filename = wp_unique_filename( $this->dir, __FUNCTION__ . '.txt' );
     
    97105                unlink( $this->dir . DIRECTORY_SEPARATOR . $filename );
    98106        }
    99107
     108        /**
     109         *
     110         * @cover ::wp_unique_filename
     111         */
    100112        function test_unique_filename_is_unique() {
    101113                // Make sure it produces two unique filenames.
    102114                $name = __FUNCTION__;
     
    113125                unlink( $this->dir . DIRECTORY_SEPARATOR . $filename2 );
    114126        }
    115127
     128        /**
     129         *
     130         * @cover ::wp_unique_filename
     131         */
    116132        function test_unique_filename_is_sanitized() {
    117133                $name     = __FUNCTION__;
    118134                $filename = wp_unique_filename( $this->dir, $name . $this->badchars . '.txt' );
     
    125141                unlink( $this->dir . DIRECTORY_SEPARATOR . $filename );
    126142        }
    127143
     144        /**
     145         *
     146         * @cover ::wp_unique_filename
     147         */
    128148        function test_unique_filename_with_slashes() {
    129149                $name = __FUNCTION__;
    130150                // "foo/foo.txt"
     
    138158                unlink( $this->dir . DIRECTORY_SEPARATOR . $filename );
    139159        }
    140160
     161        /**
     162         *
     163         * @cover ::wp_unique_filename
     164         */
    141165        function test_unique_filename_multiple_ext() {
    142166                $name     = __FUNCTION__;
    143167                $filename = wp_unique_filename( $this->dir, $name . '.php.txt' );
     
    150174                unlink( $this->dir . DIRECTORY_SEPARATOR . $filename );
    151175        }
    152176
     177        /**
     178         *
     179         * @cover ::wp_unique_filename
     180         */
    153181        function test_unique_filename_no_ext() {
    154182                $name     = __FUNCTION__;
    155183                $filename = wp_unique_filename( $this->dir, $name );
     
    163191
    164192        /**
    165193         * @dataProvider data_wp_tempnam_filenames
     194         *
     195         * @cover ::wp_tempnam
    166196         */
    167197        function test_wp_tempnam( $case ) {
    168198                $file = wp_tempnam( $case );
     
    183213
    184214        /**
    185215         * @ticket 47186
     216         *
     217         * @cover ::verify_file_signature
    186218         */
    187219        function test_file_signature_functions_as_expected() {
    188220                $file = wp_tempnam();
     
    216248
    217249        /**
    218250         * @ticket 47186
     251         *
     252         * @cover ::verify_file_signature
    219253         */
    220254        function test_file_signature_expected_failure() {
    221255                $file = wp_tempnam();
  • tests/phpunit/tests/filters.php

     
    77 */
    88class Tests_Filters extends WP_UnitTestCase {
    99
     10        /**
     11         * @covers ::add_filter
     12         */
    1013        function test_simple_filter() {
    1114                $a   = new MockAction();
    1215                $tag = __FUNCTION__;
     
    2528                $this->assertEquals( array( $val ), $args );
    2629        }
    2730
     31        /**
     32         * @covers ::remove_filter
     33         */
    2834        function test_remove_filter() {
    2935                $a   = new MockAction();
    3036                $tag = __FUNCTION__;
     
    4551
    4652        }
    4753
     54        /**
     55         * @covers ::has_filter
     56         */
    4857        function test_has_filter() {
    4958                        $tag  = __FUNCTION__;
    5059                        $func = __FUNCTION__ . '_func';
     
    5968                        $this->assertFalse( has_filter( $tag ) );
    6069        }
    6170
    62         // One tag with multiple filters.
     71        /**
     72         * One tag with multiple filters.
     73         *
     74         * @covers ::add_filter
     75         */
    6376        function test_multiple_filters() {
    6477                $a1  = new MockAction();
    6578                $a2  = new MockAction();
     
    7790                $this->assertEquals( 1, $a2->get_call_count() );
    7891        }
    7992
     93        /**
     94         * One tag with multiple filters.
     95         *
     96         * @covers ::add_filter
     97         */
    8098        function test_filter_args_1() {
    8199                $a    = new MockAction();
    82100                $tag  = __FUNCTION__;
     
    92110                $this->assertEquals( array( $val, $arg1 ), array_pop( $argsvar ) );
    93111        }
    94112
     113        /**
     114         * One tag with multiple filters.
     115         *
     116         * @covers ::add_filter
     117         */
    95118        function test_filter_args_2() {
    96119                $a1   = new MockAction();
    97120                $a2   = new MockAction();
     
    117140                $this->assertEquals( array( $val ), array_pop( $argsvar2 ) );
    118141        }
    119142
     143        /**
     144         * One tag with multiple filters.
     145         *
     146         * @covers ::add_filter
     147         */
    120148        function test_filter_priority() {
    121149                $a   = new MockAction();
    122150                $tag = __FUNCTION__;
     
    148176                $this->assertEquals( $expected, $a->get_events() );
    149177        }
    150178
     179        /**
     180         * One tag with multiple filters.
     181         *
     182         * @covers ::add_filter
     183         */
    151184        function test_all_filter() {
    152185                $a    = new MockAction();
    153186                $tag1 = __FUNCTION__ . '_1';
     
    172205
    173206        }
    174207
     208        /**
     209         * One tag with multiple filters.
     210         *
     211         * @covers ::add_filter
     212         */
    175213        function test_remove_all_filter() {
    176214                $a   = new MockAction();
    177215                $tag = __FUNCTION__;
     
    198236
    199237        /**
    200238         * @ticket 20920
     239         *
     240         * @covers ::add_filter
    201241         */
    202242        function test_remove_all_filters_should_respect_the_priority_argument() {
    203243                $a   = new MockAction();
     
    217257
    218258        /**
    219259         * @ticket 9886
     260         *
     261         * @covers ::add_filter
    220262         */
    221263        function test_filter_ref_array() {
    222264                $obj = new stdClass();
     
    236278
    237279        /**
    238280         * @ticket 12723
     281         *
     282         * @covers ::add_filter
    239283         */
    240284        function test_filter_ref_array_result() {
    241285                $obj = new stdClass();
     
    271315
    272316        /**
    273317         * @ticket 29070
     318         *
     319         * @covers ::has_filter
    274320         */
    275321        function test_has_filter_after_remove_all_filters() {
    276322                $a   = new MockAction();
     
    298344        /**
    299345         * @ticket 10441
    300346         * @expectedDeprecated tests_apply_filters_deprecated
     347         *
     348         * @covers ::apply_filters_deprecated
    301349         */
    302350        public function test_apply_filters_deprecated() {
    303351                $p = 'Foo';
     
    317365        /**
    318366         * @ticket 10441
    319367         * @expectedDeprecated tests_apply_filters_deprecated
     368         *
     369         * @covers ::apply_filters_deprecated
    320370         */
    321371        public function test_apply_filters_deprecated_with_multiple_params() {
    322372                $p1 = 'Foo1';
     
    341391
    342392        /**
    343393         * @ticket 10441
     394         *
     395         * @covers ::apply_filters_deprecated
    344396         */
    345397        public function test_apply_filters_deprecated_without_filter() {
    346398                $val = 'Foobar';
     
    351403        private $current_priority;
    352404        /**
    353405         * @ticket 39007
     406         *
     407         * @covers ::add_action
    354408         */
    355409        public function test_current_priority() {
    356410                add_action( 'test_current_priority', array( $this, '_current_priority_action' ), 99 );
     
    360414                $this->assertSame( 99, $this->current_priority );
    361415        }
    362416
     417        /**
     418         * One tag with multiple filters.
     419         */
    363420        public function _current_priority_action() {
    364421                global $wp_filter;
    365422                $this->current_priority = $wp_filter[ current_filter() ]->current_priority();
     
    367424
    368425        /**
    369426         * @ticket 39007
     427         *
     428         * @covers ::add_action
    370429         */
    371430        public function test_other_priority() {
    372431                add_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 );
  • tests/phpunit/tests/functions.php

     
    44 * @group functions.php
    55 */
    66class Tests_Functions extends WP_UnitTestCase {
     7
     8        /**
     9         *
     10         * @covers ::wp_parse_args
     11         */
    712        function test_wp_parse_args_object() {
    813                $x        = new MockClass;
    914                $x->_baba = 5;
     
    2126                $this->assertEquals( array(), wp_parse_args( $y ) );
    2227        }
    2328
     29
     30        /**
     31         *
     32         * @covers ::wp_parse_args
     33         */
    2434        function test_wp_parse_args_array() {
    2535                // Arrays.
    2636                $a = array();
     
    4050                );
    4151        }
    4252
     53
     54        /**
     55         *
     56         * @covers ::wp_parse_args
     57         */
    4358        function test_wp_parse_args_defaults() {
    4459                $x        = new MockClass;
    4560                $x->_baba = 5;
     
    6681                );
    6782        }
    6883
     84
     85        /**
     86         *
     87         * @covers ::wp_parse_args
     88         */
    6989        function test_wp_parse_args_other() {
    7090                $b = true;
    7191                wp_parse_str( $b, $s );
     
    7797
    7898        /**
    7999         * @ticket 30753
     100         *
     101         * @covers ::wp_parse_args
    80102         */
    81103        function test_wp_parse_args_boolean_strings() {
    82104                $args = wp_parse_args( 'foo=false&bar=true' );
     
    86108
    87109        /**
    88110         * @ticket 35972
     111         *
     112         * @covers ::bool_from_yn
    89113         */
    90114        function test_bool_from_yn() {
    91115                $this->assertTrue( bool_from_yn( 'Y' ) );
     
    93117                $this->assertFalse( bool_from_yn( 'n' ) );
    94118        }
    95119
     120        /**
     121         *
     122         * @covers ::path_is_absolute
     123         */
    96124        function test_path_is_absolute() {
    97125                $absolute_paths = array(
    98126                        '/',
     
    111139                }
    112140        }
    113141
     142        /**
     143         *
     144         * @covers ::path_is_absolute
     145         */
    114146        function test_path_is_not_absolute() {
    115147                $relative_paths = array(
    116148                        '',
     
    134166         * @ticket 35996
    135167         *
    136168         * @dataProvider data_wp_normalize_path
     169         * @covers ::wp_normalize_path
    137170         */
    138171        function test_wp_normalize_path( $path, $expected ) {
    139172                $this->assertEquals( $expected, wp_normalize_path( $path ) );
     
    163196                );
    164197        }
    165198
     199
     200        /**
     201         *
     202         * @covers ::wp_unique_filename
     203         */
    166204        function test_wp_unique_filename() {
    167205
    168206                $testdir = DIR_TESTDATA . '/images/';
     
    198236
    199237        /**
    200238         * @ticket 42437
     239         *
     240         * @covers ::wp_unique_filename
    201241         */
    202242        function test_unique_filename_with_dimension_like_filename() {
    203243                $testdir = DIR_TESTDATA . '/images/';
     
    223263
    224264        /**
    225265         * @dataProvider data_is_not_serialized
     266         *
     267         * @covers ::serialize
    226268         */
    227269        function test_maybe_serialize( $value ) {
    228270                if ( is_array( $value ) || is_object( $value ) ) {
     
    236278
    237279        /**
    238280         * @dataProvider data_is_serialized
     281         *
     282         * @covers ::serialize
    239283         */
    240284        function test_maybe_serialize_with_double_serialization( $value ) {
    241285                $expected = serialize( $value );
     
    246290        /**
    247291         * @dataProvider data_is_serialized
    248292         * @dataProvider data_is_not_serialized
     293         *
     294         * @covers ::maybe_unserialize
    249295         */
    250296        function test_maybe_unserialize( $value, $is_serialized ) {
    251297                if ( $is_serialized ) {
     
    264310        /**
    265311         * @dataProvider data_is_serialized
    266312         * @dataProvider data_is_not_serialized
     313         *
     314         * @covers ::is_serialized
    267315         */
    268316        function test_is_serialized( $value, $expected ) {
    269317                $this->assertSame( $expected, is_serialized( $value ) );
     
    324372        /**
    325373         * @ticket 46570
    326374         * @dataProvider data_is_serialized_should_return_true_for_large_floats
     375         *
     376         * @covers ::is_serialized
    327377         */
    328378        function test_is_serialized_should_return_true_for_large_floats( $value ) {
    329379                $this->assertTrue( is_serialized( $value ) );
     
    338388
    339389        /**
    340390         * @ticket 17375
     391         *
     392         * @covers ::is_serialized
    341393         */
    342394        function test_no_new_serializable_types() {
    343395                $this->assertFalse( is_serialized( 'C:16:"Serialized_Class":6:{a:0:{}}' ) );
     
    345397
    346398        /**
    347399         * @group add_query_arg
     400         *
     401         * @covers ::add_query_arg
    348402         */
    349403        function test_add_query_arg() {
    350404                $old_req_uri = $_SERVER['REQUEST_URI'];
     
    533587
    534588        /**
    535589         * @ticket 31306
     590         *
     591         * @covers ::add_query_arg
    536592         */
    537593        function test_add_query_arg_numeric_keys() {
    538594                $url = add_query_arg( array( 'foo' => 'bar' ), '1=1' );
     
    553609
    554610        /**
    555611         * @ticket 21594
     612         *
     613         * @covers ::get_allowed_mime_types
    556614         */
    557615        function test_get_allowed_mime_types() {
    558616                $mimes = get_allowed_mime_types();
     
    573631
    574632        /**
    575633         * @ticket 21594
     634         *
     635         * @covers ::wp_get_mime_types
    576636         */
    577637        function test_wp_get_mime_types() {
    578638                $mimes = wp_get_mime_types();
     
    605665
    606666        /**
    607667         * @ticket 23688
     668         *
     669         * @covers ::get_option
     670         * @covers ::_canonical_charset
    608671         */
    609672        function test_canonical_charset() {
    610673                $orig_blog_charset = get_option( 'blog_charset' );
     
    643706        /**
    644707         * @ticket 43977
    645708         * @dataProvider data_wp_parse_list
     709         *
     710         * @covers ::wp_parse_list
    646711         */
    647712        function test_wp_parse_list( $expected, $actual ) {
    648713                $this->assertSame( $expected, array_values( wp_parse_list( $actual ) ) );
     
    666731
    667732        /**
    668733         * @dataProvider data_wp_parse_id_list
     734         *
     735         * @covers ::wp_parse_id_list
    669736         */
    670737        function test_wp_parse_id_list( $expected, $actual ) {
    671738                $this->assertSame( $expected, array_values( wp_parse_id_list( $actual ) ) );
     
    701768
    702769        /**
    703770         * @dataProvider data_device_can_upload
     771         *
     772         * @covers ::_device_can_upload
    704773         */
    705774        function test_device_can_upload( $user_agent, $expected ) {
    706775                $_SERVER['HTTP_USER_AGENT'] = $user_agent;
     
    761830
    762831        /**
    763832         * @ticket 9064
     833         *
     834         * @covers ::wp_extract_urls
    764835         */
    765836        function test_wp_extract_urls() {
    766837                $original_urls = array(
     
    928999
    9291000        /**
    9301001         * @ticket 28786
     1002         *
     1003         * @covers ::wp_json_encode
    9311004         */
    9321005        function test_wp_json_encode() {
    9331006                $this->assertEquals( wp_json_encode( 'a' ), '"a"' );
     
    9351008
    9361009        /**
    9371010         * @ticket 28786
     1011         *
     1012         * @covers ::wp_json_encode
    9381013         */
    9391014        function test_wp_json_encode_utf8() {
    9401015                $this->assertEquals( wp_json_encode( '这' ), '"\u8fd9"' );
     
    9421017
    9431018        /**
    9441019         * @ticket 28786
     1020         *
     1021         * @covers ::wp_json_encode
    9451022         */
    9461023        function test_wp_json_encode_non_utf8() {
    9471024                if ( ! function_exists( 'mb_detect_order' ) ) {
     
    9671044
    9681045        /**
    9691046         * @ticket 28786
     1047         *
     1048         * @covers ::wp_json_encode
    9701049         */
    9711050        function test_wp_json_encode_non_utf8_in_array() {
    9721051                if ( ! function_exists( 'mb_detect_order' ) ) {
     
    9921071
    9931072        /**
    9941073         * @ticket 28786
     1074         *
     1075         * @covers ::wp_json_encode
    9951076         */
    9961077        function test_wp_json_encode_array() {
    9971078                $this->assertEquals( wp_json_encode( array( 'a' ) ), '["a"]' );
     
    9991080
    10001081        /**
    10011082         * @ticket 28786
     1083         *
     1084         * @covers ::wp_json_encode
    10021085         */
    10031086        function test_wp_json_encode_object() {
    10041087                $object    = new stdClass;
     
    10081091
    10091092        /**
    10101093         * @ticket 28786
     1094         *
     1095         * @covers ::wp_json_encode
    10111096         */
    10121097        function test_wp_json_encode_depth() {
    10131098                $data = array( array( array( 1, 2, 3 ) ) );
     
    10221107        /**
    10231108         * @ticket 36054
    10241109         * @dataProvider datetime_provider
     1110         *
     1111         * @covers ::mysql_to_rfc3339
    10251112         */
    10261113        function test_mysql_to_rfc3339( $expected, $actual ) {
    10271114                $date_return = mysql_to_rfc3339( $actual );
     
    10441131
    10451132        /**
    10461133         * @ticket 35987
     1134         *
     1135         * @covers ::wp_get_ext_types
    10471136         */
    10481137        public function test_wp_get_ext_types() {
    10491138                $extensions = wp_get_ext_types();
     
    10631152
    10641153        /**
    10651154         * @ticket 35987
     1155         *
     1156         * @covers ::wp_get_ext_types
    10661157         */
    10671158        public function test_wp_ext2type() {
    10681159                $extensions = wp_get_ext_types();
     
    10841175         * test suite is -1, we can not test the memory limit negotiations.
    10851176         *
    10861177         * @ticket 32075
     1178         *
     1179         * @covers ::wp_raise_memory_limit
    10871180         */
    10881181        function test_wp_raise_memory_limit() {
    10891182                if ( -1 !== WP_MAX_MEMORY_LIMIT ) {
     
    11021195        /**
    11031196         * Tests wp_generate_uuid4().
    11041197         *
     1198         * @ticket 38164
     1199         *
    11051200         * @covers ::wp_generate_uuid4
    1106          * @ticket 38164
    11071201         */
    11081202        function test_wp_generate_uuid4() {
    11091203                $uuids = array();
     
    11201214        /**
    11211215         * Tests wp_is_uuid().
    11221216         *
     1217         * @ticket 39778
     1218         *
    11231219         * @covers ::wp_is_uuid
    1124          * @ticket 39778
    11251220         */
    11261221        function test_wp_is_valid_uuid() {
    11271222                $uuids_v4 = array(
     
    11701265        /**
    11711266         * Tests wp_unique_id().
    11721267         *
     1268         * @ticket 44883
     1269         *
    11731270         * @covers ::wp_unique_id
    1174          * @ticket 44883
    11751271         */
    11761272        function test_wp_unique_id() {
    11771273
     
    11981294        /**
    11991295         * @ticket 40017
    12001296         * @dataProvider _wp_get_image_mime
     1297         *
     1298         * @covers ::wp_get_image_mime
    12011299         */
    12021300        public function test_wp_get_image_mime( $file, $expected ) {
    12031301                if ( ! is_callable( 'exif_imagetype' ) && ! function_exists( 'getimagesize' ) ) {
     
    12101308        /**
    12111309         * @ticket 39550
    12121310         * @dataProvider _wp_check_filetype_and_ext_data
     1311         *
     1312         * @covers ::wp_check_filetype_and_ext
    12131313         */
    12141314        function test_wp_check_filetype_and_ext( $file, $filename, $expected ) {
    12151315                if ( ! extension_loaded( 'fileinfo' ) ) {
     
    12221322        /**
    12231323         * @ticket 39550
    12241324         * @group ms-excluded
     1325         *
     1326         * @covers ::wp_check_filetype_and_ext
    12251327         */
    12261328        function test_wp_check_filetype_and_ext_with_filtered_svg() {
    12271329                if ( ! extension_loaded( 'fileinfo' ) ) {
     
    12471349        /**
    12481350         * @ticket 39550
    12491351         * @group ms-excluded
     1352         *
     1353         * @covers ::wp_check_filetype_and_ext
    12501354         */
    12511355        function test_wp_check_filetype_and_ext_with_filtered_woff() {
    12521356                if ( ! extension_loaded( 'fileinfo' ) ) {
     
    14881592         * @param string $file          File path.
    14891593         * @param array  $allowed_files List of allowed files.
    14901594         * @param int    $expected      Expected result.
     1595         *
     1596         * @covers ::validate_file
    14911597         */
    14921598        public function test_validate_file( $file, $allowed_files, $expected ) {
    14931599                $this->assertSame( $expected, validate_file( $file, $allowed_files ) );
     
    16301736         *
    16311737         * @param string $path     The resource path or URL.
    16321738         * @param bool   $expected Expected result.
     1739         *
     1740         * @covers ::wp_is_stream
    16331741         */
    16341742        public function test_wp_is_stream( $path, $expected ) {
    16351743                if ( ! extension_loaded( 'openssl' ) && false !== strpos( $path, 'https://' ) ) {
     
    16741782         *
    16751783         * @param string $input    Duration.
    16761784         * @param string $expected Expected human readable duration.
     1785         *
     1786         * @covers ::human_readable_duration
    16771787         */
    16781788        public function test_human_readable_duration( $input, $expected ) {
    16791789                $this->assertSame( $expected, human_readable_duration( $input ) );
  • tests/phpunit/tests/kses.php

     
    99
    1010        /**
    1111         * @ticket 20210
     12         *
     13         * @covers ::wp_kses
    1214         */
    1315        function test_wp_filter_post_kses_address() {
    1416                global $allowedposttags;
     
    3638
    3739        /**
    3840         * @ticket 20210
     41         *
     42         * @covers ::wp_kses
    3943         */
    4044        function test_wp_filter_post_kses_a() {
    4145                global $allowedposttags;
     
    7781         * @param string $source   Source HTML.
    7882         * @param string $context  Context to use for parsing source.
    7983         * @param string $expected Expected output following KSES parsing.
     84         *
     85         * @covers ::wp_kses
    8086         */
    8187        function test_wp_kses_video( $source, $context, $expected ) {
    8288                $actual = wp_kses( $source, $context );
     
    123129
    124130        /**
    125131         * @ticket 20210
     132         *
     133         * @covers ::wp_kses
    126134         */
    127135        function test_wp_filter_post_kses_abbr() {
    128136                global $allowedposttags;
     
    141149                }
    142150        }
    143151
     152        /**
     153         *
     154         * @covers ::wp_kses
     155         */
    144156        function test_feed_links() {
    145157                global $allowedposttags;
    146158
     
    175187                $this->assertEquals( $expected, wp_kses( $content, $allowedposttags ) );
    176188        }
    177189
     190        /**
     191         *
     192         * @covers ::wp_kses_bad_protocol
     193         */
    178194        function test_wp_kses_bad_protocol() {
    179195                $bad = array(
    180196                        'dummy:alert(1)',
     
    277293                }
    278294        }
    279295
     296        /**
     297         *
     298         * @covers ::wp_kses_data
     299         */
    280300        public function test_hackers_attacks() {
    281301                $xss = simplexml_load_file( DIR_TESTDATA . '/formatting/xssAttacks.xml' );
    282302                foreach ( $xss->attack as $attack ) {
     
    421441
    422442        /**
    423443         * @ticket 20210
     444         *
     445         * @covers ::wp_kses_allowed_html
    424446         */
    425447        public function test_wp_kses_allowed_html() {
    426448                global $allowedposttags, $allowedtags, $allowedentitynames;
     
    470492                $this->assertEquals( $allowedtags, wp_kses_allowed_html( 'data' ) );
    471493        }
    472494
     495        /**
     496         *
     497         * @covers ::wp_kses_post
     498         */
    473499        function test_hyphenated_tag() {
    474500                $string                 = '<hyphenated-tag attribute="value" otherattribute="value2">Alot of hyphens.</hyphenated-tag>';
    475501                $custom_tags            = array(
     
    486512
    487513        /**
    488514         * @ticket 26290
     515         *
     516         * @covers ::wp_kses_normalize_entities
    489517         */
    490518        public function test_wp_kses_normalize_entities() {
    491519                $this->assertEquals( '&spades;', wp_kses_normalize_entities( '&spades;' ) );
     
    504532         *
    505533         * @ticket 28506
    506534         * @dataProvider data_ctrl_removal
     535         *
     536         * @covers ::wp_kses
    507537         */
    508538        function test_ctrl_removal( $input, $output ) {
    509539                global $allowedposttags;
     
    541571         *
    542572         * @ticket 28699
    543573         * @dataProvider data_slash_zero_removal
     574         *
     575         * @covers ::wp_kses
    544576         */
    545577        function test_slash_zero_removal( $input, $output ) {
    546578                global $allowedposttags;
     
    593625         * Test new function wp_kses_hair_parse().
    594626         *
    595627         * @dataProvider data_hair_parse
     628         *
     629         * @covers ::wp_kses_hair_parse
    596630         */
    597631        function test_hair_parse( $input, $output ) {
    598632                return $this->assertEquals( $output, wp_kses_hair_parse( $input ) );
     
    659693         * Test new function wp_kses_attr_parse().
    660694         *
    661695         * @dataProvider data_attr_parse
     696         *
     697         * @covers ::wp_kses_attr_parse
    662698         */
    663699        function test_attr_parse( $input, $output ) {
    664700                return $this->assertEquals( $output, wp_kses_attr_parse( $input ) );
     
    717753         * Test new function wp_kses_one_attr().
    718754         *
    719755         * @dataProvider data_one_attr
     756         *
     757         * @covers ::wp_kses_one_attr
    720758         */
    721759        function test_one_attr( $element, $input, $output ) {
    722760                return $this->assertEquals( $output, wp_kses_one_attr( $input, $element ) );
     
    794832
    795833        /**
    796834         * @ticket 34063
     835         *
     836         * @covers ::wp_kses
    797837         */
    798838        function test_bdo() {
    799839                global $allowedposttags;
     
    805845
    806846        /**
    807847         * @ticket 35079
     848         *
     849         * @covers ::wp_kses
    808850         */
    809851        function test_ol_reversed() {
    810852                global $allowedposttags;
     
    816858
    817859        /**
    818860         * @ticket 40680
     861         *
     862         * @covers ::wp_kses_attr
    819863         */
    820864        function test_wp_kses_attr_no_attributes_allowed_with_empty_array() {
    821865                $element   = 'foo';
     
    826870
    827871        /**
    828872         * @ticket 40680
     873         *
     874         * @covers ::wp_kses_attr
    829875         */
    830876        function test_wp_kses_attr_no_attributes_allowed_with_true() {
    831877                $element   = 'foo';
     
    836882
    837883        /**
    838884         * @ticket 40680
     885         *
     886         * @covers ::wp_kses_attr
    839887         */
    840888        function test_wp_kses_attr_single_attribute_is_allowed() {
    841889                $element   = 'foo';
     
    846894
    847895        /**
    848896         * @ticket 43312
     897         *
     898         * @covers ::wp_kses_attr
    849899         */
    850900        function test_wp_kses_attr_no_attributes_allowed_with_false() {
    851901                $element   = 'foo';
     
    864914         *
    865915         * @param string $css      A string of CSS rules.
    866916         * @param string $expected Expected string of CSS rules.
     917         *
     918         * @covers ::safecss_filter_attr
    867919         */
    868920        public function test_safecss_filter_attr( $css, $expected ) {
    869921                $this->assertSame( $expected, safecss_filter_attr( $css ) );
     
    10521104         * Data attributes are globally accepted.
    10531105         *
    10541106         * @ticket 33121
     1107         *
     1108         * @covers ::wp_kses_post
    10551109         */
    10561110        function test_wp_kses_attr_data_attribute_is_allowed() {
    10571111                $test     = '<div data-foo="foo" data-bar="bar" datainvalid="gone" data--invaild="gone"  data-also-invaild-="gone" data-two-hyphens="remains">Pens and pencils</div>';
     
    10641118         * Ensure wildcard attributes block unprefixed wildcard uses.
    10651119         *
    10661120         * @ticket 33121
     1121         *
     1122         * @covers ::wp_kses
    10671123         */
    10681124        function test_wildcard_requires_hyphen_after_prefix() {
    10691125                $allowed_html = array(
     
    10851141         * Ensure wildcard allows two hyphen.
    10861142         *
    10871143         * @ticket 33121
     1144         *
     1145         * @covers ::wp_kses
    10881146         */
    10891147        function test_wildcard_allows_two_hyphens() {
    10901148                $allowed_html = array(
     
    11071165         * @dataProvider data_wildcard_attribute_prefixes
    11081166         *
    11091167         * @ticket 33121
     1168         *
     1169         * @covers ::wp_kses_attr_check
    11101170         */
    11111171        function test_wildcard_attribute_prefixes( $wildcard_attribute, $expected ) {
    11121172                $allowed_html = array(
     
    11521212         *
    11531213         * @param $input string The style attribute saved in the editor.
    11541214         * @param $expected string The sanitized style attribute.
     1215         *
     1216         * @covers ::safecss_filter_attr
    11551217         */
    11561218        function test_kses_style_attr_with_url( $input, $expected ) {
    11571219                $actual = safecss_filter_attr( $input );
     
    12991361         *
    13001362         * @param string $css      A string of CSS rules.
    13011363         * @param string $expected Expected string of CSS rules.
     1364         *
     1365         * @covers ::safecss_filter_attr
    13021366         */
    13031367        public function test_safecss_filter_attr_filtered( $css, $expected ) {
    13041368                add_filter( 'safecss_filter_attr_allow_css', '__return_true' );
     
    13661430         * Test filtering a standard img tag.
    13671431         *
    13681432         * @ticket 50731
     1433         *
     1434         * @covers ::wp_kses_post
    13691435         */
    13701436        function test_wp_kses_img_tag_standard_attributes() {
    13711437                $html = array(
  • tests/phpunit/tests/l10n.php

     
    1717
    1818        /**
    1919         * @ticket 35961
     20         *
     21         * @covers ::_n_noop
    2022         */
    2123        function test_n_noop() {
    2224                $text_domain   = 'text-domain';
     
    3032
    3133        /**
    3234         * @ticket 35961
     35         *
     36         * @covers ::_nx_noop
    3337         */
    3438        function test_nx_noop() {
    3539                $text_domain   = 'text-domain';
     
    4448
    4549        /**
    4650         * @ticket 35073
     51         *
     52         * @covers ::before_last_bar
    4753         */
    4854        function test_before_last_bar() {
    4955                $this->assertEquals( 'no-bar-at-all', before_last_bar( 'no-bar-at-all' ) );
     
    5359
    5460        /**
    5561         * @ticket 35950
     62         *
     63         * @covers ::get_available_languages
    5664         */
    5765        function test_get_available_languages() {
    5866                $array = get_available_languages();
     
    6775
    6876        /**
    6977         * @ticket 35284
     78         *
     79         * @covers ::wp_get_installed_translations
    7080         */
    7181        function test_wp_get_installed_translations_for_core() {
    7282                $installed_translations = wp_get_installed_translations( 'core' );
     
    8999
    90100        /**
    91101         * @ticket 35294
     102         *
     103         * @covers ::wp_dropdown_languages
    92104         */
    93105        function test_wp_dropdown_languages() {
    94106                $args   = array(
     
    111123
    112124        /**
    113125         * @ticket 38632
     126         *
     127         * @covers ::wp_dropdown_languages
    114128         */
    115129        function test_wp_dropdown_languages_site_default() {
    116130                $args   = array(
     
    135149
    136150        /**
    137151         * @ticket 44494
     152         *
     153         * @covers ::wp_dropdown_languages
    138154         */
    139155        function test_wp_dropdown_languages_exclude_en_us() {
    140156                $args   = array(
     
    153169
    154170        /**
    155171         * @ticket 38632
     172         *
     173         * @covers ::wp_dropdown_languages
    156174         */
    157175        function test_wp_dropdown_languages_en_US_selected() {
    158176                $args   = array(
     
    175193
    176194        /**
    177195         * Add site default language to ja_JP in dropdown
     196         *
     197         * @covers ::wp_dropdown_languages
    178198         */
    179199        function test_wp_dropdown_languages_site_default_ja_JP() {
    180200                $args   = array(
     
    199219
    200220        /**
    201221         * Select dropdown language from de_DE to ja_JP
     222         *
     223         * @covers ::wp_dropdown_languages
    202224         */
    203225        function test_wp_dropdown_languages_ja_JP_selected() {
    204226                $args   = array(
     
    246268
    247269        /**
    248270         * @ticket 35284
     271         *
     272         * @covers ::wp_get_pomo_file_data
    249273         */
    250274        function test_wp_get_pomo_file_data() {
    251275                $file  = DIR_TESTDATA . '/pomo/empty.po';
     
    272296
    273297        /**
    274298         * @ticket 44541
     299         *
     300         * @covers ::the_excerpt
    275301         */
    276302        function test_length_of_excerpt_should_be_counted_by_words() {
    277303                global $post;
     
    296322
    297323        /**
    298324         * @ticket 44541
     325         *
     326         * @covers ::the_excerpt
    299327         */
    300328        function test_length_of_excerpt_should_be_counted_by_chars() {
    301329                global $post;
     
    320348
    321349        /**
    322350         * @ticket 44541
     351         *
     352         * @covers ::the_excerpt
    323353         */
    324354        function test_length_of_excerpt_should_be_counted_by_chars_in_japanese() {
    325355                global $post;
     
    344374
    345375        /**
    346376         * @ticket 44541
     377         *
     378         * @covers ::the_excerpt_rss
    347379         */
    348380        function test_length_of_excerpt_rss_should_be_counted_by_words() {
    349381                global $post;
     
    368400
    369401        /**
    370402         * @ticket 44541
     403         *
     404         * @covers ::the_excerpt_rss
    371405         */
    372406        function test_length_of_excerpt_rss_should_be_counted_by_chars() {
    373407                global $post;
     
    393427
    394428        /**
    395429         * @ticket 44541
     430         *
     431         * @covers ::wp_dashboard_recent_drafts
    396432         */
    397433        function test_length_of_draft_should_be_counted_by_words() {
    398434                require_once ABSPATH . 'wp-admin/includes/dashboard.php';
     
    417453
    418454        /**
    419455         * @ticket 44541
     456         *
     457         * @covers ::wp_dashboard_recent_drafts
    420458         */
    421459        function test_length_of_draft_should_be_counted_by_chars() {
    422460                require_once ABSPATH . 'wp-admin/includes/dashboard.php';
     
    441479
    442480        /**
    443481         * @ticket 44541
     482         *
     483         * @covers ::wp_dashboard_recent_drafts
    444484         */
    445485        function test_length_of_draft_should_be_counted_by_chars_in_japanese() {
    446486                require_once ABSPATH . 'wp-admin/includes/dashboard.php';
     
    465505
    466506        /**
    467507         * @ticket 44541
     508         *
     509         * @covers ::get_comment_excerpt
    468510         */
    469511        function test_length_of_comment_excerpt_should_be_counted_by_words() {
    470512                switch_to_locale( 'en_US' );
     
    483525
    484526        /**
    485527         * @ticket 44541
     528         *
     529         * @covers ::get_comment_excerpt
    486530         */
    487531        function test_length_of_comment_excerpt_should_be_counted_by_chars() {
    488532                switch_to_locale( 'ja_JP' );
     
    501545
    502546        /**
    503547         * @ticket 44541
     548         *
     549         * @covers ::get_comment_excerpt
    504550         */
    505551        function test_length_of_comment_excerpt_should_be_counted_by_chars_in_Japanese() {
    506552                switch_to_locale( 'ja_JP' );
  • tests/phpunit/tests/link.php

     
    1010
    1111        /**
    1212         * @ticket 8847
     13         *
     14         * @covers ::get_pagenum_link
    1315         */
    1416        function test_get_pagenum_link_case_insensitivity() {
    1517                $old_req_uri = $_SERVER['REQUEST_URI'];
     
    2628                $_SERVER['REQUEST_URI'] = $old_req_uri;
    2729        }
    2830
     31        /**
     32         *
     33         * @covers ::wp_get_shortlink
     34         */
    2935        function test_wp_get_shortlink() {
    3036                $post_id  = self::factory()->post->create();
    3137                $post_id2 = self::factory()->post->create();
     
    7076                $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink() );
    7177        }
    7278
     79        /**
     80         *
     81         * @covers ::wp_get_shortlink
     82         */
    7383        function test_wp_get_shortlink_with_page() {
    7484                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    7585
     
    8494
    8595        /**
    8696         * @ticket 26871
     97         *
     98         * @covers ::wp_get_shortlink
    8799         */
    88100        function test_wp_get_shortlink_with_home_page() {
    89101                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
     
    99111
    100112        /**
    101113         * @ticket 30910
     114         *
     115         * @covers ::get_permalink
    102116         */
    103117        public function test_get_permalink_should_not_reveal_post_name_for_post_with_post_status_future() {
    104118                update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' );
     
    114128
    115129                $non_pretty_permalink = add_query_arg( 'p', $p, trailingslashit( home_url() ) );
    116130
    117                 $this->assertEquals( $non_pretty_permalink, get_permalink( $p ) );
     131                $this->assertSame( $non_pretty_permalink, get_permalink( $p ) );
    118132        }
    119133
    120134        /**
    121135         * @ticket 30910
     136         *
     137         * @covers ::get_permalink
    122138         */
    123139        public function test_get_permalink_should_not_reveal_post_name_for_cpt_with_post_status_future() {
    124140                update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' );
     
    148164
    149165        /**
    150166         * @ticket 1914
     167         *
     168         * @covers ::get_permalink
    151169         */
    152170        public function test_unattached_attachment_has_a_pretty_permalink() {
    153171                $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     
    170188
    171189        /**
    172190         * @ticket 1914
     191         *
     192         * @covers ::get_permalink
    173193         */
    174194        public function test_attachment_attached_to_non_existent_post_type_has_a_pretty_permalink() {
    175195                global $wp_post_types;
  • tests/phpunit/tests/locale.php

     
    1515                $this->locale = new WP_Locale();
    1616        }
    1717
     18        /**
     19         *
     20         * @covers WP_Locale::get_weekday
     21         */
    1822        public function test_get_weekday() {
    1923                $this->assertEquals( __( 'Sunday' ), $this->locale->get_weekday( 0 ) );
    2024                $this->assertEquals( __( 'Monday' ), $this->locale->get_weekday( 1 ) );
     
    2731
    2832        /**
    2933         * @expectedException PHPUnit_Framework_Error_Notice
     34         *
     35         * @covers WP_Locale::get_weekday
    3036         */
    3137        public function test_get_weekday_undefined_index() {
    3238                $this->locale->get_weekday( 7 );
    3339        }
    3440
     41        /**
     42         *
     43         * @covers WP_Locale::get_weekday_initial
     44         */
    3545        public function test_get_weekday_initial() {
    3646                $this->assertEquals( __( 'S' ), $this->locale->get_weekday_initial( __( 'Sunday' ) ) );
    3747                $this->assertEquals( __( 'M' ), $this->locale->get_weekday_initial( __( 'Monday' ) ) );
     
    4252                $this->assertEquals( __( 'S' ), $this->locale->get_weekday_initial( __( 'Saturday' ) ) );
    4353        }
    4454
     55        /**
     56         *
     57         * @covers WP_Locale::get_weekday_abbrev
     58         */
    4559        public function test_get_weekday_abbrev() {
    4660                $this->assertEquals( __( 'Sun' ), $this->locale->get_weekday_abbrev( __( 'Sunday' ) ) );
    4761                $this->assertEquals( __( 'Mon' ), $this->locale->get_weekday_abbrev( __( 'Monday' ) ) );
     
    5266                $this->assertEquals( __( 'Sat' ), $this->locale->get_weekday_abbrev( __( 'Saturday' ) ) );
    5367        }
    5468
     69        /**
     70         *
     71         * @covers WP_Locale::get_month
     72         */
    5573        public function test_get_month() {
    5674                $this->assertEquals( __( 'January' ), $this->locale->get_month( 1 ) );
    5775                $this->assertEquals( __( 'February' ), $this->locale->get_month( 2 ) );
     
    6785                $this->assertEquals( __( 'December' ), $this->locale->get_month( 12 ) );
    6886        }
    6987
     88        /**
     89         *
     90         * @covers WP_Locale::get_month
     91         */
    7092        public function test_get_month_leading_zero() {
    7193                $this->assertEquals( __( 'January' ), $this->locale->get_month( '01' ) );
    7294                $this->assertEquals( __( 'February' ), $this->locale->get_month( '02' ) );
     
    79101                $this->assertEquals( __( 'September' ), $this->locale->get_month( '09' ) );
    80102        }
    81103
     104        /**
     105         *
     106         * @covers WP_Locale::get_month_abbrev
     107         */
    82108        public function test_get_month_abbrev() {
    83109                $this->assertEquals( __( 'Jan' ), $this->locale->get_month_abbrev( __( 'January' ) ) );
    84110                $this->assertEquals( __( 'Feb' ), $this->locale->get_month_abbrev( __( 'February' ) ) );
     
    94120                $this->assertEquals( __( 'Dec' ), $this->locale->get_month_abbrev( __( 'December' ) ) );
    95121        }
    96122
     123        /**
     124         *
     125         * @covers WP_Locale::get_meridiem
     126         */
    97127        public function test_get_meridiem() {
    98128                $this->assertEquals( __( 'am' ), $this->locale->get_meridiem( 'am' ) );
    99129                $this->assertEquals( __( 'AM' ), $this->locale->get_meridiem( 'AM' ) );
     
    101131                $this->assertEquals( __( 'PM' ), $this->locale->get_meridiem( 'PM' ) );
    102132        }
    103133
     134        /**
     135         *
     136         * @covers WP_Locale::is_rtl
     137         */
    104138        public function test_is_rtl() {
    105139                $this->assertFalse( $this->locale->is_rtl() );
    106140                $this->locale->text_direction = 'foo';
  • tests/phpunit/tests/mail.php

     
    2121         * when it encounters a line longer than 999 characters. But PHPMailer doesn't clean up after itself / presets
    2222         * all variables, which means that following tests would fail. To solve this issue we set `$this->Encoding`
    2323         * back to 8bit in `MockPHPMailer::preSend`.
     24         *
     25         * @covers ::wp_mail
    2426         */
    2527        function test_wp_mail_break_it() {
    2628                $content = str_repeat( 'A', 1000 );
     
    2729                $this->assertTrue( wp_mail( WP_TESTS_EMAIL, 'Looong line testing', $content ) );
    2830        }
    2931
     32        /**
     33         *
     34         * @covers ::wp_mail
     35         */
    3036        function test_wp_mail_custom_boundaries() {
    3137                $to       = 'user@example.com';
    3238                $subject  = 'Test email with custom boundaries';
     
    8793
    8894        /**
    8995         * @ticket 17305
     96         *
     97         * @covers ::wp_mail
    9098         */
    9199        function test_wp_mail_rfc2822_addresses() {
    92100                $to        = 'Name <address@tld.com>';
     
    117125
    118126        /**
    119127         * @ticket 17305
     128         *
     129         * @covers ::wp_mail
    120130         */
    121131        function test_wp_mail_multiple_rfc2822_to_addresses() {
    122132                $to      = 'Name <address@tld.com>, Another Name <another_address@different-tld.com>';
     
    135145                $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body );
    136146        }
    137147
     148        /**
     149         *
     150         * @covers ::wp_mail
     151         */
    138152        function test_wp_mail_multiple_to_addresses() {
    139153                $to      = 'address@tld.com, another_address@different-tld.com';
    140154                $subject = 'RFC2822 Testing';
     
    150164
    151165        /**
    152166         * @ticket 18463
     167         *
     168         * @covers ::wp_mail
    153169         */
    154170        function test_wp_mail_to_address_no_name() {
    155171                $to      = '<address@tld.com>';
     
    165181
    166182        /**
    167183         * @ticket 23642
     184         *
     185         * @covers ::wp_mail
    168186         */
    169187        function test_wp_mail_return_value() {
    170188                // No errors.
     
    179197
    180198        /**
    181199         * @ticket 30266
     200         *
     201         * @covers ::wp_mail
    182202         */
    183203        public function test_wp_mail_with_valid_from_header() {
    184204                $to       = 'address@tld.com';
     
    195215
    196216        /**
    197217         * @ticket 30266
     218         *
     219         * @covers ::wp_mail
    198220         */
    199221        public function test_wp_mail_with_empty_from_header() {
    200222                $to       = 'address@tld.com';
     
    211233
    212234        /**
    213235         * @ticket 30266
     236         *
     237         * @covers ::wp_mail
    214238         */
    215239        public function test_wp_mail_with_empty_from_name_for_the_from_header() {
    216240                $to       = 'address@tld.com';
     
    227251
    228252        /**
    229253         * @ticket 30266
     254         *
     255         * @covers ::wp_mail
    230256         */
    231257        public function test_wp_mail_with_valid_content_type_header() {
    232258                $to       = 'address@tld.com';
     
    243269
    244270        /**
    245271         * @ticket 30266
     272         *
     273         * @covers ::wp_mail
    246274         */
    247275        public function test_wp_mail_with_empty_content_type_header() {
    248276                $to       = 'address@tld.com';
     
    259287
    260288        /**
    261289         * @ticket 30266
     290         *
     291         * @covers ::wp_mail
    262292         */
    263293        public function test_wp_mail_with_empty_charset_for_the_content_type_header() {
    264294                $to       = 'address@tld.com';
     
    275305
    276306        /**
    277307         * @ticket 43542
     308         *
     309         * @covers ::wp_mail
    278310         */
    279311        public function test_wp_mail_does_not_duplicate_mime_version_header() {
    280312                $to       = 'user@example.com';
     
    308340         * https://tools.ietf.org/html/rfc2045#section-6.1
    309341         *
    310342         * @ticket 28039
     343         *
     344         * @covers ::wp_mail
    311345         */
    312346        function test_wp_mail_content_transfer_encoding_in_quoted_printable_multipart() {
    313347                add_action( 'phpmailer_init', array( $this, 'wp_mail_quoted_printable' ) );
     
    325359
    326360        /**
    327361         * @ticket 21659
     362         *
     363         * @covers ::wp_mail
    328364         */
    329365        public function test_wp_mail_addresses_arent_encoded() {
    330366                $to      = 'Lukáš To <to@example.org>';
     
    367403         * set it correctly.
    368404         *
    369405         * @ticket 37736
     406         *
     407         * @covers ::wp_mail
    370408         */
    371409        public function test_wp_mail_sender_not_set() {
    372410                wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should not have been set.' );
     
    378416
    379417        /**
    380418         * @ticket 35598
     419         *
     420         * @covers ::wp_mail
    381421         */
    382422        public function test_phpmailer_exception_thrown() {
    383423                $to      = 'an_invalid_address';
     
    410450
    411451        /**
    412452         * @ticket 50720
     453         *
     454         * @coversNothing
    413455         */
    414456        function test_phpmailer_validator() {
    415457                $phpmailer = $GLOBALS['phpmailer'];
  • tests/phpunit/tests/media.php

     
    4646                );
    4747        }
    4848
     49        /**
     50         * @covers ::add_shortcode
     51         */
    4952        function test_img_caption_shortcode_added() {
    5053                global $shortcode_tags;
    5154                $this->assertEquals( 'img_caption_shortcode', $shortcode_tags['caption'] );
     
    5255                $this->assertEquals( 'img_caption_shortcode', $shortcode_tags['wp_caption'] );
    5356        }
    5457
     58        /**
     59         * @covers ::img_caption_shortcode
     60         */
    5561        function test_img_caption_shortcode_with_empty_params() {
    5662                $result = img_caption_shortcode( array() );
    5763                $this->assertNull( $result );
     
    5965
    6066        /**
    6167         * @ticket 33981
     68         *
     69         * @covers ::img_caption_shortcode
    6270         */
    6371        function test_img_caption_shortcode_with_empty_params_but_content() {
    6472                $result = img_caption_shortcode( array(), $this->caption );
     
    6775
    6876        /**
    6977         * @ticket 33981
     78         *
     79         * @covers ::img_caption_shortcode
    7080         */
    7181        function test_img_caption_shortcode_short_circuit_filter() {
    7282                add_filter( 'img_caption_shortcode', array( $this, '_return_alt_caption' ) );
     
    8494
    8595        /**
    8696         * @ticket 33981
     97         *
     98         * @covers ::img_caption_shortcode
    8799         */
    88100        function test_img_caption_shortcode_empty_width() {
    89101                $result = img_caption_shortcode(
     
    97109
    98110        /**
    99111         * @ticket 33981
     112         *
     113         * @covers ::img_caption_shortcode
    100114         */
    101115        function test_img_caption_shortcode_empty_caption() {
    102116                $result = img_caption_shortcode(
     
    109123
    110124        /**
    111125         * @ticket 33981
     126         *
     127         * @covers ::img_caption_shortcode
    112128         */
    113129        function test_img_caption_shortcode_empty_caption_and_content() {
    114130                $result = img_caption_shortcode(
     
    120136                $this->assertEquals( $this->caption, $result );
    121137        }
    122138
     139        /**
     140         * @covers ::img_caption_shortcode
     141         */
    123142        function test_img_caption_shortcode_with_old_format() {
    124143                $result = img_caption_shortcode(
    125144                        array(
     
    139158                }
    140159        }
    141160
     161        /**
     162         * @covers ::img_caption_shortcode
     163         */
    142164        function test_img_caption_shortcode_with_old_format_id_and_align() {
    143165                $result = img_caption_shortcode(
    144166                        array(
     
    153175                $this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) );
    154176        }
    155177
     178        /**
     179         * @covers ::img_caption_shortcode
     180         */
    156181        function test_img_caption_shortcode_with_old_format_and_class() {
    157182                $result = img_caption_shortcode(
    158183                        array(
     
    165190
    166191        }
    167192
     193        /**
     194         * @covers ::img_caption_shortcode
     195         */
    168196        function test_new_img_caption_shortcode_with_html_caption() {
    169197                $result   = img_caption_shortcode(
    170198                        array(
     
    177205                $this->assertEquals( 1, preg_match_all( "~{$our_preg}~", $result, $_r ) );
    178206        }
    179207
     208        /**
     209         * @covers ::img_caption_shortcode
     210         */
    180211        function test_new_img_caption_shortcode_new_format() {
    181212                $result       = img_caption_shortcode(
    182213                        array( 'width' => 20 ),
     
    189220                $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) );
    190221        }
    191222
     223        /**
     224         * @covers ::img_caption_shortcode
     225         */
    192226        function test_new_img_caption_shortcode_new_format_and_linked_image() {
    193227                $linked_image = "<a href='#'>{$this->img_content}</a>";
    194228                $result       = img_caption_shortcode(
     
    202236                $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) );
    203237        }
    204238
     239        /**
     240         * @covers ::img_caption_shortcode
     241         */
    205242        function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() {
    206243                $linked_image = "<a href='#'>{$this->img_content}</a>";
    207244                $result       = img_caption_shortcode(
     
    217254
    218255        /**
    219256         * @ticket 34595
     257         *
     258         * @covers ::img_caption_shortcode
    220259         */
    221260        function test_img_caption_shortcode_has_aria_describedby() {
    222261                $result = img_caption_shortcode(
     
    230269                $this->assertEquals( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) );
    231270        }
    232271
     272        /**
     273         * @covers ::wp_oembed_remove_provider
     274         */
    233275        function test_add_remove_oembed_provider() {
    234276                wp_oembed_add_provider( 'http://foo.bar/*', 'http://foo.bar/oembed' );
    235277                $this->assertTrue( wp_oembed_remove_provider( 'http://foo.bar/*' ) );
     
    238280
    239281        /**
    240282         * @ticket 23776
     283         *
     284         * @covers WP_Embed::autoembed
    241285         */
    242286        function test_autoembed_empty() {
    243287                global $wp_embed;
     
    250294
    251295        /**
    252296         * @ticket 23776
     297         *
     298         * @covers WP_Embed::autoembed
    253299         */
    254300        function test_autoembed_no_paragraphs_around_urls() {
    255301                global $wp_embed;
     
    329375
    330376        /**
    331377         * @dataProvider data_autoembed
     378         *
     379         * @covers WP_Embed::autoembed
    332380         */
    333381        function test_autoembed( $content, $result = null ) {
    334382                $wp_embed = new Test_Autoembed;
     
    336384                $this->assertEquals( $wp_embed->autoembed( $content ), $result ? $result : $content );
    337385        }
    338386
     387        /**
     388         * @covers ::wp_prepare_attachment_for_js
     389         */
    339390        function test_wp_prepare_attachment_for_js() {
    340391                // Attachment without media.
    341392                $id   = wp_insert_attachment(
     
    389440
    390441        /**
    391442         * @ticket 38965
     443         *
     444         * @covers ::wp_prepare_attachment_for_js
    392445         */
    393446        function test_wp_prepare_attachment_for_js_without_image_sizes() {
    394447                // Create the attachement post.
     
    420473        /**
    421474         * @ticket 19067
    422475         * @expectedDeprecated wp_convert_bytes_to_hr
     476         *
     477         * @covers ::wp_convert_bytes_to_hr
     478         * @covers ::size_format
    423479         */
    424480        function test_wp_convert_bytes_to_hr() {
    425481                $kb = 1024;
     
    458514
    459515        /**
    460516         * @ticket 22960
     517         *
     518         * @covers ::get_attached_media
    461519         */
    462520        function test_get_attached_images() {
    463521                $post_id       = self::factory()->post->create();
     
    476534
    477535        /**
    478536         * @ticket 22960
     537         *
     538         * @covers ::wp_update_attachment_metadata
    479539         */
    480540        function test_post_galleries_images() {
    481541                $ids1      = array();
     
    527587
    528588        /**
    529589         * @ticket 39304
     590         *
     591         * @covers ::get_post_galleries
    530592         */
    531593        function test_post_galleries_images_without_global_post() {
    532594                // Set up an unattached image.
     
    552614
    553615        /**
    554616         * @ticket 39304
     617         *
     618         * @covers ::get_post_galleries
    555619         */
    556620        function test_post_galleries_ignores_global_post() {
    557621                $global_post_id = $this->factory->post->create(
     
    587651
    588652        /**
    589653         * @ticket 39304
     654         *
     655         * @covers ::get_post_galleries
    590656         */
    591657        function test_post_galleries_respects_id_attrs() {
    592658                $post_id     = $this->factory->post->create(
     
    626692
    627693        /**
    628694         * @ticket 22960
     695         *
     696         * @covers ::get_post_gallery_images
    629697         */
    630698        function test_post_gallery_images() {
    631699                $ids1      = array();
     
    675743                $this->assertEquals( $srcs, $ids1_srcs );
    676744        }
    677745
     746        /**
     747         * @covers ::get_media_embedded_in_content
     748         */
    678749        function test_get_media_embedded_in_content() {
    679750                $object = <<<OBJ
    680751<object src="this" data="that">
     
    739810                $this->assertEquals( $contents, $matches );
    740811        }
    741812
     813        /**
     814         * @covers ::get_media_embedded_in_content
     815         */
    742816        function test_get_media_embedded_in_content_order() {
    743817                $audio   = <<<AUDIO
    744818<audio preload="none">
     
    769843
    770844        /**
    771845         * @ticket 35367
     846         *
     847         * @covers ::wp_audio_shortcode
    772848         */
    773849        function test_wp_audio_shortcode_with_bad_attr() {
    774850                $this->assertSame(
     
    783859
    784860        /**
    785861         * @ticket 35367
     862         *
     863         * @covers ::wp_audio_shortcode
    786864         */
    787865        function test_wp_audio_shortcode_attributes() {
    788866                $actual = wp_audio_shortcode(
     
    819897
    820898        /**
    821899         * Test [video] shortcode processing
     900         *
     901         * @covers ::wp_video_shortcode
    822902         */
    823903        function test_video_shortcode_body() {
    824904                $width  = 720;
     
    865945        /**
    866946         * @ticket 35367
    867947         * @depends test_video_shortcode_body
     948         *
     949         * @covers ::wp_video_shortcode
    868950         */
    869951        function test_wp_video_shortcode_with_empty_params() {
    870952                $this->assertNull( wp_video_shortcode( array() ) );
     
    873955        /**
    874956         * @ticket 35367
    875957         * @depends test_video_shortcode_body
     958         *
     959         * @covers ::wp_video_shortcode
    876960         */
    877961        function test_wp_video_shortcode_with_bad_attr() {
    878962                $this->assertSame(
     
    888972        /**
    889973         * @ticket 35367
    890974         * @depends test_video_shortcode_body
     975         *
     976         * @covers ::wp_video_shortcode
    891977         */
    892978        function test_wp_video_shortcode_attributes() {
    893979                $actual = wp_video_shortcode(
     
    9301016        /**
    9311017         * @ticket 40866
    9321018         * @depends test_video_shortcode_body
     1019         *
     1020         * @covers ::wp_video_shortcode
    9331021         */
    9341022        function test_wp_video_shortcode_youtube_remove_feature() {
    9351023                $actual = wp_video_shortcode(
     
    9441032        /**
    9451033         * @ticket 40866
    9461034         * @depends test_video_shortcode_body
     1035         *
     1036         * @covers ::wp_video_shortcode
    9471037         */
    9481038        function test_wp_video_shortcode_youtube_force_ssl() {
    9491039                $actual = wp_video_shortcode(
     
    9581048        /**
    9591049         * @ticket 40866
    9601050         * @depends test_video_shortcode_body
     1051         *
     1052         * @covers ::wp_video_shortcode
    9611053         */
    9621054        function test_wp_video_shortcode_vimeo_force_ssl_remove_query_args() {
    9631055                $actual = wp_video_shortcode(
     
    9731065        /**
    9741066         * @ticket 40977
    9751067         * @depends test_video_shortcode_body
     1068         *
     1069         * @covers ::wp_video_shortcode
    9761070         */
    9771071        function test_wp_video_shortcode_vimeo_adds_loop() {
    9781072                $actual = wp_video_shortcode(
     
    9871081        /**
    9881082         * @ticket 40977
    9891083         * @depends test_video_shortcode_body
     1084         *
     1085         * @covers ::wp_video_shortcode
    9901086         */
    9911087        function test_wp_video_shortcode_vimeo_force_adds_loop_true() {
    9921088                $actual = wp_video_shortcode(
     
    10011097
    10021098        /**
    10031099         * @ticket 26768
     1100         *
     1101         * @covers ::add_image_size
    10041102         */
    10051103        function test_add_image_size() {
    10061104                $_wp_additional_image_sizes = wp_get_additional_image_sizes();
     
    10221120
    10231121        /**
    10241122         * @ticket 26768
     1123         *
     1124         * @covers ::remove_image_size
    10251125         */
    10261126        function test_remove_image_size() {
    10271127                add_image_size( 'test-size', 200, 600 );
     
    10321132
    10331133        /**
    10341134         * @ticket 26951
     1135         *
     1136         * @covers ::has_image_size
    10351137         */
    10361138        function test_has_image_size() {
    10371139                add_image_size( 'test-size', 200, 600 );
     
    10431145
    10441146        /**
    10451147         * @ticket 30346
     1148         *
     1149         * @covers ::attachment_url_to_postid
    10461150         */
    10471151        function test_attachment_url_to_postid() {
    10481152                $image_path    = '2014/11/' . $this->img_name;
     
    10611165
    10621166        /**
    10631167         * @ticket 33109
     1168         *
     1169         * @covers ::attachment_url_to_postid
    10641170         */
    10651171        function test_attachment_url_to_postid_with_different_scheme() {
    10661172                $image_path    = '2014/11/' . $this->img_name;
     
    10791185
    10801186        /**
    10811187         * @ticket 39768
     1188         *
     1189         * @covers ::attachment_url_to_postid
    10821190         */
    10831191        function test_attachment_url_to_postid_should_be_case_sensitive() {
    10841192                $image_path_lower_case    = '2014/11/' . $this->img_name;
     
    11051213                $this->assertEquals( $attachment_id_upper_case, attachment_url_to_postid( $image_url ) );
    11061214        }
    11071215
     1216        /**
     1217         * @covers ::attachment_url_to_postid
     1218         */
    11081219        function test_attachment_url_to_postid_filtered() {
    11091220                $image_path    = '2014/11/' . $this->img_name;
    11101221                $attachment_id = self::factory()->attachment->create_object(
     
    11291240
    11301241        /**
    11311242         * @ticket 31044
     1243         *
     1244         * @covers ::attachment_url_to_postid
    11321245         */
    11331246        function test_attachment_url_to_postid_with_empty_url() {
    11341247                $post_id = attachment_url_to_postid( '' );
     
    11381251
    11391252        /**
    11401253         * @ticket 22768
     1254         *
     1255         * @covers ::media_handle_upload
    11411256         */
    11421257        public function test_media_handle_upload_sets_post_excerpt() {
    11431258                $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg';
     
    11771292
    11781293        /**
    11791294         * @ticket 37989
     1295         *
     1296         * @covers ::media_handle_upload
    11801297         */
    11811298        public function test_media_handle_upload_expected_titles() {
    11821299                $test_file = DIR_TESTDATA . '/images/test-image.jpg';
     
    12161333
    12171334        /**
    12181335         * @ticket 33016
     1336         *
     1337         * @covers WP_Embed::autoembed
    12191338         */
    12201339        function test_multiline_cdata() {
    12211340                global $wp_embed;
     
    12331352
    12341353        /**
    12351354         * @ticket 33016
     1355         *
     1356         * @covers WP_Embed::autoembed
    12361357         */
    12371358        function test_multiline_comment() {
    12381359                global $wp_embed;
     
    12501371
    12511372        /**
    12521373         * @ticket 33016
     1374         *
     1375         * @covers WP_Embed::autoembed
    12531376         */
    12541377        function test_multiline_comment_with_embeds() {
    12551378                $content = <<<EOF
     
    12931416
    12941417        /**
    12951418         * @ticket 33016
     1419         *
     1420         * @covers WP_Embed::autoembed
    12961421         */
    12971422        function test_oembed_explicit_media_link() {
    12981423                global $wp_embed;
     
    13301455         * Tests the default output of `wp_get_attachment_image()`.
    13311456         *
    13321457         * @ticket 34635
     1458         *
     1459         * @covers ::wp_get_attachment_image
    13331460         */
    13341461        function test_wp_get_attachment_image_defaults() {
    13351462                $image    = image_downsize( self::$large_id, 'thumbnail' );
     
    13471474         * Test that `wp_get_attachment_image()` returns a proper alt value.
    13481475         *
    13491476         * @ticket 34635
     1477         *
     1478         * @covers ::wp_get_attachment_image
    13501479         */
    13511480        function test_wp_get_attachment_image_with_alt() {
    13521481                // Add test alt metadata.
     
    13681497
    13691498        /**
    13701499         * @ticket 33878
     1500         *
     1501         * @covers ::wp_get_attachment_image
    13711502         */
    13721503        function test_wp_get_attachment_image_url() {
    13731504                $this->assertFalse( wp_get_attachment_image_url( 0 ) );
     
    13891520
    13901521        /**
    13911522         * @ticket 12235
     1523         *
     1524         * @covers ::wp_get_attachment_caption
    13921525         */
    13931526        function test_wp_get_attachment_caption() {
    13941527                $this->assertFalse( wp_get_attachment_caption( 0 ) );
     
    14131546
    14141547        /**
    14151548         * @ticket 12235
     1549         *
     1550         * @covers ::wp_get_attachment_caption
    14161551         */
    14171552        function test_wp_get_attachment_caption_empty() {
    14181553                $post_id       = self::factory()->post->create();
     
    14631598
    14641599        /**
    14651600         * @ticket 33641
     1601         *
     1602         * @covers ::wp_calculate_image_srcset
    14661603         */
    14671604        function test_wp_calculate_image_srcset() {
    14681605                $_wp_additional_image_sizes = wp_get_additional_image_sizes();
     
    15101647
    15111648        /**
    15121649         * @ticket 33641
     1650         *
     1651         * @covers ::wp_calculate_image_srcset
    15131652         */
    15141653        function test_wp_calculate_image_srcset_no_date_uploads() {
    15151654                $_wp_additional_image_sizes = wp_get_additional_image_sizes();
     
    15661705
    15671706        /**
    15681707         * @ticket 33641
     1708         *
     1709         * @covers ::wp_calculate_image_srcset
    15691710         */
    15701711        function test_wp_calculate_image_srcset_with_edits() {
    15711712                // For this test we're going to mock metadata changes from an edit.
     
    15991740
    16001741        /**
    16011742         * @ticket 35106
     1743         *
     1744         * @covers ::wp_calculate_image_srcset
    16021745         */
    16031746        function test_wp_calculate_image_srcset_with_absolute_path_in_meta() {
    16041747                $_wp_additional_image_sizes = wp_get_additional_image_sizes();
     
    16501793
    16511794        /**
    16521795         * @ticket 33641
     1796         *
     1797         * @covers ::wp_calculate_image_srcset
    16531798         */
    16541799        function test_wp_calculate_image_srcset_false() {
    16551800                $sizes = wp_calculate_image_srcset( array( 400, 300 ), 'file.png', array() );
     
    16601805
    16611806        /**
    16621807         * @ticket 33641
     1808         *
     1809         * @covers ::wp_calculate_image_srcset
    16631810         */
    16641811        function test_wp_calculate_image_srcset_no_width() {
    16651812                $file       = get_attached_file( self::$large_id );
     
    16771824        /**
    16781825         * @ticket 34955
    16791826         * @ticket 33641
     1827         *
     1828         * @covers ::wp_calculate_image_srcset
    16801829         */
    16811830        function test_wp_calculate_image_srcset_ratio_variance() {
    16821831                // Mock data for this test.
     
    17261875        /**
    17271876         * @ticket 35108
    17281877         * @ticket 33641
     1878         *
     1879         * @covers ::wp_calculate_image_srcset
    17291880         */
    17301881        function test_wp_calculate_image_srcset_include_src() {
    17311882                // Mock data for this test.
     
    17751926
    17761927        /**
    17771928         * @ticket 35480
     1929         *
     1930         * @covers ::wp_calculate_image_srcset
    17781931         */
    17791932        function test_wp_calculate_image_srcset_corrupted_image_meta() {
    17801933                $size_array = array( 300, 150 );
     
    18492002        /**
    18502003         * @ticket 36549
    18512004         * @ticket 33641
     2005         *
     2006         * @covers ::wp_calculate_image_srcset
    18522007         */
    18532008        function test_wp_calculate_image_srcset_with_spaces_in_filenames() {
    18542009                // Mock data for this test.
     
    18962051
    18972052        /**
    18982053         * @ticket 33641
     2054         *
     2055         * @covers ::wp_calculate_image_srcset
    18992056         */
    19002057        function test_wp_get_attachment_image_srcset() {
    19012058                $_wp_additional_image_sizes = wp_get_additional_image_sizes();
     
    19352092
    19362093        /**
    19372094         * @ticket 33641
     2095         *
     2096         * @covers ::wp_calculate_image_srcset
    19382097         */
    19392098        function test_wp_get_attachment_image_srcset_single_srcset() {
    19402099                $image_meta = wp_get_attachment_metadata( self::$large_id );
     
    19502109
    19512110        /**
    19522111         * @ticket 33641
     2112         *
     2113         * @covers ::wp_calculate_image_srcset
    19532114         */
    19542115        function test_wp_get_attachment_image_srcset_invalidsize() {
    19552116                $image_meta    = wp_get_attachment_metadata( self::$large_id );
     
    19662127
    19672128        /**
    19682129         * @ticket 33641
     2130         *
     2131         * @covers ::wp_calculate_image_src
    19692132         */
    19702133        function test_wp_get_attachment_image_sizes() {
    19712134                // Test sizes against the default WP sizes.
     
    19862149
    19872150        /**
    19882151         * @ticket 33641
     2152         *
     2153         * @covers ::wp_calculate_image_sizes
    19892154         */
    19902155        function test_wp_calculate_image_sizes() {
    19912156                // Test sizes against the default WP sizes.
     
    20092174
    20102175        /**
    20112176         * @ticket 33641
     2177         *
     2178         * @covers ::wp_filter_content_tags
    20122179         */
    20132180        function test_wp_filter_content_tags_srcset_sizes() {
    20142181                $image_meta = wp_get_attachment_metadata( self::$large_id );
     
    20992266         *
    21002267         * @ticket 34898
    21012268         * @ticket 33641
     2269         *
     2270         * @covers ::wp_filter_content_tags
    21022271         */
    21032272        function test_wp_filter_content_tags_srcset_sizes_wrong() {
    21042273                $img = get_image_tag( self::$large_id, '', '', '', 'medium' );
     
    21122281
    21132282        /**
    21142283         * @ticket 33641
     2284         *
     2285         * @covers ::wp_filter_content_tags
    21152286         */
    21162287        function test_wp_filter_content_tags_srcset_sizes_with_preexisting_srcset() {
    21172288                // Generate HTML and add a dummy srcset attribute.
     
    21262297        /**
    21272298         * @ticket 33641
    21282299         * @ticket 34528
     2300         *
     2301         * @covers ::wp_calculate_image_srcset
    21292302         */
    21302303        function test_wp_calculate_image_srcset_animated_gifs() {
    21312304                // Mock meta for an animated gif.
     
    21702343        /**
    21712344         * @ticket 35045
    21722345         * @ticket 33641
     2346         *
     2347         * @covers ::wp_filter_content_tags
    21732348         */
    21742349        function test_wp_filter_content_tags_schemes() {
    21752350                $image_meta = wp_get_attachment_metadata( self::$large_id );
     
    22212396        /**
    22222397         * @ticket 34945
    22232398         * @ticket 33641
     2399         *
     2400         * @covers ::wp_calculate_image_srcset
    22242401         */
    22252402        function test_wp_get_attachment_image_with_https_on() {
    22262403                // Mock meta for the image.
     
    22662443
    22672444        /**
    22682445         * @ticket 36084
     2446         *
     2447         * @covers :get_image_send_to_editor:
    22692448         */
    22702449        function test_get_image_send_to_editor_defaults() {
    22712450                $id      = self::$large_id;
     
    22862465
    22872466        /**
    22882467         * @ticket 36084
     2468         *
     2469         * @covers ::get_image_send_to_editor
    22892470         */
    22902471        function test_get_image_send_to_editor_defaults_with_optional_params() {
    22912472                $id      = self::$large_id;
     
    23102491
    23112492        /**
    23122493         * @ticket 36084
     2494         *
     2495         * @covers ::get_image_send_to_editor
    23132496         */
    23142497        function test_get_image_send_to_editor_defaults_no_caption_no_rel() {
    23152498                $id      = self::$large_id;
     
    23412524         * used in the output of `wp_get_attachment_image()`.
    23422525         *
    23432526         * @ticket 36246
     2527         *
     2528         * @covers ::wp_get_attachment_image
    23442529         */
    23452530        function test_wp_get_attachment_image_should_use_wp_get_attachment_metadata() {
    23462531                add_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ), 10, 2 );
     
    23762561
    23772562        /**
    23782563         * @ticket 37813
     2564         *
     2565         * @covers ::wp_insert_attachment
    23792566         */
    23802567        public function test_return_type_when_inserting_attachment_with_error_in_data() {
    23812568                $data = array(
     
    23952582
    23962583        /**
    23972584         * @ticket 35218
     2585         *
     2586         * @covers ::wp_get_media_creation_timestamp
    23982587         */
    23992588        function test_wp_get_media_creation_timestamp_video_asf() {
    24002589                $metadata = array(
     
    24112600
    24122601        /**
    24132602         * @ticket 35218
     2603         *
     2604         * @covers ::wp_get_media_creation_timestamp
    24142605         */
    24152606        function test_wp_get_media_creation_timestamp_video_matroska() {
    24162607                $metadata = array(
     
    24292620
    24302621        /**
    24312622         * @ticket 35218
     2623         *
     2624         * @covers ::wp_get_media_creation_timestamp
    24322625         */
    24332626        function test_wp_get_media_creation_timestamp_video_quicktime() {
    24342627                $metadata = array(
     
    24492642
    24502643        /**
    24512644         * @ticket 35218
     2645         *
     2646         * @covers ::wp_get_media_creation_timestamp
    24522647         */
    24532648        function test_wp_get_media_creation_timestamp_video_webm() {
    24542649                $metadata = array(
     
    24722667         *`wp_read_audio_metadata()`.
    24732668         *
    24742669         * @ticket 42017
     2670         *
     2671         * @covers ::wp_read_audio_metadata
    24752672         */
    24762673        function test_wp_read_audio_metadata_adds_creation_date_with_mp4() {
    24772674                $video    = DIR_TESTDATA . '/uploads/small-video.mp4';
     
    24822679
    24832680        /**
    24842681         * @ticket 35218
     2682         *
     2683         * @covers ::wp_read_video_metadata
    24852684         */
    24862685        function test_wp_read_video_metadata_adds_creation_date_with_quicktime() {
    24872686                $video    = DIR_TESTDATA . '/uploads/small-video.mov';
     
    24922691
    24932692        /**
    24942693         * @ticket 35218
     2694         *
     2695         * @covers ::wp_read_video_metadata
    24952696         */
    24962697        function test_wp_read_video_metadata_adds_creation_date_with_mp4() {
    24972698                $video    = DIR_TESTDATA . '/uploads/small-video.mp4';
     
    25022703
    25032704        /**
    25042705         * @ticket 35218
     2706         *
     2707         * @covers ::wp_read_video_metadata
    25052708         */
    25062709        function test_wp_read_video_metadata_adds_creation_date_with_mkv() {
    25072710                $video    = DIR_TESTDATA . '/uploads/small-video.mkv';
     
    25122715
    25132716        /**
    25142717         * @ticket 35218
     2718         *
     2719         * @covers ::wp_read_video_metadata
    25152720         */
    25162721        function test_wp_read_video_metadata_adds_creation_date_with_webm() {
    25172722                $video    = DIR_TESTDATA . '/uploads/small-video.webm';
     
    25222727
    25232728        /**
    25242729         * @ticket 10752
     2730         *
     2731         * @covers ::media_handle_upload
    25252732         */
    25262733        public function test_media_handle_upload_uses_post_parent_for_directory_date() {
    25272734                $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg';
     
    25682775
    25692776        /**
    25702777         * @ticket 10752
     2778         *
     2779         * @covers ::media_handle_upload
    25712780         */
    25722781        public function test_media_handle_upload_ignores_page_parent_for_directory_date() {
    25732782                $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg';
     
    26202829
    26212830        /**
    26222831         * @ticket 50367
     2832         *
     2833         * @covers ::wp_filter_content_tags
    26232834         */
    26242835        function test_wp_filter_content_tags_width_height() {
    26252836                $image_meta = wp_get_attachment_metadata( self::$large_id );
     
    26652876        /**
    26662877         * @ticket 44427
    26672878         * @ticket 50367
     2879         *
     2880         * @covers ::wp_filter_content_tags
    26682881         */
    26692882        function test_wp_filter_content_tags_loading_lazy() {
    26702883                $image_meta = wp_get_attachment_metadata( self::$large_id );
     
    27132926
    27142927        /**
    27152928         * @ticket 44427
     2929         *
     2930         * @covers ::wp_filter_content_tags
    27162931         */
    27172932        function test_wp_filter_content_tags_loading_lazy_opted_in() {
    27182933                $img      = get_image_tag( self::$large_id, '', '', '', 'medium' );
     
    27382953
    27392954        /**
    27402955         * @ticket 44427
     2956         *
     2957         * @covers ::wp_filter_content_tags
    27412958         */
    27422959        function test_wp_filter_content_tags_loading_lazy_opted_out() {
    27432960                $img = get_image_tag( self::$large_id, '', '', '', 'medium' );
     
    27612978        /**
    27622979         * @ticket 44427
    27632980         * @ticket 50367
     2981         *
     2982         * @covers ::wp_img_tag_add_loading_attr
    27642983         */
    27652984        function test_wp_img_tag_add_loading_attr() {
    27662985                $img = '<img src="example.png" alt=" width="300" height="225" />';
     
    27722991        /**
    27732992         * @ticket 44427
    27742993         * @ticket 50367
     2994         *
     2995         * @covers ::wp_img_tag_add_loading_attr
    27752996         */
    27762997        function test_wp_img_tag_add_loading_attr_without_src() {
    27772998                $img = '<img alt=" width="300" height="225" />';
     
    27833004        /**
    27843005         * @ticket 44427
    27853006         * @ticket 50367
     3007         *
     3008         * @covers ::wp_img_tag_add_loading_attr
    27863009         */
    27873010        function test_wp_img_tag_add_loading_attr_with_single_quotes() {
    27883011                $img = "<img src='example.png' alt=' width='300' height='225' />";
     
    27983021        /**
    27993022         * @ticket 44427
    28003023         * @ticket 50425
     3024         *
     3025         * @covers ::wp_img_tag_add_loading_attr
    28013026         */
    28023027        function test_wp_img_tag_add_loading_attr_opt_out() {
    28033028                $img = '<img src="example.png" alt=" width="300" height="225" />';
     
    28093034        /**
    28103035         * @ticket 44427
    28113036         * @ticket 50425
     3037         *
     3038         * @covers ::wp_get_attachment_image
    28123039         */
    28133040        function test_wp_get_attachment_image_loading() {
    28143041                $img = wp_get_attachment_image( self::$large_id );
     
    28193046        /**
    28203047         * @ticket 44427
    28213048         * @ticket 50425
     3049         *
     3050         * @covers ::wp_get_attachment_image
    28223051         */
    28233052        function test_wp_get_attachment_image_loading_opt_out() {
    28243053                add_filter( 'wp_lazy_loading_enabled', '__return_false' );
     
    28313060        /**
    28323061         * @ticket 44427
    28333062         * @ticket 50425
     3063         *
     3064         * @covers ::wp_get_attachment_image
    28343065         */
    28353066        function test_wp_get_attachment_image_loading_opt_out_individual() {
    28363067                // The default is already tested above, the filter below ensures that
     
    28503081         *
    28513082         * @param string $tag_name Tag name.
    28523083         * @param bool   $expected Expected return value.
     3084         *
     3085         * @covers ::wp_lazy_loading_enabled
    28533086         */
    28543087        function test_wp_lazy_loading_enabled_tag_name_defaults( $tag_name, $expected ) {
    28553088                if ( $expected ) {
     
    28733106         *
    28743107         * @param string $context  Function context.
    28753108         * @param bool   $expected Expected return value.
     3109         *
     3110         * @covers ::wp_lazy_loading_enabled
    28763111         */
    28773112        function test_wp_lazy_loading_enabled_context_defaults( $context, $expected ) {
    28783113                if ( $expected ) {
     
    28953130
    28963131        /**
    28973132         * @ticket 50543
     3133         *
     3134         * @covers ::wp_image_file_matches_image_meta
    28983135         */
    28993136        function test_wp_image_file_matches_image_meta() {
    29003137                $image_meta       = wp_get_attachment_metadata( self::$large_id );
     
    29073144
    29083145        /**
    29093146         * @ticket 50543
     3147         *
     3148         * @covers ::wp_image_file_matches_image_meta
    29103149         */
    29113150        function test_wp_image_file_matches_image_meta_no_subsizes() {
    29123151                $image_meta = wp_get_attachment_metadata( self::$large_id );
     
    29193158
    29203159        /**
    29213160         * @ticket 50543
     3161         *
     3162         * @covers ::wp_image_file_matches_image_meta
    29223163         */
    29233164        function test_wp_image_file_matches_image_meta_invalid_meta() {
    29243165                $image_meta = ''; // Attachment is not an image.
     
    29293170
    29303171        /**
    29313172         * @ticket 50543
     3173         *
     3174         * @covers ::wp_image_file_matches_image_meta
    29323175         */
    29333176        function test_wp_image_file_matches_image_meta_different_meta() {
    29343177                $image_meta = wp_get_attachment_metadata( self::$large_id );
     
    29393182
    29403183        /**
    29413184         * @ticket 50543
     3185         *
     3186         * @covers ::wp_image_file_matches_image_meta
    29423187         */
    29433188        function test_wp_image_file_matches_image_meta_original_image() {
    29443189                $image_meta = wp_get_attachment_metadata( self::$large_id );
     
    29493194
    29503195        /**
    29513196         * @ticket 22101
     3197         *
     3198         * @covers ::gallery_shortcode
    29523199         */
    29533200        function test_gallery_shortcode_when_is_feed_true() {
    29543201
  • tests/phpunit/tests/meta.php

     
    1717                return 'sanitized';
    1818        }
    1919
     20        /**
     21         *
     22         * @covers ::sanitize_meta
     23         */
    2024        function test_sanitize_meta() {
    2125                $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' );
    2226                $this->assertEquals( 'unsanitized', $meta );
     
    2630                $this->assertEquals( 'sanitized', $meta );
    2731        }
    2832
     33        /**
     34         *
     35         * @covers ::delete_metadata_by_mid
     36         */
    2937        function test_delete_metadata_by_mid() {
    3038                // Let's try and delete a non-existing ID, non existing meta.
    3139                $this->assertFalse( delete_metadata_by_mid( 'user', 0 ) );
     
    4149                $this->assertFalse( (bool) get_user_meta( $this->author->ID, 'delete_meta_key' ) );
    4250        }
    4351
     52        /**
     53         *
     54         * @covers ::delete_metadata_by_mid
     55         */
    4456        function test_update_metadata_by_mid() {
    4557                // Setup.
    4658                $meta = get_metadata_by_mid( 'user', $this->meta_id );
     
    8092
    8193        /**
    8294         * @ticket 11683
     95         *
     96         * @covers ::add_metadata
    8397         */
    8498        public function test_update_metadata_hooks_for_multiple_updated_rows() {
    8599                add_metadata( 'post', 1, 'test_key', 'value_1' );
     
    104118                }
    105119        }
    106120
     121        /**
     122         *
     123         * @covers ::metadata_exists
     124         */
    107125        function test_metadata_exists() {
    108126                $this->assertFalse( metadata_exists( 'user', $this->author->ID, 'foobarbaz' ) );
    109127                $this->assertTrue( metadata_exists( 'user', $this->author->ID, 'meta_key' ) );
     
    113131
    114132        /**
    115133         * @ticket 22746
     134         *
     135         * @covers ::metadata_exists
    116136         */
    117137        function test_metadata_exists_with_filter() {
    118138                // Let's see if it returns the correct value when adding a filter.
     
    124144
    125145        /**
    126146         * @ticket 18158
     147         *
     148         * @covers ::get_users
    127149         */
    128150        function test_user_metadata_not_exists() {
    129151                $u = get_users(
     
    198220                );
    199221        }
    200222
     223        /**
     224         *
     225         * @covers ::get_metadata
     226         */
    201227        function test_metadata_slashes() {
    202228                $key       = __FUNCTION__;
    203229                $value     = 'Test\\singleslash';
     
    230256
    231257        /**
    232258         * @ticket 16814
     259         *
     260         * @covers ::add_post_meta
    233261         */
    234262        function test_meta_type_cast() {
    235263                $post_id1 = self::factory()->post->create();
     
    320348
    321349        /**
    322350         * @ticket 28315
     351         *
     352         * @covers ::add_post_meta
     353         * @covers ::update_metadata
     354         * @covers ::delete_metadata
     355         * @covers ::get_metadata
     356         * @covers ::metadata_exists
    323357         */
    324358        function test_non_numeric_object_id() {
    325359                $this->assertFalse( add_metadata( 'user', array( 1 ), 'meta_key', 'meta_value' ) );
     
    331365
    332366        /**
    333367         * @ticket 28315
     368         *
     369         * @covers ::add_post_meta
     370         * @covers ::update_metadata
     371         * @covers ::delete_metadata
    334372         */
    335373        function test_non_numeric_meta_id() {
    336374                $this->assertFalse( get_metadata_by_mid( 'user', array( 1 ) ) );
     
    340378
    341379        /**
    342380         * @ticket 37746
     381         *
     382         * @covers ::add_post_meta
     383         * @covers ::update_metadata
     384         * @covers ::delete_metadata
    343385         */
    344386        function test_negative_meta_id() {
    345387                $negative_mid = $this->meta_id * -1;
     
    352394
    353395        /**
    354396         * @ticket 37746
     397         *
     398         * @covers ::add_post_meta
     399         * @covers ::update_metadata
     400         * @covers ::delete_metadata
    355401         */
    356402        function test_floating_meta_id() {
    357403                $floating_mid = $this->meta_id + 0.1337;
     
    364410
    365411        /**
    366412         * @ticket 37746
     413         *
     414         * @covers ::add_post_meta
     415         * @covers ::update_metadata
     416         * @covers ::delete_metadata
    367417         */
    368418        function test_string_point_zero_meta_id() {
    369419                $meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value_2' );
     
    379429
    380430        /**
    381431         * @ticket 15030
     432         *
     433         * @covers ::get_metadata
    382434         */
    383435        public function test_get_metadata_with_empty_key_array_value() {
    384436                $data  = array( 1, 2 );
     
    391443
    392444        /**
    393445         * @ticket 15030
     446         *
     447         * @covers ::get_metadata
    394448         */
    395449        public function test_get_metadata_with_empty_key_object_value() {
    396450                $data      = new stdClass;
     
    404458
    405459        /**
    406460         * @ticket 15030
     461         *
     462         * @covers ::get_metadata
    407463         */
    408464        public function test_get_metadata_with_empty_key_nested_array_value() {
    409465                $data  = array(
  • tests/phpunit/tests/multisite.php

     
    2222                        $wpdb->suppress_errors( $this->suppress );
    2323                }
    2424
     25                /**
     26                 *
     27                 * @covers ::wpmu_log_new_registrations
     28                 */
    2529                function test_wpmu_log_new_registrations() {
    2630                        global $wpdb;
    2731
     
    3741
    3842                /**
    3943                 * @ticket 37392
     44                 *
     45                 * @covers ::wp_count_sites
    4046                 */
    4147                function test_wp_count_sites() {
    4248                        // Create a random number of sites with each status.
  • tests/phpunit/tests/pluggable.php

     
    1212         * @ticket 33867
    1313         *
    1414         * @dataProvider get_defined_pluggable_functions
     15         *
     16         * @coversNothing
    1517         */
    1618        public function test_pluggable_function_signatures_match( $function ) {
    1719
     
    5355         *
    5456         * @ticket 33654
    5557         * @ticket 33867
     58         *
     59         * @coversNothing
    5660         */
    5761        public function test_all_pluggable_functions_exist() {
    5862
  • tests/phpunit/tests/post.php

     
    5858
    5959        /**
    6060         * Test simple valid behavior: insert and get a post.
     61         *
     62         * @covers ::wp_insert_post
     63         * @covers ::wp_delete_post
    6164         */
    6265        function test_vb_insert_get_delete() {
    6366                register_post_type( 'cpt', array( 'taxonomies' => array( 'post_tag', 'ctax' ) ) );
     
    119122
    120123        /**
    121124         * Insert a post with a future date, and make sure the status and cron schedule are correct.
     125         *
     126         * @covers ::wp_insert_post
    122127         */
    123128        function test_vb_insert_future() {
    124129                $future_date = strtotime( '+1 day' );
     
    153158
    154159        /**
    155160         * Insert a post with a future date, and make sure the status and cron schedule are correct.
     161         *
     162         * @covers ::wp_insert_post
    156163         */
    157164        function test_vb_insert_future_over_dst() {
    158165                // Some magic days - one DST one not.
     
    199206         * Future post bug: posts get published at the wrong time if you edit the timestamp.
    200207         *
    201208         * @ticket 4710
     209         *
     210         * @covers ::wp_insert_post
    202211         */
    203212        function test_vb_insert_future_edit_bug() {
    204213                $future_date_1 = strtotime( '+1 day' );
     
    242251
    243252        /**
    244253         * Insert a draft post with a future date, and make sure no cron schedule is set.
     254         *
     255         * @covers ::wp_insert_post
    245256         */
    246257        function test_vb_insert_future_draft() {
    247258                $future_date = strtotime( '+1 day' );
     
    277288
    278289        /**
    279290         * Insert a future post, then edit and change it to draft, and make sure cron gets it right.
     291         *
     292         * @covers ::wp_insert_post
    280293         */
    281294        function test_vb_insert_future_change_to_draft() {
    282295                $future_date_1 = strtotime( '+1 day' );
     
    318331
    319332        /**
    320333         * Insert a future post, then edit and change the status, and make sure cron gets it right.
     334         *
     335         * @covers ::wp_insert_post
    321336         */
    322337        function test_vb_insert_future_change_status() {
    323338                $future_date_1 = strtotime( '+1 day' );
     
    363378
    364379        /**
    365380         * Insert a draft post with a future date, and make sure no cron schedule is set.
     381         *
     382         * @covers ::wp_insert_post
    366383         */
    367384        function test_vb_insert_future_private() {
    368385                $future_date = strtotime( '+1 day' );
     
    399416         * Insert a post with an invalid date, make sure it fails.
    400417         *
    401418         * @ticket 17180
     419         *
     420         * @covers ::wp_insert_post
    402421         */
    403422        function test_vb_insert_invalid_date() {
    404423                $post = array(
     
    420439
    421440        /**
    422441         * Insert a future post, then edit and change it to private, and make sure cron gets it right.
     442         *
     443         * @covers ::wp_insert_post
    423444         */
    424445        function test_vb_insert_future_change_to_private() {
    425446                $future_date_1 = strtotime( '+1 day' );
     
    461482
    462483        /**
    463484         * @ticket 5305
     485         *
     486         * @covers ::wp_insert_post
    464487         */
    465488        public function test_wp_insert_post_should_not_allow_a_bare_numeric_slug_that_might_conflict_with_a_date_archive_when_generating_from_an_empty_post_title() {
    466489                $this->set_permalink_structure( '/%postname%/' );
     
    484507        /**
    485508         * @ticket 5305
    486509         * @ticket 33392
     510         *
     511         * @covers ::wp_insert_post
    487512         */
    488513        public function test_wp_insert_post_should_invalidate_post_cache_before_generating_guid_when_post_name_is_empty_and_is_generated_from_the_post_ID() {
    489514                register_post_type( 'wptests_pt' );
     
    503528
    504529        /**
    505530         * @ticket 20451
     531         *
     532         * @covers ::wp_insert_post
    506533         */
    507534        public function test_wp_insert_post_with_meta_input() {
    508535                $post_id = wp_insert_post(
     
    526553         * "When I delete a future post using wp_delete_post( $post->ID ) it does not update the cron correctly."
    527554         *
    528555         * @ticket 5364
     556         *
     557         * @covers ::wp_insert_post
    529558         */
    530559        function test_delete_future_post_cron() {
    531560                $future_date = strtotime( '+1 day' );
     
    557586         * Might only fail if the post ID is greater than four characters.
    558587         *
    559588         * @ticket 5305
     589         *
     590         * @covers ::wp_insert_post
    560591         */
    561592        function test_permalink_without_title() {
    562593                $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     
    593624
    594625        /**
    595626         * @ticket 22944
     627         *
     628         * @covers ::wp_insert_post
    596629         */
    597630        function test_wp_insert_post_and_wp_publish_post_with_future_date() {
    598631                $future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 );
     
    616649
    617650        /**
    618651         * @ticket 48145
     652         *
     653         * @covers ::wp_insert_post
    619654         */
    620655        function test_wp_insert_post_should_default_to_publish_if_post_date_is_within_59_seconds_from_current_time() {
    621656                $future_date = gmdate( 'Y-m-d H:i:s', time() + 59 );
     
    632667
    633668        /**
    634669         * @ticket 22944
     670         *
     671         * @covers ::wp_insert_post
     672         * @covers ::wp_update_post
    635673         */
    636674        function test_publish_post_with_content_filtering() {
    637675                kses_remove_filters();
     
    657695
    658696        /**
    659697         * @ticket 22944
     698         *
     699         * @covers ::wp_insert_post
     700         * @covers ::wp_update_post
    660701         */
    661702        function test_wp_publish_post_and_avoid_content_filtering() {
    662703                kses_remove_filters();
     
    677718
    678719        /**
    679720         * @ticket 23708
     721         *
     722         * @covers ::get_post_ancestors
    680723         */
    681724        function test_get_post_ancestors_within_loop() {
    682725                global $post;
     
    687730
    688731        /**
    689732         * @ticket 23474
     733         *
     734         * @covers ::wp_insert_post
     735         * @covers ::wp_update_post
    690736         */
    691737        function test_update_invalid_post_id() {
    692738                $post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
     
    702748
    703749        }
    704750
     751        /**
     752         *
     753         * @covers ::setup_postdata
     754         */
    705755        function test_parse_post_content_single_page() {
    706756                global $multipage, $pages, $numpages;
    707757                $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
     
    713763                $this->assertEquals( array( 'Page 0' ), $pages );
    714764        }
    715765
     766        /**
     767         *
     768         * @covers ::setup_postdata
     769         */
    716770        function test_parse_post_content_multi_page() {
    717771                global $multipage, $pages, $numpages;
    718772                $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
     
    724778                $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages );
    725779        }
    726780
     781        /**
     782         *
     783         * @covers ::setup_postdata
     784         */
    727785        function test_parse_post_content_remaining_single_page() {
    728786                global $multipage, $pages, $numpages;
    729787                $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
     
    735793                $this->assertEquals( array( 'Page 0' ), $pages );
    736794        }
    737795
     796        /**
     797         *
     798         * @covers ::setup_postdata
     799         */
    738800        function test_parse_post_content_remaining_multi_page() {
    739801                global $multipage, $pages, $numpages;
    740802                $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
     
    748810
    749811        /**
    750812         * @ticket 16746
     813         *
     814         * @covers ::setup_postdata
    751815         */
    752816        function test_parse_post_content_starting_with_nextpage() {
    753817                global $multipage, $pages, $numpages;
     
    762826
    763827        /**
    764828         * @ticket 16746
     829         *
     830         * @covers ::setup_postdata
    765831         */
    766832        function test_parse_post_content_starting_with_nextpage_multi() {
    767833                global $multipage, $pages, $numpages;
     
    776842
    777843        /**
    778844         * @ticket 19373
     845         *
     846         * @covers ::wp_insert_post
    779847         */
    780848        function test_insert_programmatic_sanitized() {
    781849                $this->_unset_current_user();
     
    802870
    803871        /**
    804872         * @ticket 24803
     873         *
     874         * @covers ::wp_count_posts
    805875         */
    806876        function test_wp_count_posts() {
    807877                $post_type = rand_str( 20 );
     
    818888                $this->assertEquals( new stdClass, wp_count_posts( $post_type, 'readable' ) );
    819889        }
    820890
     891        /**
     892         *
     893         * @covers ::wp_count_posts
     894         */
    821895        function test_wp_count_posts_filtered() {
    822896                $post_type = rand_str( 20 );
    823897                register_post_type( $post_type );
     
    843917                return $counts;
    844918        }
    845919
     920        /**
     921         *
     922         * @covers ::wp_count_posts
     923         */
    846924        function test_wp_count_posts_insert_invalidation() {
    847925                $post_ids       = self::factory()->post->create_many( 3 );
    848926                $initial_counts = wp_count_posts();
     
    861939                $this->assertNotEquals( $initial_counts->publish, $after_draft_counts->publish );
    862940        }
    863941
     942        /**
     943         *
     944         * @covers ::wp_count_posts
     945         */
    864946        function test_wp_count_posts_trash_invalidation() {
    865947                $post_ids       = self::factory()->post->create_many( 3 );
    866948                $initial_counts = wp_count_posts();
     
    881963
    882964        /**
    883965         * @ticket 49685
     966         *
     967         * @covers ::wp_count_posts
    884968         */
    885969        function test_wp_count_posts_status_changes_visible() {
    886970                self::factory()->post->create_many( 3 );
     
    897981
    898982        /**
    899983         * @ticket 13771
     984         *
     985         * @covers ::get_the_date
    900986         */
    901987        function test_get_the_date_with_id_returns_correct_time() {
    902988                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     
    905991
    906992        /**
    907993         * @ticket 28310
     994         *
     995         * @covers ::get_the_date
    908996         */
    909997        function test_get_the_date_returns_false_with_null_or_non_existing_post() {
    910998                $this->assertFalse( get_the_date() );
     
    9151003
    9161004        /**
    9171005         * @ticket 28310
     1006         *
     1007         * @covers ::get_the_time
    9181008         */
    9191009        function test_get_the_time_with_id_returns_correct_time() {
    9201010                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     
    9231013
    9241014        /**
    9251015         * @ticket 28310
     1016         *
     1017         * @covers ::get_the_time
    9261018         */
    9271019        function test_get_the_time_returns_false_with_null_or_non_existing_post() {
    9281020                $this->assertFalse( get_the_time() );
     
    9331025
    9341026        /**
    9351027         * @ticket 28310
     1028         *
     1029         * @covers ::get_post_time
    9361030         */
    9371031        function test_get_post_time_with_id_returns_correct_time() {
    9381032                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     
    9411035
    9421036        /**
    9431037         * @ticket 28310
     1038         *
     1039         * @covers ::get_post_time
    9441040         */
    9451041        function test_get_post_time_returns_false_with_null_or_non_existing_post() {
    9461042                $this->assertFalse( get_post_time() );
     
    9511047
    9521048        /**
    9531049         * @ticket 28310
     1050         *
     1051         * @covers ::get_post_modified_time
    9541052         */
    9551053        function test_get_post_modified_time_with_id_returns_correct_time() {
    9561054                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     
    9591057
    9601058        /**
    9611059         * @ticket 28310
     1060         *
     1061         * @covers ::get_post_modified_time
    9621062         */
    9631063        function test_get_post_modified_time_returns_false_with_null_or_non_existing_post() {
    9641064                $this->assertFalse( get_post_modified_time() );
     
    9691069
    9701070        /**
    9711071         * @ticket 28310
     1072         *
     1073         * @covers ::mysql2date
    9721074         */
    9731075        function test_mysql2date_returns_false_with_no_date() {
    9741076                $this->assertFalse( mysql2date( 'F j, Y H:i:s', '' ) );
     
    9761078
    9771079        /**
    9781080         * @ticket 28310
     1081         *
     1082         * @covers ::mysql2date
    9791083         */
    9801084        function test_mysql2date_returns_gmt_or_unix_timestamp() {
    9811085                $this->assertEquals( '441013392', mysql2date( 'G', '1983-12-23 07:43:12' ) );
     
    9841088
    9851089        /**
    9861090         * @ticket 25566
     1091         *
     1092         * @covers ::wp_tag_cloud
    9871093         */
    9881094        function test_wp_tag_cloud_link_with_post_type() {
    9891095                $post_type = 'new_post_type';
     
    10171123
    10181124        /**
    10191125         * @ticket 21212
     1126         *
     1127         * @covers ::edit_post
    10201128         */
    10211129        function test_utf8mb3_post_saves_with_emoji() {
    10221130                global $wpdb;
     
    10531161
    10541162        /**
    10551163         * @ticket 31168
     1164         *
     1165         * @covers ::wp_insert_post
    10561166         */
    10571167        function test_wp_insert_post_default_comment_ping_status_open() {
    10581168                $post_id = self::factory()->post->create(
     
    10711181
    10721182        /**
    10731183         * @ticket 31168
     1184         *
     1185         * @covers ::wp_insert_post
    10741186         */
    10751187        function test_wp_insert_post_page_default_comment_ping_status_closed() {
    10761188                $post_id = self::factory()->post->create(
     
    10901202
    10911203        /**
    10921204         * @ticket 31168
     1205         *
     1206         * @covers ::wp_insert_post
    10931207         */
    10941208        function test_wp_insert_post_cpt_default_comment_ping_status_open() {
    10951209                $post_type = rand_str( 20 );
     
    11121226
    11131227        /**
    11141228         * @ticket 31168
     1229         *
     1230         * @covers ::wp_insert_post
    11151231         */
    11161232        function test_wp_insert_post_cpt_default_comment_ping_status_closed() {
    11171233                $post_type = rand_str( 20 );
     
    11371253         * it should _stay_ sticky.
    11381254         *
    11391255         * @ticket 24153
     1256         *
     1257         * @covers ::stick_post
    11401258         */
    11411259        function test_user_without_publish_cannot_affect_sticky() {
    11421260                wp_set_current_user( self::$grammarian_id );
     
    11751293         * the sticky status of the post should not be changed.
    11761294         *
    11771295         * @ticket 24153
     1296         *
     1297         * @covers ::stick_post
    11781298         */
    11791299        function test_user_without_publish_cannot_affect_sticky_with_edit_post() {
    11801300                // Create a sticky post.
     
    12151335         * Test that hooks are fired when post gets stuck and unstuck.
    12161336         *
    12171337         * @ticket 35600
     1338         *
     1339         * @covers ::stick_post
    12181340         */
    12191341        function test_hooks_fire_when_post_gets_stuck_and_unstuck() {
    12201342                $post_id = self::factory()->post->create();
     
    12431365         * a new slug should not be generated.
    12441366         *
    12451367         * @ticket 34865
     1368         *
     1369         * @covers ::wp_insert_post
    12461370         */
    12471371        function test_post_updates_without_slug_provided() {
    12481372                $post_id = self::factory()->post->create(
     
    12661390
    12671391        /**
    12681392         * @ticket 32585
     1393         *
     1394         * @covers ::wp_insert_post
    12691395         */
    12701396        public function test_wp_insert_post_author_zero() {
    12711397                $post_id = self::factory()->post->create( array( 'post_author' => 0 ) );
     
    12751401
    12761402        /**
    12771403         * @ticket 32585
     1404         *
     1405         * @covers ::wp_insert_post
    12781406         */
    12791407        public function test_wp_insert_post_author_null() {
    12801408                $post_id = self::factory()->post->create( array( 'post_author' => null ) );
     
    12841412
    12851413        /**
    12861414         * @ticket 15946
     1415         *
     1416         * @covers ::wp_insert_post
    12871417         */
    12881418        function test_wp_insert_post_should_respect_post_date_gmt() {
    12891419                $post = array(
     
    13061436                $this->assertEquals( $post['post_date_gmt'], $out->post_date_gmt );
    13071437        }
    13081438
     1439        /**
     1440         *
     1441         * @covers ::wp_delete_post
     1442         */
    13091443        function test_wp_delete_post_reassign_hierarchical_post_type() {
    13101444                $grandparent_page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    13111445                $parent_page_id      = self::factory()->post->create(
     
    13321466         *
    13331467         * @see _wp_customize_changeset_filter_insert_post_data()
    13341468         * @ticket 30937
     1469         *
     1470         * @covers ::wp_insert_post
    13351471         */
    13361472        function test_wp_insert_post_for_customize_changeset_should_not_drop_post_name() {
    13371473
     
    13851521         *
    13861522         * @see wp_unique_post_slug()
    13871523         * @ticket 21112
     1524         *
     1525         * @covers ::wp_insert_post
    13881526         */
    13891527        function test_pre_wp_unique_post_slug_filter() {
    13901528                add_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 );
     
    14081546
    14091547        /**
    14101548         * @ticket 48113
     1549         *
     1550         * @covers ::wp_insert_post
    14111551         */
    14121552        public function test_insert_post_should_respect_date_floating_post_status_arg() {
    14131553                register_post_status( 'floating', array( 'date_floating' => true ) );
     
    14261566
    14271567        /**
    14281568         * @ticket 48113
     1569         *
     1570         * @covers ::wp_insert_post
    14291571         */
    14301572        public function test_insert_post_should_respect_date_floating_post_status_arg_not_set() {
    14311573                register_post_status( 'not-floating', array( 'date_floating' => false ) );
     
    14501592         * and is different from the existing tags.
    14511593         *
    14521594         * @ticket 45121
     1595         *
     1596         * @covers ::wp_update_post
    14531597         */
    14541598        public function test_update_post_should_only_modify_post_tags_if_different_tags_input_was_provided() {
    14551599                $tag_1 = wp_insert_term( 'wp_update_post_tag', 'post_tag', array( 'slug' => 'wp_update_post_tag_1' ) );
  • tests/phpunit/tests/post/nav-menu.php

     
    679679        /**
    680680         * Test _wp_delete_customize_changeset_dependent_auto_drafts.
    681681         *
    682          * @covers ::_wp_delete_customize_changeset_dependent_auto_drafts()
     682         * @covers ::_wp_delete_customize_changeset_dependent_auto_drafts
    683683         */
    684684        function test_wp_delete_customize_changeset_dependent_auto_drafts() {
    685685                $auto_draft_post_id = $this->factory()->post->create(
  • tests/phpunit/tests/post/types.php

     
    6868
    6969        /**
    7070         * @ticket 35985
    71          * @covers ::register_post_type()
     71         * @covers ::register_post_type
    7272         */
    7373        function test_register_post_type_exclude_from_search_should_default_to_opposite_value_of_public() {
    7474                /*
     
    8282
    8383        /**
    8484         * @ticket 35985
    85          * @covers ::register_post_type()
     85         * @covers ::register_post_type
    8686         */
    8787        function test_register_post_type_publicly_queryable_should_default_to_value_of_public() {
    8888                /*
     
    9696
    9797        /**
    9898         * @ticket 35985
    99          * @covers ::register_post_type()
     99         * @covers ::register_post_type
    100100         */
    101101        function test_register_post_type_show_ui_should_default_to_value_of_public() {
    102102                /*
     
    110110
    111111        /**
    112112         * @ticket 35985
    113          * @covers ::register_post_type()
     113         * @covers ::register_post_type
    114114         */
    115115        function test_register_post_type_show_in_menu_should_default_to_value_of_show_ui() {
    116116                /*
     
    129129
    130130        /**
    131131         * @ticket 35985
    132          * @covers ::register_post_type()
     132         * @covers ::register_post_type
    133133         */
    134134        function test_register_post_type_show_in_nav_menus_should_default_to_value_of_public() {
    135135                /*
     
    143143
    144144        /**
    145145         * @ticket 35985
    146          * @covers ::register_post_type()
     146         * @covers ::register_post_type
    147147         */
    148148        function test_register_post_type_show_in_admin_bar_should_default_to_value_of_show_in_menu() {
    149149                /*
  • tests/phpunit/tests/query.php

     
    1111
    1212        /**
    1313         * @ticket 24785
     14         *
     15         * @covers WP_Query::reset_postdata
    1416         */
    1517        function test_nested_loop_reset_postdata() {
    1618                $post_id        = self::factory()->post->create();
     
    3133
    3234        /**
    3335         * @ticket 16471
     36         *
     37         * @covers WP_Query::get
    3438         */
    3539        function test_default_query_var() {
    3640                $query = new WP_Query;
     
    4145
    4246        /**
    4347         * @ticket 25380
     48         *
     49         * @covers WP_Query::get_posts
    4450         */
    4551        function test_pre_posts_per_page() {
    4652                self::factory()->post->create_many( 10 );
     
    5864
    5965        /**
    6066         * @ticket 26627
     67         *
     68         * @covers ::get_term_by
     69         * @covers ::get_query_var
     70         * @covers ::get_queried_object
    6171         */
    6272        function test_tag_queried_object() {
    6373                $slug = 'tag-slug-26627';
     
    8999
    90100        /**
    91101         * @ticket 31246
     102         *
     103         * @covers WP_Query::get_queried_object
    92104         */
    93105        public function test_get_queried_object_should_return_null_when_is_tax_is_true_but_the_taxonomy_args_have_been_removed_in_a_parse_query_callback() {
    94106                // Don't override the args provided below.
     
    125137
    126138        /**
    127139         * @ticket 37962
     140         *
     141         * @covers WP_Query::get_queried_object
    128142         */
    129143        public function test_get_queried_object_should_return_null_for_not_exists_tax_query() {
    130144                register_taxonomy( 'wptests_tax', 'post' );
     
    144158                $this->assertNull( $queried_object );
    145159        }
    146160
     161        /**
     162         *
     163         * @covers WP_Query::__construct
     164         */
    147165        public function test_orderby_space_separated() {
    148166                global $wpdb;
    149167
     
    157175                $this->assertContains( "ORDER BY $wpdb->posts.post_title DESC, $wpdb->posts.post_date DESC", $q->request );
    158176        }
    159177
     178        /**
     179         *
     180         * @covers ::wp_set_object_terms
     181         */
    160182        public function test_cat_querystring_single_term() {
    161183                $c1 = self::factory()->category->create(
    162184                        array(
     
    193215                $this->assertEqualSets( array( $p1, $p2 ), $matching_posts );
    194216        }
    195217
     218        /**
     219         *
     220         * @covers ::wp_set_object_terms
     221         */
    196222        public function test_category_querystring_multiple_terms_comma_separated() {
    197223                $c1 = self::factory()->category->create(
    198224                        array(
     
    239265
    240266        /**
    241267         * @ticket 33532
     268         *
     269         * @covers ::wp_set_object_terms
    242270         */
    243271        public function test_category_querystring_multiple_terms_formatted_as_array() {
    244272                $c1 = self::factory()->category->create(
     
    284312                $this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
    285313        }
    286314
    287 
     315        /**
     316         *
     317         * @covers ::wp_set_object_terms
     318         */
    288319        public function test_tag_querystring_single_term() {
    289320                $t1 = self::factory()->tag->create_and_get(
    290321                        array(
     
    321352                $this->assertEqualSets( array( $p1, $p2 ), $matching_posts );
    322353        }
    323354
     355        /**
     356         *
     357         * @covers ::wp_set_object_terms
     358         */
    324359        public function test_tag_querystring_multiple_terms_comma_separated() {
    325360                $c1 = self::factory()->tag->create_and_get(
    326361                        array(
     
    367402
    368403        /**
    369404         * @ticket 33532
     405         *
     406         * @covers WP_Query::get_posts
    370407         */
    371408        public function test_tag_querystring_multiple_terms_formatted_as_array() {
    372409                $c1 = self::factory()->tag->create_and_get(
     
    412449                $this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
    413450        }
    414451
     452        /**
     453         *
     454         * @covers WP_Query::get_posts
     455         */
    415456        public function test_custom_taxonomy_querystring_single_term() {
    416457                register_taxonomy( 'test_tax_cat', 'post' );
    417458
     
    439480                $this->assertEqualSets( array( $p1, $p2 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
    440481        }
    441482
     483        /**
     484         *
     485         * @covers WP_Query::get_posts
     486         */
    442487        public function test_custom_taxonomy_querystring_multiple_terms_comma_separated() {
    443488                register_taxonomy( 'test_tax_cat', 'post' );
    444489
     
    470515
    471516        /**
    472517         * @ticket 32454
     518         *
     519         * @covers WP_Query::get_posts
    473520         */
    474521        public function test_custom_taxonomy_querystring_multiple_terms_formatted_as_array() {
    475522                register_taxonomy( 'test_tax_cat', 'post' );
     
    502549
    503550        /**
    504551         * @ticket 31355
     552         *
     553         * @covers WP_Query::is_404
    505554         */
    506555        public function test_pages_dont_404_when_queried_post_id_is_modified() {
    507556                $post_id = self::factory()->post->create(
     
    524573
    525574        /**
    526575         * @ticket 31355
     576         *
     577         * @covers WP_Query::is_404
    527578         */
    528579        public function test_custom_hierarchical_post_types_404_when_queried_post_id_is_modified() {
    529580                global $wp_rewrite;
     
    561612
    562613        /**
    563614         * @ticket 34060
     615         *
     616         * @covers WP_Query::__construct
    564617         */
    565618        public function test_offset_0_should_override_page() {
    566619                $q = new WP_Query(
     
    576629
    577630        /**
    578631         * @ticket 34060
     632         *
     633         * @covers WP_Query::__construct
    579634         */
    580635        public function test_offset_should_be_ignored_when_not_set() {
    581636                $q = new WP_Query(
     
    590645
    591646        /**
    592647         * @ticket 34060
     648         *
     649         * @covers WP_Query::__construct
    593650         */
    594651        public function test_offset_should_be_ignored_when_passed_a_non_numeric_value() {
    595652                $q = new WP_Query(
     
    605662
    606663        /**
    607664         * @ticket 35601
     665         *
     666         * @covers WP_Query::__construct
    608667         */
    609668        public function test_comment_status() {
    610669                $p1 = self::factory()->post->create( array( 'comment_status' => 'open' ) );
     
    622681
    623682        /**
    624683         * @ticket 35601
     684         *
     685         * @covers WP_Query::__construct
    625686         */
    626687        public function test_ping_status() {
    627688                $p1 = self::factory()->post->create( array( 'ping_status' => 'open' ) );
     
    639700
    640701        /**
    641702         * @ticket 35619
     703         *
     704         * @covers ::get_queried_object
    642705         */
    643706        public function test_get_queried_object_should_return_first_of_multiple_terms() {
    644707                register_taxonomy( 'tax1', 'post' );
     
    669732
    670733        /**
    671734         * @ticket 35619
     735         *
     736         * @covers ::get_queried_object
    672737         */
    673738        public function test_query_vars_should_match_first_of_multiple_terms() {
    674739                register_taxonomy( 'tax1', 'post' );
  • tests/phpunit/tests/rest-api.php

     
    2929
    3030        /**
    3131         * Checks that the main classes are loaded.
     32         *
     33         * @covers WP_REST_Server::__construct
     34         * @covers WP_REST_Request::__construct
     35         * @covers WP_REST_Response::__construct
     36         * @covers WP_REST_Posts_Controller::__construct
    3237         */
    3338        function test_rest_api_active() {
    3439                $this->assertTrue( class_exists( 'WP_REST_Server' ) );
     
    4045        /**
    4146         * The rest_api_init hook should have been registered with init, and should
    4247         * have a default priority of 10.
     48         *
     49         * @covers ::rest_api_init
    4350         */
    4451        function test_init_action_added() {
    4552                $this->assertEquals( 10, has_action( 'init', 'rest_api_init' ) );
    4653        }
    4754
     55        /**
     56         * @covers ::create_initial_taxonomies
     57         */
    4858        public function test_add_extra_api_taxonomy_arguments() {
    4959                $taxonomy = get_taxonomy( 'category' );
    5060                $this->assertTrue( $taxonomy->show_in_rest );
     
    5767                $this->assertEquals( 'WP_REST_Terms_Controller', $taxonomy->rest_controller_class );
    5868        }
    5969
     70        /**
     71         * @covers ::create_initial_post_types
     72         */
    6073        public function test_add_extra_api_post_type_arguments() {
    6174                $post_type = get_post_type_object( 'post' );
    6275                $this->assertTrue( $post_type->show_in_rest );
     
    7891         * Check that a single route is canonicalized.
    7992         *
    8093         * Ensures that single and multiple routes are handled correctly.
     94         *
     95         * @covers ::register_rest_route
    8196         */
    8297        public function test_route_canonicalized() {
    8398                register_rest_route(
     
    114129         * Check that a single route is canonicalized.
    115130         *
    116131         * Ensures that single and multiple routes are handled correctly.
     132         *
     133         * @covers ::register_rest_route
    117134         */
    118135        public function test_route_canonicalized_multiple() {
    119136                register_rest_route(
     
    157174
    158175        /**
    159176         * Check that routes are merged by default.
     177         *
     178         * @covers ::register_rest_route
    160179         */
    161180        public function test_route_merge() {
    162181                register_rest_route(
     
    186205
    187206        /**
    188207         * Check that we can override routes.
     208         *
     209         * @covers ::register_rest_route
    189210         */
    190211        public function test_route_override() {
    191212                register_rest_route(
     
    224245         * Test that we reject routes without namespaces
    225246         *
    226247         * @expectedIncorrectUsage register_rest_route
     248         *
     249         * @covers ::register_rest_route
    227250         */
    228251        public function test_route_reject_empty_namespace() {
    229252                register_rest_route(
     
    244267         * Test that we reject empty routes
    245268         *
    246269         * @expectedIncorrectUsage register_rest_route
     270         *
     271         * @covers ::register_rest_route
    247272         */
    248273        public function test_route_reject_empty_route() {
    249274                register_rest_route(
     
    262287
    263288        /**
    264289         * The rest_route query variable should be registered.
     290         *
     291         * @covers ::rest_api_init
    265292         */
    266293        function test_rest_route_query_var() {
    267294                rest_api_init();
     
    268295                $this->assertTrue( in_array( 'rest_route', $GLOBALS['wp']->public_query_vars, true ) );
    269296        }
    270297
     298        /**
     299         * @covers ::register_rest_route
     300         */
    271301        public function test_route_method() {
    272302                register_rest_route(
    273303                        'test-ns',
     
    286316
    287317        /**
    288318         * The 'methods' arg should accept a single value as well as array.
     319         *
     320         * @covers ::register_rest_route
    289321         */
    290322        public function test_route_method_string() {
    291323                register_rest_route(
     
    305337
    306338        /**
    307339         * The 'methods' arg should accept a single value as well as array.
     340         *
     341         * @covers ::register_rest_route
    308342         */
    309343        public function test_route_method_array() {
    310344                register_rest_route(
     
    330364
    331365        /**
    332366         * The 'methods' arg should a comma-separated string.
     367         *
     368         * @covers ::register_rest_route
    333369         */
    334370        public function test_route_method_comma_separated() {
    335371                register_rest_route(
     
    353389                );
    354390        }
    355391
     392        /**
     393         * @covers ::register_rest_route
     394         */
    356395        public function test_options_request() {
    357396                register_rest_route(
    358397                        'test-ns',
     
    375414
    376415        /**
    377416         * Ensure that the OPTIONS handler doesn't kick in for non-OPTIONS requests.
     417         *
     418         * @covers ::rest_handle_options_request
    378419         */
    379420        public function test_options_request_not_options() {
    380421                register_rest_route(
     
    395436
    396437        /**
    397438         * Ensure that result fields are not allowed if no request['_fields'] is present.
     439         *
     440         * @covers ::rest_filter_response_fields
    398441         */
    399442        public function test_rest_filter_response_fields_no_request_filter() {
    400443                $response = new WP_REST_Response();
     
    407450
    408451        /**
    409452         * Ensure that result fields are allowed if request['_fields'] is present.
     453         *
     454         * @covers ::rest_filter_response_fields
    410455         */
    411456        public function test_rest_filter_response_fields_single_field_filter() {
    412457                $response = new WP_REST_Response();
     
    427472
    428473        /**
    429474         * Ensure that multiple comma-separated fields may be allowed with request['_fields'].
     475         *
     476         * @covers ::rest_filter_response_fields
    430477         */
    431478        public function test_rest_filter_response_fields_multi_field_filter() {
    432479                $response = new WP_REST_Response();
     
    458505        /**
    459506         * Ensure that multiple comma-separated fields may be allowed
    460507         * with request['_fields'] using query parameter array syntax.
     508         *
     509         * @covers ::rest_filter_response_fields
    461510         */
    462511        public function test_rest_filter_response_fields_multi_field_filter_array() {
    463512                $response = new WP_REST_Response();
     
    489538
    490539        /**
    491540         * Ensure that request['_fields'] allowed list apply to items in response collections.
     541         *
     542         * @covers ::rest_filter_response_fields
    492543         */
    493544        public function test_rest_filter_response_fields_numeric_array() {
    494545                $response = new WP_REST_Response();
     
    539590         * Ensure that nested fields may be allowed with request['_fields'].
    540591         *
    541592         * @ticket 42094
     593         *
     594         * @covers ::rest_filter_response_fields
    542595         */
    543596        public function test_rest_filter_response_fields_nested_field_filter() {
    544597                $response = new WP_REST_Response();
     
    580633         * Ensure inclusion of deeply nested fields may be controlled with request['_fields'].
    581634         *
    582635         * @ticket 49648
     636         *
     637         * @covers ::rest_filter_response_fields
    583638         */
    584639        public function test_rest_filter_response_fields_deeply_nested_field_filter() {
    585640                $response = new WP_REST_Response();
     
    622677         * Ensure that specifying a single top-level key in _fields includes that field and all children.
    623678         *
    624679         * @ticket 48266
     680         *
     681         * @covers ::rest_filter_response_fields
    625682         */
    626683        public function test_rest_filter_response_fields_top_level_key() {
    627684                $response = new WP_REST_Response();
     
    654711         * Ensure that a top-level key in _fields supersedes any specified children of that field.
    655712         *
    656713         * @ticket 48266
     714         *
     715         * @covers ::rest_filter_response_fields
    657716         */
    658717        public function test_rest_filter_response_fields_child_after_parent() {
    659718                $response = new WP_REST_Response();
     
    686745         * Ensure that specifying two sibling properties in _fields causes both to be included.
    687746         *
    688747         * @ticket 48266
     748         *
     749         * @covers ::rest_filter_response_fields
    689750         */
    690751        public function test_rest_filter_response_fields_include_all_specified_siblings() {
    691752                $response = new WP_REST_Response();
     
    716777
    717778        /**
    718779         * @ticket 42094
     780         *
     781         * @covers ::rest_is_field_included
    719782         */
    720783        public function test_rest_is_field_included() {
    721784                $fields = array(
     
    741804        /**
    742805         * The get_rest_url function should return a URL consistently terminated with a "/",
    743806         * whether the blog is configured with pretty permalink support or not.
     807         *
     808         * @covers ::get_rest_url
    744809         */
    745810        public function test_rest_url_generation() {
    746811                // In pretty permalinks case, we expect a path of wp-json/ with no query.
     
    758823
    759824        /**
    760825         * @ticket 34299
     826         *
     827         * @covers ::get_rest_url
    761828         */
    762829        public function test_rest_url_scheme() {
    763830                $_SERVER['SERVER_NAME'] = parse_url( home_url(), PHP_URL_HOST );
     
    799866
    800867        /**
    801868         * @ticket 42452
     869         *
     870         * @covers ::get_rest_url
    802871         */
    803872        public function test_always_prepend_path_with_slash_in_rest_url_filter() {
    804873                $filter = new MockAction();
     
    844913
    845914        /**
    846915         * @dataProvider jsonp_callback_provider
     916         *
     917         * @covers ::wp_check_jsonp_callback
    847918         */
    848919        public function test_jsonp_callback_check( $callback, $valid ) {
    849920                $this->assertEquals( $valid, wp_check_jsonp_callback( $callback ) );
     
    876947
    877948        /**
    878949         * @dataProvider rest_date_provider
     950         *
     951         * @covers ::rest_parse_date
    879952         */
    880953        public function test_rest_parse_date( $string, $value ) {
    881954                $this->assertEquals( $value, rest_parse_date( $string ) );
     
    908981
    909982        /**
    910983         * @dataProvider rest_date_force_utc_provider
     984         *
     985         * @covers ::rest_parse_date
    911986         */
    912987        public function test_rest_parse_date_force_utc( $string, $value ) {
    913988                $this->assertEquals( $value, rest_parse_date( $string, true ) );
     
    917992                return 'Spy_REST_Server';
    918993        }
    919994
     995        /**
     996         * @covers ::register_rest_route
     997         */
    920998        public function test_register_rest_route_without_server() {
    921999                $GLOBALS['wp_rest_server'] = null;
    9221000                add_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) );
     
    9351013                $this->assertEquals( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) );
    9361014        }
    9371015
     1016        /**
     1017         *
     1018         */
    9381019        function test_rest_preload_api_request_with_method() {
    9391020                $rest_server               = $GLOBALS['wp_rest_server'];
    9401021                $GLOBALS['wp_rest_server'] = null;
     
    9581039
    9591040        /**
    9601041         * @ticket 40614
     1042         *
     1043         * @covers ::rest_ensure_request
    9611044         */
    9621045        function test_rest_ensure_request_accepts_path_string() {
    9631046                $request = rest_ensure_request( '/wp/v2/posts' );
     
    9681051
    9691052        /**
    9701053         * @dataProvider _dp_rest_parse_embed_param
     1054         *
     1055         * @covers ::rest_parse_embed_param
    9711056         */
    9721057        public function test_rest_parse_embed_param( $expected, $embed ) {
    9731058                $this->assertEquals( $expected, rest_parse_embed_param( $embed ) );
     
    9971082         * @ticket 48819
    9981083         *
    9991084         * @dataProvider _dp_rest_filter_response_by_context
     1085         *
     1086         * @covers ::rest_filter_response_by_context
    10001087         */
    10011088        public function test_rest_filter_response_by_context( $schema, $data, $expected ) {
    10021089                $this->assertEquals( $expected, rest_filter_response_by_context( $data, $schema, 'view' ) );
     
    10041091
    10051092        /**
    10061093         * @ticket 49749
     1094         *
     1095         * @covers ::register_rest_route
    10071096         */
    10081097        public function test_register_route_with_invalid_namespace() {
    10091098                $this->setExpectedIncorrectUsage( 'register_rest_route' );
     
    10251114
    10261115        /**
    10271116         * @ticket 50075
     1117         *
     1118         * @covers ::register_rest_route
    10281119         */
    10291120        public function test_register_route_with_missing_permission_callback_top_level_route() {
    10301121                $this->setExpectedIncorrectUsage( 'register_rest_route' );
     
    10421133
    10431134        /**
    10441135         * @ticket 50075
     1136         *
     1137         * @covers ::register_rest_route
    10451138         */
    10461139        public function test_register_route_with_missing_permission_callback_single_wrapped_route() {
    10471140                $this->setExpectedIncorrectUsage( 'register_rest_route' );
     
    10621155
    10631156        /**
    10641157         * @ticket 50075
     1158         *
     1159         * @covers ::register_rest_route
    10651160         */
    10661161        public function test_register_route_with_missing_permission_callback_multiple_wrapped_route() {
    10671162                $this->setExpectedIncorrectUsage( 'register_rest_route' );
     
    15141609                );
    15151610        }
    15161611
     1612        /**
     1613         * @covers ::rest_ensure_response
     1614         */
    15171615        function test_rest_ensure_response_accepts_wp_error_and_returns_wp_error() {
    15181616                $response = rest_ensure_response( new WP_Error() );
    15191617                $this->assertInstanceOf( 'WP_Error', $response );
     
    15241622         *
    15251623         * @param mixed $response      The response passed to rest_ensure_response().
    15261624         * @param mixed $expected_data The expected data a response should include.
     1625         *
     1626         * @covers ::rest_ensure_response
    15271627         */
    15281628        function test_rest_ensure_response_returns_instance_of_wp_rest_response( $response, $expected_data ) {
    15291629                $response_object = rest_ensure_response( $response );
     
    15501650
    15511651        /**
    15521652         * @ticket 49116
     1653         *
     1654         * @covers ::rest_get_route_for_post
    15531655         */
    15541656        public function test_rest_get_route_for_post_non_post() {
    15551657                $this->assertEquals( '', rest_get_route_for_post( 'garbage' ) );
     
    15571659
    15581660        /**
    15591661         * @ticket 49116
     1662         *
     1663         * @covers ::rest_get_route_for_post
    15601664         */
    15611665        public function test_rest_get_route_for_post_invalid_post_type() {
    15621666                register_post_type( 'invalid' );
     
    15681672
    15691673        /**
    15701674         * @ticket 49116
     1675         *
     1676         * @covers ::rest_get_route_for_post
    15711677         */
    15721678        public function test_rest_get_route_for_post_non_rest() {
    15731679                $post = self::factory()->post->create_and_get( array( 'post_type' => 'custom_css' ) );
     
    15761682
    15771683        /**
    15781684         * @ticket 49116
     1685         *
     1686         * @covers ::rest_get_route_for_post
    15791687         */
    15801688        public function test_rest_get_route_for_post_custom_controller() {
    15811689                $post = self::factory()->post->create_and_get( array( 'post_type' => 'wp_block' ) );
     
    15841692
    15851693        /**
    15861694         * @ticket 49116
     1695         *
     1696         * @covers ::rest_get_route_for_post
    15871697         */
    15881698        public function test_rest_get_route_for_post() {
    15891699                $post = self::factory()->post->create_and_get();
     
    15921702
    15931703        /**
    15941704         * @ticket 49116
     1705         *
     1706         * @covers ::rest_get_route_for_post
    15951707         */
    15961708        public function test_rest_get_route_for_media() {
    15971709                $post = self::factory()->attachment->create_and_get();
     
    16001712
    16011713        /**
    16021714         * @ticket 49116
     1715         *
     1716         * @covers ::rest_get_route_for_post
    16031717         */
    16041718        public function test_rest_get_route_for_post_id() {
    16051719                $post = self::factory()->post->create_and_get();
     
    16081722
    16091723        /**
    16101724         * @ticket 49116
     1725         *
     1726         * @covers ::rest_get_route_for_term
    16111727         */
    16121728        public function test_rest_get_route_for_term_non_term() {
    16131729                $this->assertEquals( '', rest_get_route_for_term( 'garbage' ) );
     
    16151731
    16161732        /**
    16171733         * @ticket 49116
     1734         *
     1735         * @covers ::rest_get_route_for_term
    16181736         */
    16191737        public function test_rest_get_route_for_term_invalid_term_type() {
    16201738                register_taxonomy( 'invalid', 'post' );
     
    16261744
    16271745        /**
    16281746         * @ticket 49116
     1747         *
     1748         * @covers ::rest_get_route_for_term
    16291749         */
    16301750        public function test_rest_get_route_for_term_non_rest() {
    16311751                $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'post_format' ) );
     
    16341754
    16351755        /**
    16361756         * @ticket 49116
     1757         *
     1758         * @covers ::rest_get_route_for_term
    16371759         */
    16381760        public function test_rest_get_route_for_term() {
    16391761                $term = self::factory()->term->create_and_get();
     
    16421764
    16431765        /**
    16441766         * @ticket 49116
     1767         *
     1768         * @covers ::rest_get_route_for_term
    16451769         */
    16461770        public function test_rest_get_route_for_category() {
    16471771                $term = self::factory()->category->create_and_get();
     
    16501774
    16511775        /**
    16521776         * @ticket 49116
     1777         *
     1778         * @covers ::rest_get_route_for_term
    16531779         */
    16541780        public function test_rest_get_route_for_term_id() {
    16551781                $term = self::factory()->term->create_and_get();
     
    16631789         *
    16641790         * @param bool  $expected Expected result of the check.
    16651791         * @param mixed $value    The value to check.
     1792         *
     1793         * @covers ::rest_is_object
    16661794         */
    16671795        public function test_rest_is_object( $expected, $value ) {
    16681796                $is_object = rest_is_object( $value );
     
    17261854         *
    17271855         * @param array $expected Expected sanitized version.
    17281856         * @param mixed $value    The value to sanitize.
     1857         *
     1858         * @covers ::rest_sanitize_object
    17291859         */
    17301860        public function test_rest_sanitize_object( $expected, $value ) {
    17311861                $sanitized = rest_sanitize_object( $value );
     
    17841914         *
    17851915         * @param bool  $expected Expected result of the check.
    17861916         * @param mixed $value    The value to check.
     1917         *
     1918         * @covers ::rest_is_array
    17871919         */
    17881920        public function test_rest_is_array( $expected, $value ) {
    17891921                $is_array = rest_is_array( $value );
     
    18551987         *
    18561988         * @param array $expected Expected sanitized version.
    18571989         * @param mixed $value    The value to sanitize.
     1990         *
     1991         * @covers ::rest_sanitize_array
    18581992         */
    18591993        public function test_rest_sanitize_array( $expected, $value ) {
    18601994                $sanitized = rest_sanitize_array( $value );
     
    19262060         * @param string $expected The expected best type.
    19272061         * @param mixed  $value    The value to test.
    19282062         * @param array  $types    The list of available types.
     2063         *
     2064         * @covers ::rest_get_best_type_for_value
    19292065         */
    19302066        public function test_get_best_type_for_value( $expected, $value, $types ) {
    19312067                $this->assertEquals( $expected, rest_get_best_type_for_value( $value, $types ) );
  • tests/phpunit/tests/rewrite.php

     
    2727
    2828        /**
    2929         * @ticket 16840
     30         *
     31         * @covers ::add_rule
    3032         */
    3133        public function test_add_rule() {
    3234                global $wp_rewrite;
     
    4547
    4648        /**
    4749         * @ticket 16840
     50         *
     51         * @covers ::add_rule
    4852         */
    4953        public function test_add_rule_redirect_array() {
    5054                global $wp_rewrite;
     
    6973
    7074        /**
    7175         * @ticket 16840
     76         *
     77         * @covers ::add_rule
    7278         */
    7379        public function test_add_rule_top() {
    7480                global $wp_rewrite;
     
    8591                $this->assertContains( $redirect, $extra_rules_top[ $pattern ] );
    8692        }
    8793
     94        /**
     95         *
     96         * @covers ::url_to_postid
     97         */
    8898        function test_url_to_postid() {
    8999
    90100                $id = self::factory()->post->create();
     
    94104                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
    95105        }
    96106
     107        /**
     108         *
     109         * @covers ::url_to_postid
     110         * @covers ::set_url_scheme
     111         */
    97112        function test_url_to_postid_set_url_scheme_https_to_http() {
    98113                $post_id   = self::factory()->post->create();
    99114                $permalink = get_permalink( $post_id );
     
    104119                $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) );
    105120        }
    106121
     122        /**
     123         *
     124         * @covers ::url_to_postid
     125         * @covers ::set_url_scheme
     126         */
    107127        function test_url_to_postid_set_url_scheme_http_to_https() {
    108128                $_SERVER['HTTPS'] = 'on';
    109129
     
    123143         * @ticket 35531
    124144         * @group multisite
    125145         * @group ms-required
     146         *
     147         * @covers ::url_to_postid
    126148         */
    127149        function test_url_to_postid_of_http_site_when_current_site_uses_https() {
    128150                $_SERVER['HTTPS'] = 'on';
     
    170192                return $url;
    171193        }
    172194
     195        /**
     196         *
     197         * @covers ::url_to_postid
     198         */
    173199        function test_url_to_postid_custom_post_type() {
    174200                delete_option( 'rewrite_rules' );
    175201
     
    182208                _unregister_post_type( $post_type );
    183209        }
    184210
     211        /**
     212         *
     213         * @covers ::url_to_postid
     214         */
    185215        function test_url_to_postid_hierarchical() {
    186216
    187217                $parent_id = self::factory()->post->create(
     
    202232                $this->assertEquals( $child_id, url_to_postid( get_permalink( $child_id ) ) );
    203233        }
    204234
     235        /**
     236         *
     237         * @covers ::url_to_postid
     238         */
    205239        function test_url_to_postid_hierarchical_with_matching_leaves() {
    206240
    207241                $parent_id       = self::factory()->post->create(
     
    245279                $this->assertEquals( $grandchild_id_2, url_to_postid( get_permalink( $grandchild_id_2 ) ) );
    246280        }
    247281
     282        /**
     283         *
     284         * @covers ::url_to_postid
     285         */
    248286        function test_url_to_postid_home_has_path() {
    249287
    250288                update_option( 'home', home_url( '/example/' ) );
     
    270308
    271309        /**
    272310         * @ticket 30438
     311         *
     312         * @covers ::home_url
    273313         */
    274314        function test_parse_request_home_path() {
    275315                $home_url = home_url( '/path/' );
     
    290330
    291331        /**
    292332         * @ticket 30438
     333         *
     334         * @covers ::home_url
    293335         */
    294336        function test_parse_request_home_path_with_regex_character() {
    295337                $home_url       = home_url( '/ma.ch/' );
     
    327369
    328370        /**
    329371         * @ticket 30018
     372         *
     373         * @covers ::home_url
    330374         */
    331375        function test_parse_request_home_path_non_public_type() {
    332376                register_post_type( 'foo', array( 'public' => false ) );
     
    340384                $this->assertEquals( array(), $GLOBALS['wp']->query_vars );
    341385        }
    342386
     387        /**
     388         *
     389         * @covers ::url_to_postid
     390         */
    343391        function test_url_to_postid_dupe_path() {
    344392                update_option( 'home', home_url( '/example/' ) );
    345393
     
    359407
    360408        /**
    361409         * Reveals bug introduced in WP 3.0
     410         *
     411         * @covers ::url_to_postid
    362412         */
    363413        function test_url_to_postid_home_url_collision() {
    364414                update_option( 'home', home_url( '/example' ) );
     
    380430         * Reveals bug introduced in WP 3.0
    381431         *
    382432         * @group ms-required
     433         *
     434         * @covers ::network_home_url
    383435         */
    384436        function test_url_to_postid_ms_home_url_collision() {
    385437                $blog_id = self::factory()->blog->create( array( 'path' => '/example' ) );
     
    401453
    402454        /**
    403455         * @ticket 21970
     456         *
     457         * @covers ::url_to_postid
    404458         */
    405459        function test_url_to_postid_with_post_slug_that_clashes_with_a_trashed_page() {
    406460                $this->set_permalink_structure( '/%postname%/' );
     
    418472
    419473        /**
    420474         * @ticket 34971
     475         *
     476         * @covers ::url_to_postid
    421477         */
    422478        function test_url_to_postid_static_front_page() {
    423479                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
     
    438494
    439495        /**
    440496         * @ticket 39373
     497         *
     498         * @covers ::url_to_postid
    441499         */
    442500        public function test_url_to_postid_should_bail_when_host_does_not_match() {
    443501                $this->set_permalink_structure( '/%postname%/' );
     
    452510
    453511        /**
    454512         * @ticket 21970
     513         *
     514         * @covers ::get_permalink
    455515         */
    456516        function test_parse_request_with_post_slug_that_clashes_with_a_trashed_page() {
    457517                $this->set_permalink_structure( '/%postname%/' );
     
    472532
    473533        /**
    474534         * @ticket 29107
     535         *
     536         * @covers ::flush_rules
    475537         */
    476538        public function test_flush_rules_does_not_delete_option() {
    477539                $this->set_permalink_structure( '' );
  • tests/phpunit/tests/shortcode.php

     
    9595                return $out;
    9696        }
    9797
     98        /**
     99         *
     100         * @covers ::do_shortcode
     101         */
    98102        function test_noatts() {
    99103                do_shortcode( '[test-shortcode-tag /]' );
    100104                $this->assertEquals( '', $this->atts );
     
    101105                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    102106        }
    103107
     108        /**
     109         *
     110         * @covers ::do_shortcode
     111         */
    104112        function test_one_att() {
    105113                do_shortcode( '[test-shortcode-tag foo="asdf" /]' );
    106114                $this->assertEquals( array( 'foo' => 'asdf' ), $this->atts );
     
    107115                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    108116        }
    109117
     118        /**
     119         *
     120         * @covers ::do_shortcode
     121         */
    110122        function test_not_a_tag() {
    111123                $out = do_shortcode( '[not-a-shortcode-tag]' );
    112124                $this->assertEquals( '[not-a-shortcode-tag]', $out );
     
    114126
    115127        /**
    116128         * @ticket 17657
     129         *
     130         * @covers ::do_shortcode
    117131         */
    118132        function test_tag_hyphen_not_tag() {
    119133                $out = do_shortcode( '[dumptag-notreal]' );
     
    120134                $this->assertEquals( '[dumptag-notreal]', $out );
    121135        }
    122136
     137        /**
     138         *
     139         * @covers ::do_shortcode
     140         */
    123141        function test_tag_underscore_not_tag() {
    124142                $out = do_shortcode( '[dumptag_notreal]' );
    125143                $this->assertEquals( '[dumptag_notreal]', $out );
    126144        }
    127145
     146        /**
     147         *
     148         * @covers ::do_shortcode
     149         */
    128150        function test_tag_not_tag() {
    129151                $out = do_shortcode( '[dumptagnotreal]' );
    130152                $this->assertEquals( '[dumptagnotreal]', $out );
     
    132154
    133155        /**
    134156         * @ticket 17657
     157         *
     158         * @covers ::do_shortcode
    135159         */
    136160        function test_tag_hyphen() {
    137161                $this->assertEquals( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) );
     
    143167
    144168        /**
    145169         * @ticket 9405
     170         *
     171         * @covers ::do_shortcode
    146172         */
    147173        function test_attr_hyphen() {
    148174                do_shortcode( '[test-shortcode-tag foo="foo" foo-bar="foo-bar" foo-bar-="foo-bar-" -foo-bar="-foo-bar" -foo-bar-="-foo-bar-" foo-bar-baz="foo-bar-baz" -foo-bar-baz="-foo-bar-baz" foo--bar="foo--bar" /]' );
     
    159185                $this->assertEquals( $expected_attrs, $this->atts );
    160186        }
    161187
     188        /**
     189         *
     190         * @covers ::do_shortcode
     191         */
    162192        function test_two_atts() {
    163193                do_shortcode( '[test-shortcode-tag foo="asdf" bar="bing" /]' );
    164194                $this->assertEquals(
     
    171201                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    172202        }
    173203
     204        /**
     205         *
     206         * @covers ::do_shortcode
     207         */
    174208        function test_noatts_enclosing() {
    175209                do_shortcode( '[test-shortcode-tag]content[/test-shortcode-tag]' );
    176210                $this->assertEquals( '', $this->atts );
     
    178212                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    179213        }
    180214
     215        /**
     216         *
     217         * @covers ::do_shortcode
     218         */
    181219        function test_one_att_enclosing() {
    182220                do_shortcode( '[test-shortcode-tag foo="bar"]content[/test-shortcode-tag]' );
    183221                $this->assertEquals( array( 'foo' => 'bar' ), $this->atts );
     
    185223                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    186224        }
    187225
     226        /**
     227         *
     228         * @covers ::do_shortcode
     229         */
    188230        function test_two_atts_enclosing() {
    189231                do_shortcode( '[test-shortcode-tag foo="bar" baz="bing"]content[/test-shortcode-tag]' );
    190232                $this->assertEquals(
     
    198240                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    199241        }
    200242
     243        /**
     244         *
     245         * @covers ::do_shortcode
     246         */
    201247        function test_unclosed() {
    202248                $out = do_shortcode( '[test-shortcode-tag]' );
    203249                $this->assertEquals( '', $out );
     
    205251                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    206252        }
    207253
     254        /**
     255         *
     256         * @covers ::do_shortcode
     257         */
    208258        function test_positional_atts_num() {
    209259                $out = do_shortcode( '[test-shortcode-tag 123]' );
    210260                $this->assertEquals( '', $out );
     
    212262                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    213263        }
    214264
     265        /**
     266         *
     267         * @covers ::do_shortcode
     268         */
    215269        function test_positional_atts_url() {
    216270                $out = do_shortcode( '[test-shortcode-tag http://www.youtube.com/watch?v=eBGIQ7ZuuiU]' );
    217271                $this->assertEquals( '', $out );
     
    219273                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    220274        }
    221275
     276        /**
     277         *
     278         * @covers ::do_shortcode
     279         */
    222280        function test_positional_atts_quotes() {
    223281                $out = do_shortcode( '[test-shortcode-tag "something in quotes" "something else"]' );
    224282                $this->assertEquals( '', $out );
     
    232290                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    233291        }
    234292
     293        /**
     294         *
     295         * @covers ::do_shortcode
     296         */
    235297        function test_positional_atts_mixed() {
    236298                $out = do_shortcode( '[test-shortcode-tag 123 https://wordpress.org/ 0 "foo" bar]' );
    237299                $this->assertEquals( '', $out );
     
    248310                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    249311        }
    250312
     313        /**
     314         *
     315         * @covers ::do_shortcode
     316         */
    251317        function test_positional_and_named_atts() {
    252318                $out = do_shortcode( '[test-shortcode-tag 123 url=https://wordpress.org/ foo bar="baz"]' );
    253319                $this->assertEquals( '', $out );
     
    263329                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    264330        }
    265331
     332        /**
     333         *
     334         * @covers ::do_shortcode
     335         */
    266336        function test_footag_default() {
    267337                $out = do_shortcode( '[footag]' );
    268338                $this->assertEquals( 'foo = ', $out );
    269339        }
    270340
     341        /**
     342         *
     343         * @covers ::do_shortcode
     344         */
    271345        function test_footag_val() {
    272346                $val = rand_str();
    273347                $out = do_shortcode( '[footag foo="' . $val . '"]' );
     
    274348                $this->assertEquals( 'foo = ' . $val, $out );
    275349        }
    276350
     351        /**
     352         *
     353         * @covers ::do_shortcode
     354         */
    277355        function test_nested_tags() {
    278356                $out      = do_shortcode( '[baztag][dumptag abc="foo" def=123 https://wordpress.org/][/baztag]' );
    279357                $expected = "content = abc = foo\ndef = 123\n0 = https://wordpress.org\n";
     
    282360
    283361        /**
    284362         * @ticket 6518
     363         *
     364         * @covers ::do_shortcode
    285365         */
    286366        function test_tag_escaped() {
    287367                $out = do_shortcode( '[[footag]] [[bartag foo="bar"]]' );
     
    298378                $this->assertEquals( '[[footag]] [[bartag foo="bar"]]', $out );
    299379        }
    300380
     381        /**
     382         *
     383         * @covers ::do_shortcode
     384         */
    301385        function test_tag_not_escaped() {
    302386                // These have square brackets on either end but aren't actually escaped.
    303387                $out = do_shortcode( '[[footag] [bartag foo="bar"]]' );
     
    316400                $this->assertEquals( '[[foo =  foo = bar]]', $out );
    317401        }
    318402
     403        /**
     404         *
     405         * @covers ::do_shortcode
     406         */
    319407        function test_mixed_tags() {
    320408                $in       = <<<EOF
    321409So this is a post with [footag foo="some stuff"] and a bunch of tags.
     
    355443
    356444        /**
    357445         * @ticket 6562
     446         *
     447         * @covers ::do_shortcode
    358448         */
    359449        function test_utf8_whitespace_1() {
    360450                // NO-BREAK SPACE: U+00A0.
     
    371461
    372462        /**
    373463         * @ticket 6562
     464         *
     465         * @covers ::do_shortcode
    374466         */
    375467        function test_utf8_whitespace_2() {
    376468                // ZERO WIDTH SPACE: U+200B.
     
    387479
    388480        /**
    389481         * @ticket 14050
     482         *
     483         * @covers ::shortcode_unautop
    390484         */
    391485        function test_shortcode_unautop() {
    392486                // A blank line is added at the end, so test with it already there.
     
    416510         *
    417511         * @param string $expected  Expected output.
    418512         * @param string $content   Content to run strip_shortcodes() on.
     513         *
     514         * @covers ::strip_shortcodes
    419515         */
    420516        function test_strip_shortcodes( $expected, $content ) {
    421517                $this->assertEquals( $expected, strip_shortcodes( $content ) );
     
    458554                return $out;
    459555        }
    460556
     557        /**
     558         *
     559         * @covers ::do_shortcode
     560         */
    461561        function test_shortcode_atts_filter_passes_original_arguments() {
    462562                add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 );
    463563
     
    481581                remove_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 );
    482582        }
    483583
     584        /**
     585         *
     586         * @covers ::do_shortcode
     587         */
    484588        function test_shortcode_atts_filtering() {
    485589                add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts2' ), 10, 3 );
    486590
     
    498602         * Check that shortcode_unautop() will always recognize spaces around shortcodes.
    499603         *
    500604         * @ticket 22692
     605         *
     606         * @covers ::shortcode_unautop
    501607         */
    502608        function test_spaces_around_shortcodes() {
    503609                $nbsp = "\xC2\xA0";
     
    520626         * Check for bugginess using normal input with latest patches.
    521627         *
    522628         * @dataProvider data_escaping
     629         *
     630         * @covers ::do_shortcode
    523631         */
    524632        function test_escaping( $input, $output ) {
    525633                return $this->assertEquals( $output, do_shortcode( $input ) );
     
    598706         * Check for bugginess using normal input with latest patches.
    599707         *
    600708         * @dataProvider data_escaping2
     709         *
     710         * @covers ::strip_shortcodes
    601711         */
    602712        function test_escaping2( $input, $output ) {
    603713                return $this->assertEquals( $output, strip_shortcodes( $input ) );
     
    638748
    639749        /**
    640750         * @ticket 26343
     751         *
     752         * @covers ::has_shortcode
    641753         */
    642754        function test_has_shortcode() {
    643755                $content = 'This is a blob with [gallery] in it';
     
    654766         *
    655767         * @dataProvider data_registration_bad
    656768         * @expectedIncorrectUsage add_shortcode
     769         *
     770         * @covers ::shortcode_exists
    657771         */
    658772        function test_registration_bad( $input, $expected ) {
    659773                return $this->sub_registration( $input, $expected );
     
    663777         * Make sure valid shortcode names are allowed.
    664778         *
    665779         * @dataProvider data_registration_good
     780         *
     781         * @covers ::shortcode_exists
    666782         */
    667783        function test_registration_good( $input, $expected ) {
    668784                return $this->sub_registration( $input, $expected );
     
    732848         * Automated performance testing of the main regex.
    733849         *
    734850         * @dataProvider data_whole_posts
     851         *
     852         * @covers ::get_shortcode_regex
    735853         */
    736854        function test_pcre_performance( $input ) {
    737855                $regex  = '/' . get_shortcode_regex() . '/';
     
    744862                return data_whole_posts();
    745863        }
    746864
     865        /**
     866         *
     867         * @covers ::get_shortcode_regex
     868         */
    747869        function test_php_and_js_shortcode_attribute_regexes_match() {
    748870
    749871                $file    = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' );
     
    761883         * @ticket 34939
    762884         *
    763885         * Test the (not recommended) [shortcode=XXX] format
     886         *
     887         * @covers ::do_shortcode
    764888         */
    765889        function test_unnamed_attribute() {
    766890                $out      = do_shortcode( '[dumptag=https://wordpress.org/]' );
     
    770894
    771895        /**
    772896         * @ticket 36306
     897         *
     898         * @covers ::the_content
    773899         */
    774900        function test_smilies_arent_converted() {
    775901                $out      = apply_filters( 'the_content', '[img alt="Hello :-) World"]' );
     
    779905
    780906        /**
    781907         * @ticket 37906
     908         *
     909         * @covers ::do_shortcode
    782910         */
    783911        public function test_pre_do_shortcode_tag() {
    784912                // Does nothing if no filters are set up.
     
    849977
    850978        /**
    851979         * @ticket 32790
     980         *
     981         * @covers ::do_shortcode
    852982         */
    853983        public function test_do_shortcode_tag_filter() {
    854984                // Does nothing if no filters are set up.
     
    9211051         * @ticket 37304
    9221052         *
    9231053         * Test 'value' syntax for empty attributes
     1054         *
     1055         * @covers ::do_shortcode
    9241056         */
    9251057        function test_empty_single_quote_attribute() {
    9261058                $out = do_shortcode( '[test-shortcode-tag a="foo" b=\'bar\' c=baz foo \'bar\' "baz" ]test empty atts[/test-shortcode-tag]' );
     
    9391071
    9401072        /**
    9411073         * @ticket 37304
     1074         *
     1075         * @covers ::do_shortcode
    9421076         */
    9431077        function test_positional_atts_single_quotes() {
    9441078                $out = do_shortcode( "[test-shortcode-tag 'something in quotes' 'something else']" );
     
    9551089
    9561090        /**
    9571091         * @ticket 37304
     1092         *
     1093         * @covers ::do_shortcode
    9581094         */
    9591095        function test_positional_atts_mixed_quotes() {
    9601096                $out = do_shortcode( "[test-shortcode-tag 'something in quotes' \"something else\" 123 foo bar='baz' example=\"test\" ]" );
  • tests/phpunit/tests/site-health.php

     
    1313         * Ensure Site Health reports correctly cron job reports.
    1414         *
    1515         * @ticket 47223
     16         *
     17         * @covers WP_Site_Health::get_test_scheduled_events
    1618         */
    1719        function test_cron_health_checks_critical() {
    1820                $wp_site_health = new WP_Site_Health();
     
    3335         *
    3436         * @dataProvider data_cron_health_checks
    3537         * @ticket 47223
     38         *
     39         * @covers WP_Site_Health::get_test_scheduled_events
    3640         */
    3741        function test_cron_health_checks( $times, $expected_status, $expected_label, $expected_late, $expected_missed ) {
    3842                $wp_site_health = new WP_Site_Health();
  • tests/phpunit/tests/taxonomy.php

     
    44 * @group taxonomy
    55 */
    66class Tests_Taxonomy extends WP_UnitTestCase {
     7
     8        /**
     9         *
     10         * @covers ::get_object_taxonomies
     11         */
    712        function test_get_post_taxonomies() {
    813                $this->assertEquals( array( 'category', 'post_tag', 'post_format' ), get_object_taxonomies( 'post' ) );
    914        }
    1015
     16        /**
     17         *
     18         * @covers ::get_object_taxonomies
     19         */
    1120        function test_get_link_taxonomies() {
    1221                $this->assertEquals( array( 'link_category' ), get_object_taxonomies( 'link' ) );
    1322        }
     
    1423
    1524        /**
    1625         * @ticket 5417
     26         *
     27         * @covers ::get_object_taxonomies
    1728         */
    1829        function test_get_unknown_taxonomies() {
    1930                // Taxonomies for an unknown object type.
     
    2334                $this->assertEquals( array(), get_object_taxonomies( null ) );
    2435        }
    2536
     37        /**
     38         *
     39         * @covers ::get_object_taxonomies
     40         */
    2641        function test_get_post_taxonomy() {
    2742                foreach ( get_object_taxonomies( 'post' ) as $taxonomy ) {
    2843                        $tax = get_taxonomy( $taxonomy );
     
    3348                }
    3449        }
    3550
     51        /**
     52         *
     53         * @covers ::get_the_taxonomies
     54         */
    3655        function test_get_the_taxonomies() {
    3756                $post_id = self::factory()->post->create();
    3857
     
    5170
    5271        /**
    5372         * @ticket 27238
     73         *
     74         * @covers ::get_the_taxonomies
    5475         */
    5576        public function test_get_the_taxonomies_term_template() {
    5677                $post_id = self::factory()->post->create();
     
    6384                $this->assertEquals( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $taxes['category'] );
    6485        }
    6586
     87        /**
     88         *
     89         * @covers ::the_taxonomies
     90         */
    6691        function test_the_taxonomies() {
    6792                $post_id = self::factory()->post->create();
    6893
     
    77102
    78103        /**
    79104         * @ticket 27238
     105         *
     106         * @covers ::get_category_link
    80107         */
    81108        function test_the_taxonomies_term_template() {
    82109                $post_id = self::factory()->post->create();
     
    105132                $this->assertEquals( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $output );
    106133        }
    107134
     135        /**
     136         *
     137         * @covers ::create_initial_taxonomies
     138         */
    108139        function test_get_link_taxonomy() {
    109140                foreach ( get_object_taxonomies( 'link' ) as $taxonomy ) {
    110141                        $tax = get_taxonomy( $taxonomy );
     
    115146                }
    116147        }
    117148
     149        /**
     150         *
     151         * @covers ::create_initial_taxonomies
     152         * @covers ::taxonomy_exists
     153         */
    118154        function test_taxonomy_exists_known() {
    119155                $this->assertTrue( taxonomy_exists( 'category' ) );
    120156                $this->assertTrue( taxonomy_exists( 'post_tag' ) );
     
    121157                $this->assertTrue( taxonomy_exists( 'link_category' ) );
    122158        }
    123159
     160        /**
     161         *
     162         * @covers ::create_initial_taxonomies
     163         * @covers ::taxonomy_exists
     164         */
    124165        function test_taxonomy_exists_unknown() {
    125166                $this->assertFalse( taxonomy_exists( rand_str() ) );
    126167                $this->assertFalse( taxonomy_exists( '' ) );
     
    128169                $this->assertFalse( taxonomy_exists( null ) );
    129170        }
    130171
     172        /**
     173         *
     174         * @covers ::create_initial_taxonomies
     175         * @covers ::is_taxonomy_hierarchical
     176         */
    131177        function test_is_taxonomy_hierarchical() {
    132178                $this->assertTrue( is_taxonomy_hierarchical( 'category' ) );
    133179                $this->assertFalse( is_taxonomy_hierarchical( 'post_tag' ) );
     
    134180                $this->assertFalse( is_taxonomy_hierarchical( 'link_category' ) );
    135181        }
    136182
     183        /**
     184         *
     185         * @covers ::create_initial_taxonomies
     186         * @covers ::is_taxonomy_hierarchical
     187         */
    137188        function test_is_taxonomy_hierarchical_unknown() {
    138189                $this->assertFalse( is_taxonomy_hierarchical( rand_str() ) );
    139190                $this->assertFalse( is_taxonomy_hierarchical( '' ) );
     
    141192                $this->assertFalse( is_taxonomy_hierarchical( null ) );
    142193        }
    143194
     195        /**
     196         *
     197         * @covers ::register_taxonomy
     198         */
    144199        function test_register_taxonomy() {
    145200
    146201                // Make up a new taxonomy name, and ensure it's unused.
     
    155210                unset( $GLOBALS['wp_taxonomies'][ $tax ] );
    156211        }
    157212
     213        /**
     214         *
     215         * @covers ::register_taxonomy
     216         */
    158217        function test_register_hierarchical_taxonomy() {
    159218
    160219                // Make up a new taxonomy name, and ensure it's unused.
     
    171230
    172231        /**
    173232         * @ticket 48558
     233         *
     234         * @covers ::register_taxonomy
    174235         */
    175236        function test_register_taxonomy_return_value() {
    176237                $this->assertInstanceOf( 'WP_Taxonomy', register_taxonomy( 'foo', 'post' ) );
     
    180241         * @ticket 21593
    181242         *
    182243         * @expectedIncorrectUsage register_taxonomy
     244         *
     245         * @covers ::register_taxonomy
    183246         */
    184247        function test_register_taxonomy_with_too_long_name() {
    185248                $this->assertInstanceOf( 'WP_Error', register_taxonomy( 'abcdefghijklmnopqrstuvwxyz0123456789', 'post', array() ) );
     
    189252         * @ticket 31135
    190253         *
    191254         * @expectedIncorrectUsage register_taxonomy
     255         *
     256         * @covers ::register_taxonomy
    192257         */
    193258        function test_register_taxonomy_with_empty_name() {
    194259                $this->assertInstanceOf( 'WP_Error', register_taxonomy( '', 'post', array() ) );
     
    196261
    197262        /**
    198263         * @ticket 26948
     264         *
     265         * @covers ::register_taxonomy
    199266         */
    200267        public function test_register_taxonomy_show_in_quick_edit_should_default_to_value_of_show_ui() {
    201268                register_taxonomy(
     
    223290
    224291        /**
    225292         * @ticket 11058
     293         *
     294         * @covers ::register_taxonomy
    226295         */
    227296        function test_registering_taxonomies_to_object_types() {
    228297                // Create a taxonomy to test with.
     
    272341
    273342        /**
    274343         * @ticket 32590
     344         *
     345         * @covers ::register_taxonomy
    275346         */
    276347        public function test_register_taxonomy_for_post_type_for_taxonomy_with_no_object_type_should_filter_out_empty_object_types() {
    277348                register_taxonomy( 'wptests_tax', '' );
     
    282353                $this->assertEqualSets( $expected, $tax->object_type );
    283354        }
    284355
     356        /**
     357         *
     358         * @covers ::get_objects_in_term
     359         */
    285360        public function test_get_objects_in_term_should_return_invalid_taxonomy_error() {
    286361                $terms = get_objects_in_term( 1, 'invalid_taxonomy' );
    287362                $this->assertInstanceOf( 'WP_Error', $terms );
     
    288363                $this->assertEquals( 'invalid_taxonomy', $terms->get_error_code() );
    289364        }
    290365
     366        /**
     367         *
     368         * @covers ::get_objects_in_term
     369         */
    291370        public function test_get_objects_in_term_should_return_empty_array() {
    292371                $this->assertEquals( array(), get_objects_in_term( 1, 'post_tag' ) );
    293372        }
    294373
     374        /**
     375         *
     376         * @covers ::get_objects_in_term
     377         */
    295378        public function test_get_objects_in_term_should_return_objects_ids() {
    296379                $tag_id              = self::factory()->tag->create();
    297380                $cat_id              = self::factory()->category->create();
     
    324407
    325408        /**
    326409         * @ticket 37094
     410         *
     411         * @covers ::wp_set_object_terms
    327412         */
    328413        public function test_term_assignment_should_invalidate_get_objects_in_term_cache() {
    329414                register_taxonomy( 'wptests_tax', 'post' );
     
    349434
    350435        /**
    351436         * @ticket 37094
     437         *
     438         * @covers ::wp_delete_term
    352439         */
    353440        public function test_term_deletion_should_invalidate_get_objects_in_term_cache() {
    354441                register_taxonomy( 'wptests_tax', 'post' );
     
    374461
    375462        /**
    376463         * @ticket 37094
     464         *
     465         * @covers ::wp_delete_term
    377466         */
    378467        public function test_post_deletion_should_invalidate_get_objects_in_term_cache() {
    379468                register_taxonomy( 'wptests_tax', 'post' );
     
    399488
    400489        /**
    401490         * @ticket 25706
     491         *
     492         * @covers ::in_category
    402493         */
    403494        function test_in_category() {
    404495                $post = self::factory()->post->create_and_get();
     
    414505                $this->assertTrue( in_category( $term['term_id'], $post ) );
    415506        }
    416507
     508        /**
     509         *
     510         * @covers ::wp_insert_category
     511         */
    417512        function test_insert_category_create() {
    418513                $cat = array(
    419514                        'cat_ID'   => 0,
     
    423518                $this->assertTrue( is_numeric( wp_insert_category( $cat, true ) ) );
    424519        }
    425520
     521        /**
     522         *
     523         * @covers ::wp_insert_category
     524         */
    426525        function test_insert_category_update() {
    427526                $cat = array(
    428527                        'cat_ID'   => 1,
     
    432531                $this->assertEquals( 1, wp_insert_category( $cat ) );
    433532        }
    434533
     534        /**
     535         *
     536         * @covers ::wp_insert_category
     537         */
    435538        function test_insert_category_force_error_handle() {
    436539                $cat = array(
    437540                        'cat_ID'   => 0,
     
    441544                $this->assertTrue( is_a( wp_insert_category( $cat, true ), 'WP_Error' ) );
    442545        }
    443546
     547        /**
     548         *
     549         * @covers ::wp_insert_category
     550         */
    444551        function test_insert_category_force_error_no_handle() {
    445552                $cat = array(
    446553                        'cat_ID'   => 0,
     
    450557                $this->assertEquals( 0, wp_insert_category( $cat, false ) );
    451558        }
    452559
     560        /**
     561         *
     562         * @covers ::get_ancestors
     563         */
    453564        public function test_get_ancestors_taxonomy_non_hierarchical() {
    454565                register_taxonomy( 'wptests_tax', 'post' );
    455566                $t = self::factory()->term->create(
     
    462573                _unregister_taxonomy( 'wptests_tax' );
    463574        }
    464575
     576        /**
     577         *
     578         * @covers ::get_ancestors
     579         */
    465580        public function test_get_ancestors_taxonomy() {
    466581                register_taxonomy(
    467582                        'wptests_tax',
     
    509624                $this->assertEqualSets( array(), get_ancestors( $p, 'wptests_tax' ) );
    510625        }
    511626
     627        /**
     628         *
     629         * @covers ::get_ancestors
     630         */
    512631        public function test_get_ancestors_post_type() {
    513632                register_post_type(
    514633                        'wptests_pt',
     
    546665
    547666        /**
    548667         * @ticket 15029
     668         *
     669         * @covers ::get_ancestors
    549670         */
    550671        public function test_get_ancestors_taxonomy_post_type_conflict_resource_type_taxonomy() {
    551672                register_post_type(
     
    593714
    594715        /**
    595716         * @ticket 21949
     717         *
     718         * @covers ::is_tax
    596719         */
    597720        public function test_nonpublicly_queryable_taxonomy_should_not_be_queryable_using_taxname_query_var() {
    598721                register_taxonomy(
     
    619742
    620743        /**
    621744         * @ticket 21949
     745         *
     746         * @covers ::register_taxonomy
    622747         */
    623748        public function test_it_should_be_possible_to_register_a_query_var_that_matches_the_name_of_a_nonpublicly_queryable_taxonomy() {
    624749                global $wp;
     
    660785
    661786        /**
    662787         * @ticket 21949
     788         *
     789         * @covers ::register_taxonomy
    663790         */
    664791        public function test_nonpublicly_queryable_taxonomy_should_not_be_queryable_using_taxonomy_and_term_vars() {
    665792                register_taxonomy(
     
    686813
    687814        /**
    688815         * @ticket 34491
     816         *
     817         * @covers ::register_taxonomy
    689818         */
    690819        public function test_public_taxonomy_should_be_publicly_queryable() {
    691820                register_taxonomy(
     
    714843
    715844        /**
    716845         * @ticket 34491
     846         *
     847         * @covers ::register_taxonomy
    717848         */
    718849        public function test_private_taxonomy_should_not_be_publicly_queryable() {
    719850                register_taxonomy(
     
    742873
    743874        /**
    744875         * @ticket 34491
     876         *
     877         * @covers ::register_taxonomy
    745878         */
    746879        public function test_private_taxonomy_should_be_overridden_by_publicly_queryable() {
    747880                register_taxonomy(
     
    771904
    772905        /**
    773906         * @ticket 35089
     907         *
     908         * @covers ::register_taxonomy
    774909         */
    775910        public function test_query_var_should_be_forced_to_false_for_non_public_taxonomy() {
    776911                register_taxonomy(
     
    788923
    789924        /**
    790925         * @ticket 35227
     926         *
     927         * @covers ::unregister_taxonomy
    791928         */
    792929        public function test_unregister_taxonomy_unknown_taxonomy() {
    793930                $this->assertWPError( unregister_taxonomy( 'foo' ) );
     
    795932
    796933        /**
    797934         * @ticket 35227
     935         *
     936         * @covers ::unregister_taxonomy
    798937         */
    799938        public function test_unregister_taxonomy_twice() {
    800939                register_taxonomy( 'foo', 'post' );
     
    804943
    805944        /**
    806945         * @ticket 35227
     946         *
     947         * @covers ::unregister_taxonomy
    807948         */
    808949        public function test_unregister_taxonomy_disallow_builtin_taxonomy() {
    809950                $this->assertWPError( unregister_taxonomy( 'post_tag' ) );
     
    812953
    813954        /**
    814955         * @ticket 35227
     956         *
     957         * @covers ::unregister_taxonomy
    815958         */
    816959        public function test_unregister_taxonomy_removes_query_vars() {
    817960                global $wp;
     
    825968
    826969        /**
    827970         * @ticket 35227
     971         *
     972         * @covers ::unregister_taxonomy
    828973         */
    829974        public function test_unregister_taxonomy_removes_permastruct() {
    830975                $this->set_permalink_structure( '/%postname%' );
     
    847992
    848993        /**
    849994         * @ticket 35227
     995         *
     996         * @covers ::unregister_taxonomy
    850997         */
    851998        public function test_unregister_taxonomy_removes_rewrite_rules() {
    852999                $this->set_permalink_structure( '/%postname%' );
     
    8671014
    8681015        /**
    8691016         * @ticket 35227
     1017         *
     1018         * @covers ::unregister_taxonomy
    8701019         */
    8711020        public function test_unregister_taxonomy_removes_taxonomy_from_global() {
    8721021                global $wp_taxonomies;
     
    8841033
    8851034        /**
    8861035         * @ticket 35227
     1036         *
     1037         * @covers ::unregister_taxonomy
    8871038         */
    8881039        public function test_unregister_taxonomy_removes_meta_box_callback() {
    8891040                global $wp_filter;
     
    8981049
    8991050        /**
    9001051         * @ticket 35227
     1052         *
     1053         * @covers ::unregister_taxonomy
    9011054         */
    9021055        public function test_taxonomy_does_not_exist_after_unregister_taxonomy() {
    9031056                register_taxonomy( 'foo', 'post' );
     
    9081061
    9091062        /**
    9101063         * @ticket 39308
     1064         *
     1065         * @covers ::unregister_taxonomy
    9111066         */
    9121067        public function test_taxonomy_name_property_should_not_get_overridden_by_passed_args() {
    9131068                register_taxonomy( 'foo', 'post', array( 'name' => 'bar' ) );
     
    9201075
    9211076        /**
    9221077         * @ticket 36514
     1078         *
     1079         * @covers ::edit_post
    9231080         */
    9241081        public function test_edit_post_hierarchical_taxonomy() {
    9251082
     
    9701127         * Test default term for custom taxonomy.
    9711128         *
    9721129         * @ticket 43517
     1130         *
     1131         * @covers ::register_taxonomy
    9731132         */
    9741133        function test_default_term_for_custom_taxonomy() {
    9751134
  • tests/phpunit/tests/template.php

     
    8989                parent::tearDown();
    9090        }
    9191
    92 
     92        /**
     93         *
     94         * @covers ::get_404_template
     95         */
    9396        public function test_404_template_hierarchy() {
    9497                $url = add_query_arg(
    9598                        array(
     
    106109                );
    107110        }
    108111
     112        /**
     113         *
     114         * @covers ::get_author_template
     115         */
    109116        public function test_author_template_hierarchy() {
    110117                $author = self::factory()->user->create_and_get(
    111118                        array(
     
    124131                );
    125132        }
    126133
     134        /**
     135         *
     136         * @covers ::get_category_template
     137         */
    127138        public function test_category_template_hierarchy() {
    128139                $term = self::factory()->term->create_and_get(
    129140                        array(
     
    144155                );
    145156        }
    146157
     158        /**
     159         *
     160         * @covers ::get_tag_template
     161         */
    147162        public function test_tag_template_hierarchy() {
    148163                $term = self::factory()->term->create_and_get(
    149164                        array(
     
    164179                );
    165180        }
    166181
     182        /**
     183         *
     184         * @covers ::get_taxonomy_template
     185         */
    167186        public function test_taxonomy_template_hierarchy() {
    168187                $term = self::factory()->term->create_and_get(
    169188                        array(
     
    184203                );
    185204        }
    186205
     206        /**
     207         *
     208         * @covers ::get_date_template
     209         */
    187210        public function test_date_template_hierarchy_for_year() {
    188211                $this->assertTemplateHierarchy(
    189212                        get_year_link( 1984 ),
     
    194217                );
    195218        }
    196219
     220        /**
     221         *
     222         * @covers ::get_date_template
     223         */
    197224        public function test_date_template_hierarchy_for_month() {
    198225                $this->assertTemplateHierarchy(
    199226                        get_month_link( 1984, 2 ),
     
    204231                );
    205232        }
    206233
     234        /**
     235         *
     236         * @covers ::get_date_template
     237         */
    207238        public function test_date_template_hierarchy_for_day() {
    208239                $this->assertTemplateHierarchy(
    209240                        get_day_link( 1984, 2, 25 ),
     
    214245                );
    215246        }
    216247
     248        /**
     249         *
     250         * @covers ::get_search_template
     251         */
    217252        public function test_search_template_hierarchy() {
    218253                $url = add_query_arg(
    219254                        array(
     
    230265                );
    231266        }
    232267
     268        /**
     269         *
     270         * @covers ::get_front_page_template
     271         */
    233272        public function test_front_page_template_hierarchy_with_posts_on_front() {
    234273                $this->assertEquals( 'posts', get_option( 'show_on_front' ) );
    235274                $this->assertTemplateHierarchy(
     
    242281                );
    243282        }
    244283
     284        /**
     285         *
     286         * @covers ::get_front_page_template
     287         */
    245288        public function test_front_page_template_hierarchy_with_page_on_front() {
    246289                update_option( 'show_on_front', 'page' );
    247290                update_option( 'page_on_front', self::$page_on_front->ID );
     
    260303                );
    261304        }
    262305
     306        /**
     307         *
     308         * @covers ::get_home_template
     309         */
    263310        public function test_home_template_hierarchy_with_page_on_front() {
    264311                update_option( 'show_on_front', 'page' );
    265312                update_option( 'page_on_front', self::$page_on_front->ID );
     
    274321                );
    275322        }
    276323
     324        /**
     325         *
     326         * @covers ::get_page_template
     327         */
    277328        public function test_page_template_hierarchy() {
    278329                $this->assertTemplateHierarchy(
    279330                        get_permalink( self::$page ),
     
    291342        /**
    292343         * @ticket 44005
    293344         * @group privacy
     345         *
     346         * @covers ::get_privacy_policy_template
    294347         */
    295348        public function test_privacy_template_hierarchy() {
    296349                update_option( 'wp_page_for_privacy_policy', self::$page_for_privacy_policy->ID );
     
    309362
    310363        /**
    311364         * @ticket 18375
     365         *
     366         * @covers ::get_single_template
    312367         */
    313368        public function test_single_template_hierarchy_for_post() {
    314369                $this->assertTemplateHierarchy(
     
    324379                );
    325380        }
    326381
     382        /**
     383         *
     384         * @covers ::get_single_template
     385         */
    327386        public function test_single_template_hierarchy_for_custom_post_type() {
    328387                $cpt = self::factory()->post->create_and_get(
    329388                        array(
     
    346405
    347406        /**
    348407         * @ticket 18375
     408         *
     409         * @covers ::get_single_template
    349410         */
    350411        public function test_single_template_hierarchy_for_custom_post_type_with_template() {
    351412                $cpt = self::factory()->post->create_and_get(
     
    369430                );
    370431        }
    371432
     433        /**
     434         *
     435         * @covers ::get_attachment_template
     436         */
    372437        public function test_attachment_template_hierarchy() {
    373438                $attachment = self::factory()->attachment->create_and_get(
    374439                        array(
     
    395460
    396461        /**
    397462         * @ticket 18375
     463         *
     464         * @covers ::get_attachment_template
    398465         */
    399466        public function test_attachment_template_hierarchy_with_template() {
    400467                $attachment = self::factory()->attachment->create_and_get(
     
    423490                );
    424491        }
    425492
     493        /**
     494         *
     495         * @covers ::get_embed_template
     496         */
    426497        public function test_embed_template_hierarchy_for_post() {
    427498                $this->assertTemplateHierarchy(
    428499                        get_post_embed_url( self::$post ),
     
    440511                );
    441512        }
    442513
     514        /**
     515         *
     516         * @covers ::get_embed_template
     517         */
    443518        public function test_embed_template_hierarchy_for_page() {
    444519                $this->assertTemplateHierarchy(
    445520                        get_post_embed_url( self::$page ),
  • tests/phpunit/tests/term.php

     
    1313
    1414        /**
    1515         * @ticket 29911
     16         *
     17         * @covers ::wp_delete_term
    1618         */
    1719        public function test_wp_delete_term_should_invalidate_cache_for_child_terms() {
    1820                register_taxonomy(
     
    4850
    4951        /**
    5052         * @ticket 5381
     53         *
     54         * @covers ::wp_insert_term
    5155         */
    5256        function test_is_term_type() {
    5357                // Insert a term.
     
    6367
    6468        /**
    6569         * @ticket 15919
     70         *
     71         * @covers ::wp_count_terms
    6672         */
    6773        function test_wp_count_terms() {
    6874                $count = wp_count_terms( 'category', array( 'hide_empty' => true ) );
     
    7278
    7379        /**
    7480         * @ticket 15475
     81         *
     82         * @covers ::wp_add_object_terms
     83         * @covers ::wp_remove_object_terms
    7584         */
    7685        function test_wp_add_remove_object_terms() {
    7786                $posts = self::$post_ids;
     
    103112
    104113        /**
    105114         * @group category.php
     115         *
     116         * @covers ::wp_insert_term
    106117         */
    107118        function test_term_is_ancestor_of() {
    108119                $term  = rand_str();
     
    123134                wp_delete_term( $t2['term_id'], 'category' );
    124135        }
    125136
     137        /**
     138         *
     139         * @covers ::wp_insert_category
     140         * @covers ::wp_delete_category
     141         */
    126142        function test_wp_insert_delete_category() {
    127143                $term = rand_str();
    128144                $this->assertNull( category_exists( $term ) );
     
    148164
    149165        /**
    150166         * @ticket 16550
     167         *
     168         * @covers ::wp_set_post_categories
    151169         */
    152170        function test_wp_set_post_categories() {
    153171                $post_id = self::$post_ids[0];
     
    187205
    188206        /**
    189207         * @ticket 43516
     208         *
     209         * @covers ::wp_set_post_categories
    190210         */
    191211        function test_wp_set_post_categories_sets_default_category_for_custom_post_types() {
    192212                add_filter( 'default_category_post_types', array( $this, 'filter_default_category_post_types' ) );
     
    216236
    217237        /**
    218238         * @ticket 25852
     239         *
     240         * @covers ::sanitize_term_field
    219241         */
    220242        function test_sanitize_term_field() {
    221243                $term = wp_insert_term( 'foo', $this->taxonomy );
     
    228250
    229251        /**
    230252         * @ticket 19205
     253         *
     254         * @covers ::wp_insert_term
    231255         */
    232256        function test_orphan_category() {
    233257                $cat_id1 = self::factory()->category->create();
  • tests/phpunit/tests/theme.php

     
    4646                parent::tearDown();
    4747        }
    4848
     49        /**
     50         *
     51         * @covers ::wp_get_themes
     52         */
    4953        function test_wp_get_themes_default() {
    5054                $themes = wp_get_themes();
    5155                $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_slug ] );
     
    5963        /**
    6064         * @expectedDeprecated get_theme
    6165         * @expectedDeprecated get_themes
     66         *
     67         * @covers ::get_themes
    6268         */
    6369        function test_get_themes_default() {
    6470                $themes = get_themes();
     
    7379        /**
    7480         * @expectedDeprecated get_theme
    7581         * @expectedDeprecated get_themes
     82         *
     83         * @covers ::get_themes
    7684         */
    7785        function test_get_theme() {
    7886                $themes = get_themes();
     
    8593                }
    8694        }
    8795
     96        /**
     97         *
     98         * @covers ::wp_get_themes
     99         */
    88100        function test_wp_get_theme() {
    89101                $themes = wp_get_themes();
    90102                foreach ( $themes as $theme ) {
     
    99111
    100112        /**
    101113         * @expectedDeprecated get_themes
     114         *
     115         * @covers ::get_themes
    102116         */
    103117        function test_get_themes_contents() {
    104118                $themes = get_themes();
     
    169183                }
    170184        }
    171185
     186        /**
     187         *
     188         * @covers ::wp_get_themes
     189         */
    172190        function test_wp_get_theme_contents() {
    173191                $theme = wp_get_theme( $this->theme_slug );
    174192
     
    193211         * Make sure we update the default theme list to include the latest default theme.
    194212         *
    195213         * @ticket 29925
     214         *
     215         * @covers WP_Theme::get_core_default_theme
    196216         */
    197217        function test_default_theme_in_default_theme_list() {
    198218                $latest_default_theme = WP_Theme::get_core_default_theme();
     
    202222                $this->assertContains( $latest_default_theme->get_stylesheet(), $this->default_themes );
    203223        }
    204224
     225        /**
     226         *
     227         * @covers WP_Theme::wp_get_theme
     228         */
    205229        function test_default_themes_have_textdomain() {
    206230                foreach ( $this->default_themes as $theme ) {
    207231                        if ( wp_get_theme( $theme )->exists() ) {
     
    212236
    213237        /**
    214238         * @ticket 48566
     239         *
     240         * @covers WP_Theme::wp_get_theme
    215241         */
    216242        function test_year_in_readme() {
    217243                // This test is designed to only run on trunk/master.
     
    240266        /**
    241267         * @ticket 20897
    242268         * @expectedDeprecated get_theme_data
     269         *
     270         * @covers ::wp_get_theme
     271         * @covers ::get_theme_data
    243272         */
    244273        function test_extra_theme_headers() {
    245274                $wp_theme = wp_get_theme( $this->theme_slug );
     
    260289        /**
    261290         * @expectedDeprecated get_themes
    262291         * @expectedDeprecated get_current_theme
     292         *
     293         * @covers ::get_themes
     294         * @covers ::get_current_theme
    263295         */
    264296        function test_switch_theme() {
    265297                $themes = get_themes();
     
    332364                }
    333365        }
    334366
     367        /**
     368         *
     369         * @covers WP_Theme::errors
     370         * @covers WP_Theme::exists
     371         * @covers ::get_template
     372         * @covers ::get_stylesheet
     373         */
    335374        function test_switch_theme_bogus() {
    336375                // Try switching to a theme that doesn't exist.
    337376                $template = rand_str();
     
    352391        /**
    353392         * Test _wp_keep_alive_customize_changeset_dependent_auto_drafts.
    354393         *
    355          * @covers ::_wp_keep_alive_customize_changeset_dependent_auto_drafts()
     394         * @covers ::_wp_keep_alive_customize_changeset_dependent_auto_drafts
    356395         */
    357396        function test_wp_keep_alive_customize_changeset_dependent_auto_drafts() {
    358397                $nav_created_post_ids = $this->factory()->post->create_many(
     
    418457
    419458        /**
    420459         * @ticket 49406
     460         *
     461         * @covers ::register_theme_feature
    421462         */
    422463        public function test_register_theme_support_defaults() {
    423464                $registered = register_theme_feature( 'test-feature' );
     
    434475
    435476        /**
    436477         * @ticket 49406
     478         *
     479         * @covers ::register_theme_feature
    437480         */
    438481        public function test_register_theme_support_explicit() {
    439482                $args = array(
     
    460503
    461504        /**
    462505         * @ticket 49406
     506         *
     507         * @covers ::register_theme_feature
    463508         */
    464509        public function test_register_theme_support_upgrades_show_in_rest() {
    465510                register_theme_feature( 'test-feature', array( 'show_in_rest' => true ) );
     
    480525
    481526        /**
    482527         * @ticket 49406
     528         *
     529         * @covers ::register_theme_feature
    483530         */
    484531        public function test_register_theme_support_fills_schema() {
    485532                register_theme_feature(
     
    514561
    515562        /**
    516563         * @ticket 49406
     564         *
     565         * @covers ::register_theme_feature
    517566         */
    518567        public function test_register_theme_support_does_not_add_boolean_type_if_non_bool_default() {
    519568                register_theme_feature(
     
    537586
    538587        /**
    539588         * @ticket 49406
     589         *
     590         * @covers ::register_theme_feature
    540591         */
    541592        public function test_register_theme_support_defaults_additional_properties_to_false() {
    542593                register_theme_feature(
     
    564615
    565616        /**
    566617         * @ticket 49406
     618         *
     619         * @covers ::register_theme_feature
    567620         */
    568621        public function test_register_theme_support_with_additional_properties() {
    569622                register_theme_feature(
     
    592645
    593646        /**
    594647         * @ticket 49406
     648         *
     649         * @covers ::register_theme_feature
    595650         */
    596651        public function test_register_theme_support_defaults_additional_properties_to_false_in_array() {
    597652                register_theme_feature(
     
    627682         *
    628683         * @param string $error_code The error code expected.
    629684         * @param array  $args       The args to register.
     685         *
     686         * @covers ::register_theme_feature
    630687         */
    631688        public function test_register_theme_support_validation( $error_code, $args ) {
    632689                $registered = register_theme_feature( 'test-feature', $args );
  • tests/phpunit/tests/upload.php

     
    1919                update_option( 'uploads_use_yearmonth_folders', 1 );
    2020        }
    2121
     22        /**
     23         *
     24         * @covers ::wp_upload_dir
     25         */
    2226        function test_upload_dir_default() {
    2327                // wp_upload_dir() with default parameters.
    2428                $info   = wp_upload_dir();
     
    3034                $this->assertEquals( false, $info['error'] );
    3135        }
    3236
     37        /**
     38         *
     39         * @covers ::wp_upload_dir
     40         */
    3341        function test_upload_dir_relative() {
    3442                // wp_upload_dir() with a relative upload path that is not 'wp-content/uploads'.
    3543                update_option( 'upload_path', 'foo/bar' );
     
    4452
    4553        /**
    4654         * @ticket 5953
     55         *
     56         * @covers ::wp_upload_dir
    4757         */
    4858        function test_upload_dir_absolute() {
    4959                $path = get_temp_dir() . 'wp-unit-test';
     
    6575                $this->assertEquals( false, $info['error'] );
    6676        }
    6777
     78        /**
     79         *
     80         * @covers ::wp_upload_dir
     81         */
    6882        function test_upload_dir_no_yearnum() {
    6983                update_option( 'uploads_use_yearmonth_folders', 0 );
    7084
     
    7791                $this->assertEquals( false, $info['error'] );
    7892        }
    7993
     94        /**
     95         *
     96         * @covers ::wp_upload_dir
     97         */
    8098        function test_upload_path_absolute() {
    8199                update_option( 'upload_url_path', 'http://' . WP_TESTS_DOMAIN . '/asdf' );
    82100
     
    91109                $this->assertEquals( false, $info['error'] );
    92110        }
    93111
     112        /**
     113         *
     114         * @covers ::wp_upload_dir
     115         */
    94116        function test_upload_dir_empty() {
    95117                // Upload path setting is empty - it should default to 'wp-content/uploads'.
    96118                update_option( 'upload_path', '' );
  • tests/phpunit/tests/url.php

     
    4747                );
    4848        }
    4949
     50        /**
     51         *
     52         * @covers ::is_ssl
     53         */
    5054        function test_is_ssl_by_port() {
    5155                unset( $_SERVER['HTTPS'] );
    5256                $_SERVER['SERVER_PORT'] = '443';
     
    5559                $this->assertTrue( $is_ssl );
    5660        }
    5761
     62        /**
     63         *
     64         * @covers ::is_ssl
     65         */
    5866        function test_is_ssl_with_no_value() {
    5967                unset( $_SERVER['HTTPS'] );
    6068
     
    6775         *
    6876         * @param string $url      Test URL.
    6977         * @param string $expected Expected result.
     78         *
     79         * @covers ::admin_url
    7080         */
    7181        function test_admin_url( $url, $expected ) {
    7282                $siteurl_http   = get_option( 'siteurl' );
     
    135145         *
    136146         * @param string $url      Test URL.
    137147         * @param string $expected Expected result.
     148         *
     149         * @covers ::home_url
    138150         */
    139151        function test_home_url( $url, $expected ) {
    140152                $homeurl_http  = get_option( 'home' );
     
    198210                );
    199211        }
    200212
     213        /**
     214         *
     215         * @covers ::home_url
     216         */
    201217        function test_home_url_from_admin() {
    202218                $screen = get_current_screen();
    203219
     
    246262                $GLOBALS['current_screen'] = $screen;
    247263        }
    248264
     265        /**
     266         *
     267         * @covers ::network_home_url
     268         */
    249269        function test_network_home_url_from_admin() {
    250270                $screen = get_current_screen();
    251271
     
    271291                $GLOBALS['current_screen'] = $screen;
    272292        }
    273293
     294        /**
     295         *
     296         * @covers ::set_url_scheme
     297         */
    274298        function test_set_url_scheme() {
    275299                if ( ! function_exists( 'set_url_scheme' ) ) {
    276300                        return;
     
    335359                force_ssl_admin( $forced_admin );
    336360        }
    337361
     362        /**
     363         *
     364         * @covers ::get_adjacent_post
     365         */
    338366        public function test_get_adjacent_post() {
    339367                $now      = time();
    340368                $post_id  = self::factory()->post->create( array( 'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ) ) );
     
    369397         * Test get_adjacent_post returns the next private post when the author is the currently logged in user.
    370398         *
    371399         * @ticket 30287
     400         *
     401         * @covers ::get_adjacent_post
    372402         */
    373403        public function test_get_adjacent_post_should_return_private_posts_belonging_to_the_current_user() {
    374404                $u       = self::factory()->user->create( array( 'role' => 'author' ) );
     
    406436
    407437        /**
    408438         * @ticket 30287
     439         *
     440         * @covers ::get_adjacent_post
    409441         */
    410442        public function test_get_adjacent_post_should_return_private_posts_belonging_to_other_users_if_the_current_user_can_read_private_posts() {
    411443                $u1      = self::factory()->user->create( array( 'role' => 'author' ) );
     
    444476
    445477        /**
    446478         * @ticket 30287
     479         *
     480         * @covers ::get_adjacent_post
    447481         */
    448482        public function test_get_adjacent_post_should_not_return_private_posts_belonging_to_other_users_if_the_current_user_cannot_read_private_posts() {
    449483                $u1      = self::factory()->user->create( array( 'role' => 'author' ) );
     
    490524         * Test that *_url functions handle paths with ".."
    491525         *
    492526         * @ticket 19032
     527         *
     528         * @covers ::site_url
     529         * @covers ::home_url
     530         * @covers ::admin_url
     531         * @covers ::network_admin_url
     532         * @covers ::user_admin_url
     533         * @covers ::includes_url
     534         * @covers ::network_site_url
     535         * @covers ::network_home_url
     536         * @covers ::content_url
     537         * @covers ::plugins_url
    493538         */
    494539        public function test_url_functions_for_dots_in_paths() {
    495540                $functions = array(
  • tests/phpunit/tests/user.php

     
    6666                $this->author = clone self::$_author;
    6767        }
    6868
     69        /**
     70         *
     71         * @covers ::get_users
     72         */
    6973        function test_get_users_of_blog() {
    7074                // Add one of each user role.
    7175                $nusers = array(
     
    9195                $this->assertEqualSets( $nusers, $found );
    9296        }
    9397
    94         // Simple get/set tests for user_option functions.
     98        /**
     99         *Simple get/set tests for user_option functions.
     100         *
     101         * @covers ::get_user_option
     102         */
    95103        function test_user_option() {
    96104                $key = rand_str();
    97105                $val = rand_str();
     
    111119
    112120        /**
    113121         * Simple tests for usermeta functions.
     122         *
     123         * @covers ::get_user_meta
    114124         */
    115125        function test_usermeta() {
    116126                $key = 'key';
     
    145155
    146156        /**
    147157         * Test usermeta functions in array mode.
     158         *
     159         * @covers ::get_user_meta
    148160         */
    149161        function test_usermeta_array() {
    150162                // Some values to set.
     
    185197
    186198        /**
    187199         * Test property magic functions for property get/set/isset.
     200         *
     201         * @covers WP_User::data
     202         * @covers WP_User::$key
    188203         */
    189204        function test_user_properties() {
    190205                $user = new WP_User( self::$author_id );
     
    209224         * Test the magic __unset() method.
    210225         *
    211226         * @ticket 20043
     227         *
     228         * @covers WP_User::__unset
    212229         */
    213230        public function test_user_unset() {
    214231                // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     
    229246         * @depends test_user_unset
    230247         * @expectedDeprecated WP_User->id
    231248         * @ticket 20043
     249         *
     250         * @covers WP_User::__unset
    232251         */
    233252        function test_user_unset_lowercase_id( $user ) {
    234253                $id = $user->id;
     
    242261         *
    243262         * @depends test_user_unset_lowercase_id
    244263         * @ticket 20043
     264         *
     265         * @covers WP_User::__unset
    245266         */
    246267        function test_user_unset_uppercase_id( $user ) {
    247268                $this->assertNotEmpty( $user->ID );
     
    251272
    252273        /**
    253274         * Test meta property magic functions for property get/set/isset.
     275         *
     276         * @covers WP_User::__get
     277         * @covers WP_User::__set
     278         * @covers WP_User::__isset
     279         * @covers WP_User::__unset
    254280         */
    255281        function test_user_meta_properties() {
    256282                $user = new WP_User( self::$author_id );
     
    264290
    265291        /**
    266292         * @expectedDeprecated WP_User->id
     293         *
     294         * @coversNothing
    267295         */
    268296        function test_id_property_back_compat() {
    269297                $user = new WP_User( self::$author_id );
     
    276304
    277305        /**
    278306         * ticket 19265
     307         *
     308         * @coversNothing
    279309         */
    280310        function test_user_level_property_back_compat() {
    281311                $roles = array(
     
    294324                }
    295325        }
    296326
     327        /**
     328         *
     329         * @covers WP_User::__construct
     330         */
    297331        function test_construction() {
    298332                $user = new WP_User( self::$author_id );
    299333                $this->assertInstanceOf( 'WP_User', $user );
     
    333367                $this->assertEquals( $user->user_login, $user7->user_login );
    334368        }
    335369
     370        /**
     371         *
     372         * @covers WP_User::get
     373         */
    336374        function test_get() {
    337375                $user = new WP_User( self::$author_id );
    338376                $this->assertEquals( 'author_login', $user->get( 'user_login' ) );
     
    344382                $this->assertEquals( 'abcdefg', $user->get( 'dashed-key' ) );
    345383        }
    346384
     385        /**
     386         *
     387         * @covers WP_User::has_prop
     388         */
    347389        function test_has_prop() {
    348390                $user = new WP_User( self::$author_id );
    349391                $this->assertTrue( $user->has_prop( 'user_email' ) );
     
    354396                $this->assertTrue( $user->has_prop( 'dashed-key' ) );
    355397        }
    356398
     399        /**
     400         *
     401         * @covers ::wp_update_user
     402         */
    357403        function test_update_user() {
    358404                $user = new WP_User( self::$author_id );
    359405
     
    411457
    412458        /**
    413459         * ticket 19595
     460         *
     461         * @covers WP_User::__construct
    414462         */
    415463        function test_global_userdata() {
    416464                global $userdata, $wpdb;
     
    427475
    428476        /**
    429477         * ticket 19769
     478         *
     479         * @covers WP_User::__construct
    430480         */
    431481        function test_global_userdata_is_null_when_logged_out() {
    432482                global $userdata;
     
    448498                $this->assertFalse( $user->exists() );
    449499        }
    450500
     501        /**
     502         *
     503         * @covers WP_User::__construct
     504         */
    451505        function test_global_authordata() {
    452506                global $authordata, $id;
    453507
     
    480534
    481535        /**
    482536         * @ticket 13317
     537         *
     538         * @covers ::get_userdata
    483539         */
    484540        function test_get_userdata() {
    485541                $this->assertFalse( get_userdata( 0 ) );
     
    490546
    491547        /**
    492548         * @ticket 23480
     549         *
     550         * @covers WP_User::get_data_by
    493551         */
    494552        function test_user_get_data_by_id() {
    495553                $user = WP_User::get_data_by( 'id', self::$author_id );
     
    521579
    522580        /**
    523581         * @ticket 33869
     582         *
     583         * @covers WP_User::get_data_by
    524584         */
    525585        public function test_user_get_data_by_ID_should_alias_to_id() {
    526586                $user = WP_User::get_data_by( 'ID', self::$author_id );
     
    529589
    530590        /**
    531591         * @ticket 21431
     592         *
     593         * @covers ::count_many_users_posts
    532594         */
    533595        function test_count_many_users_posts() {
    534596                $user_id_b = self::factory()->user->create( array( 'role' => 'author' ) );
     
    562624
    563625        /**
    564626         * @ticket 22858
     627         *
     628         * @covers ::wp_update_user
    565629         */
    566630        function test_wp_update_user_on_nonexistent_users() {
    567631                $user_id = 1;
     
    576640
    577641        /**
    578642         * @ticket 28435
     643         *
     644         * @covers ::wp_update_user
    579645         */
    580646        function test_wp_update_user_should_not_change_password_when_passed_WP_User_instance() {
    581647                $testuserid = 1;
     
    591657        /**
    592658         * @ticket 45747
    593659         * @group ms-excluded
     660         *
     661         * @covers ::wp_update_user
    594662         */
    595663        function test_wp_update_user_should_not_mark_user_as_spam_on_single_site() {
    596664                $u = wp_update_user(
     
    615683
    616684        /**
    617685         * @ticket 28315
     686         *
     687         * @covers ::update_user_meta
    618688         */
    619689        function test_user_meta_error() {
    620690                $id1 = wp_insert_user(
     
    646716
    647717        /**
    648718         * @ticket 30647
     719         *
     720         * @covers ::update_user_meta
    649721         */
    650722        function test_user_update_email_error() {
    651723                $id1 = wp_insert_user(
     
    691763        /**
    692764         * @ticket 27317
    693765         * @dataProvider _illegal_user_logins_data
     766         *
     767         * @covers ::wp_insert_user
    694768         */
    695769        function test_illegal_user_logins_single( $user_login ) {
    696770                $user_data = array(
     
    715789        /**
    716790         * @ticket 27317
    717791         * @dataProvider _illegal_user_logins_data
     792         *
     793         * @covers ::register_new_user
    718794         */
    719795        function test_illegal_user_logins_single_wp_create_user( $user_login ) {
    720796                $user_email = 'testuser-' . $user_login . '@example.com';
     
    735811        /**
    736812         * @ticket 27317
    737813         * @group ms-required
     814         *
     815         * @covers ::wpmu_validate_user_signup
    738816         */
    739817        function test_illegal_user_logins_multisite() {
    740818                $user_data = array(
     
    773851
    774852        /**
    775853         * @ticket 24618
     854         *
     855         * @covers ::validate_username
    776856         */
    777857        public function test_validate_username_string() {
    778858                $this->assertTrue( validate_username( 'johndoe' ) );
     
    781861
    782862        /**
    783863         * @ticket 24618
     864         *
     865         * @covers ::validate_username
    784866         */
    785867        public function test_validate_username_contains_uppercase_letters() {
    786868                if ( is_multisite() ) {
     
    792874
    793875        /**
    794876         * @ticket 24618
     877         *
     878         * @covers ::validate_username
    795879         */
    796880        public function test_validate_username_empty() {
    797881                $this->assertFalse( validate_username( '' ) );
     
    799883
    800884        /**
    801885         * @ticket 24618
     886         *
     887         * @covers ::validate_username
    802888         */
    803889        public function test_validate_username_invalid() {
    804890                $this->assertFalse( validate_username( '@#&99sd' ) );
     
    806892
    807893        /**
    808894         * @ticket 29880
     895         *
     896         * @covers ::wp_insert_user
    809897         */
    810898        public function test_wp_insert_user_should_not_wipe_existing_password() {
    811899                $user_details = array(
     
    828916
    829917        /**
    830918         * @ticket 29696
     919         *
     920         * @covers ::wp_insert_user
    831921         */
    832922        public function test_wp_insert_user_should_sanitize_user_nicename_parameter() {
    833923                $user = $this->author;
     
    843933
    844934        /**
    845935         * @ticket 33793
     936         *
     937         * @covers ::wp_insert_user
    846938         */
    847939        public function test_wp_insert_user_should_accept_user_login_with_60_characters() {
    848940                $user_login = str_repeat( 'a', 60 );
     
    864956
    865957        /**
    866958         * @ticket 33793
     959         *
     960         * @covers ::wp_insert_user
    867961         */
    868962        public function test_wp_insert_user_should_reject_user_login_over_60_characters() {
    869963                $user_login = str_repeat( 'a', 61 );
     
    882976
    883977        /**
    884978         * @ticket 33793
     979         *
     980         * @covers ::wp_insert_user
    885981         */
    886982        public function test_wp_insert_user_should_reject_user_nicename_over_50_characters() {
    887983                $user_nicename = str_repeat( 'a', 51 );
     
    900996
    901997        /**
    902998         * @ticket 33793
     999         *
     1000         * @covers ::wp_insert_user
    9031001         */
    9041002        public function test_wp_insert_user_should_not_generate_user_nicename_longer_than_50_chars() {
    9051003                $user_login = str_repeat( 'a', 55 );
     
    9191017
    9201018        /**
    9211019         * @ticket 33793
     1020         *
     1021         * @covers ::wp_insert_user
    9221022         */
    9231023        public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename() {
    9241024                $u1 = self::factory()->user->create(
     
    9491049
    9501050        /**
    9511051         * @ticket 33793
     1052         *
     1053         * @covers ::wp_insert_user
    9521054         */
    9531055        public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() {
    9541056                $user_ids = self::factory()->user->create_many(
     
    9851087
    9861088        /**
    9871089         * @ticket 28004
     1090         *
     1091         * @covers ::wp_insert_user
    9881092         */
    9891093        public function test_wp_insert_user_with_invalid_user_id() {
    9901094                global $wpdb;
     
    10051109
    10061110        /**
    10071111         * @ticket 47902
     1112         *
     1113         * @covers ::wp_insert_user
    10081114         */
    10091115        public function test_wp_insert_user_with_empty_data() {
    10101116                add_filter( 'wp_pre_insert_user_data', '__return_empty_array' );
     
    10191125
    10201126        /**
    10211127         * @ticket 35750
     1128         *
     1129         * @covers ::wp_update_user
    10221130         */
    10231131        public function test_wp_update_user_should_delete_userslugs_cache() {
    10241132                $u    = self::factory()->user->create();
     
    10361144                $this->assertEquals( $u, wp_cache_get( $updated_user->user_nicename, 'userslugs' ) );
    10371145        }
    10381146
     1147        /**
     1148         *
     1149         * @covers ::wp_update_user
     1150         */
    10391151        public function test_changing_email_invalidates_password_reset_key() {
    10401152                global $wpdb;
    10411153
     
    10881200                $this->assertEmpty( $user->user_activation_key );
    10891201        }
    10901202
     1203        /**
     1204         *
     1205         * @covers ::get_users
     1206         */
    10911207        public function test_search_users_login() {
    10921208                $users = get_users(
    10931209                        array(
     
    10991215                $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
    11001216        }
    11011217
     1218        /**
     1219         *
     1220         * @covers ::get_users
     1221         */
    11021222        public function test_search_users_url() {
    11031223                $users = get_users(
    11041224                        array(
     
    11101230                $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
    11111231        }
    11121232
     1233        /**
     1234         *
     1235         * @covers ::get_users
     1236         */
    11131237        public function test_search_users_email() {
    11141238                $users = get_users(
    11151239                        array(
     
    11211245                $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
    11221246        }
    11231247
     1248        /**
     1249         *
     1250         * @covers ::get_users
     1251         */
    11241252        public function test_search_users_nicename() {
    11251253                $users = get_users(
    11261254                        array(
     
    11321260                $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
    11331261        }
    11341262
     1263        /**
     1264         *
     1265         * @covers ::get_users
     1266         */
    11351267        public function test_search_users_display_name() {
    11361268                $users = get_users(
    11371269                        array(
     
    11451277
    11461278        /**
    11471279         * @ticket 32158
     1280         *
     1281         * @covers ::wp_update_user
    11481282         */
    11491283        function test_email_case() {
    11501284                // Alter the case of the email address (which stays the same).
     
    11591293
    11601294        /**
    11611295         * @ticket 32158
     1296         *
     1297         * @covers ::wp_update_user
    11621298         */
    11631299        function test_email_change() {
    11641300                // Change the email address.
     
    11821318         * @dataProvider data_wp_new_user_notifications
    11831319         * @ticket 33654
    11841320         * @ticket 36009
     1321         *
     1322         * @covers ::wp_new_user_notification
    11851323         */
    11861324        function test_wp_new_user_notification( $notify, $admin_email_sent_expected, $user_email_sent_expected ) {
    11871325                reset_phpmailer_instance();
     
    12621400         *
    12631401         * @ticket 33654
    12641402         * @expectedDeprecated wp_new_user_notification
     1403         *
     1404         * @covers ::wp_new_user_notification
    12651405         */
    12661406        function test_wp_new_user_notification_old_signature_throws_deprecated_warning_but_sends() {
    12671407                reset_phpmailer_instance();
     
    12871427         * Set up a user and try sending a notification using `wp_new_user_notification( $user );`.
    12881428         *
    12891429         * @ticket 34377
     1430         *
     1431         * @covers ::wp_new_user_notification
    12901432         */
    12911433        function test_wp_new_user_notification_old_signature_no_password() {
    12921434                reset_phpmailer_instance();
     
    13121454         * Ensure blog's admin email change notification emails do not contain encoded HTML entities
    13131455         *
    13141456         * @ticket 40015
     1457         *
     1458         * @covers ::update_option_new_admin_email
    13151459         */
    13161460        function test_new_admin_email_notification_html_entities_decoded() {
    13171461                reset_phpmailer_instance();
     
    13451489         * - is not a valid email
    13461490         *
    13471491         * @dataProvider data_user_admin_email_confirmation_emails
     1492         *
     1493         * @covers ::update_option_new_admin_email
    13481494         */
    13491495        function test_new_admin_email_confirmation_not_sent_when_email_invalid( $email, $message ) {
    13501496                reset_phpmailer_instance();
     
    13861532         * - Matches another user's email
    13871533         *
    13881534         * @dataProvider data_user_change_email_confirmation_emails
     1535         *
     1536         * @covers ::send_confirmation_on_profile_email
    13891537         */
    13901538        function test_profile_email_confirmation_not_sent_invalid_email( $email, $message ) {
    13911539
     
    14511599         * Checks that calling edit_user() with no password returns an error when adding, and doesn't when updating.
    14521600         *
    14531601         * @ticket 35715
     1602         *
     1603         * @covers ::edit_user
    14541604         */
    14551605        function test_edit_user_blank_pw() {
    14561606                $_POST                 = array();
     
    15201670
    15211671        /**
    15221672         * @ticket 16470
     1673         *
     1674         * @covers ::wp_set_current_user
    15231675         */
    15241676        function test_send_confirmation_on_profile_email() {
    15251677                reset_phpmailer_instance();
     
    15551707
    15561708        /**
    15571709         * @ticket 16470
     1710         *
     1711         * @covers ::wp_set_current_user
    15581712         */
    15591713        function test_remove_send_confirmation_on_profile_email() {
    15601714                remove_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
     
    15951749         *
    15961750         * @ticket 16470
    15971751         * @ticket 40015
     1752         *
     1753         * @covers ::send_confirmation_on_profile_email
    15981754         */
    15991755        function test_send_confirmation_on_profile_email_html_entities_decoded() {
    16001756                $user_id = self::factory()->user->create(
     
    16311787
    16321788        /**
    16331789         * @ticket 42564
     1790         *
     1791         * @covers ::edit_user
    16341792         */
    16351793        function test_edit_user_role_update() {
    16361794                $_POST    = array();
     
    16741832         * Testing the `wp_user_personal_data_exporter()` function when no user exists.
    16751833         *
    16761834         * @ticket 43547
     1835         *
     1836         * @covers ::wp_user_personal_data_exporter
    16771837         */
    16781838        function test_wp_user_personal_data_exporter_no_user() {
    16791839                $actual = wp_user_personal_data_exporter( 'not-a-user-email@test.com' );
     
    16911851         * user exists.
    16921852         *
    16931853         * @ticket 43547
     1854         *
     1855         * @covers ::wp_user_personal_data_exporter
    16941856         */
    16951857        function test_wp_user_personal_data_exporter() {
    16961858                $test_user = new WP_User( self::$contrib_id );
     
    17111873         * with Community Events Location IP data.
    17121874         *
    17131875         * @ticket 43921
     1876         *
     1877         * @covers ::wp_user_personal_data_exporter
    17141878         */
    17151879        function test_wp_community_events_location_ip_personal_data_exporter() {
    17161880                $test_user = new WP_User( self::$contrib_id );
     
    17351899         * with Community Events Location city data.
    17361900         *
    17371901         * @ticket 43921
     1902         *
     1903         * @covers ::wp_user_personal_data_exporter
    17381904         */
    17391905        function test_wp_community_events_location_city_personal_data_exporter() {
    17401906                $test_user = new WP_User( self::$contrib_id );
     
    17771943         * with Session Tokens data.
    17781944         *
    17791945         * @ticket 45889
     1946         *
     1947         * @covers ::wp_user_personal_data_exporter
    17801948         */
    17811949        function test_wp_session_tokens_personal_data_exporter() {
    17821950                $test_user = new WP_User( self::$contrib_id );
     
    18211989         * @since 5.4.0
    18221990         *
    18231991         * @ticket 47509
     1992         *
     1993         * @covers ::wp_user_personal_data_exporter
    18241994         */
    18251995        function test_filter_wp_privacy_additional_user_profile_data() {
    18261996                $test_user = new WP_User( self::$contrib_id );
  • tests/phpunit/tests/walker.php

     
    1616
    1717        }
    1818
     19        /**
     20         *
     21         * @covers Walker::walk
     22         */
    1923        function test_single_item() {
    2024
    2125                $items  = array(
     
    3135
    3236        }
    3337
     38        /**
     39         *
     40         * @covers Walker::walk
     41         */
    3442        function test_single_item_flat() {
    3543
    3644                $items  = array(
     
    4654
    4755        }
    4856
     57        /**
     58         *
     59         * @covers Walker::walk
     60         */
    4961        function test_single_item_depth_1() {
    5062
    5163                $items  = array(
     
    6173
    6274        }
    6375
     76        /**
     77         *
     78         * @covers Walker::walk
     79         */
    6480        function test_multiple_items_single_level() {
    6581
    6682                $items = array(
     
    8197
    8298        }
    8399
     100        /**
     101         *
     102         * @covers Walker::walk
     103         */
    84104        function test_multiple_items_multiple_levels() {
    85105
    86106                $items = array(
     
    101121
    102122        }
    103123
     124        /**
     125         *
     126         * @covers Walker::walk
     127         */
    104128        function test_multiple_items_multiple_levels_flat() {
    105129
    106130                $items = array(
     
    121145
    122146        }
    123147
     148        /**
     149         *
     150         * @covers Walker::walk
     151         */
    124152        function test_multiple_items_multiple_levels_depth_1() {
    125153
    126154                $items = array(
     
    141169
    142170        }
    143171
     172        /**
     173         *
     174         * @covers Walker::walk
     175         */
    144176        function test_multiple_items_multiple_levels_depth_2() {
    145177
    146178                $items = array(
     
    165197
    166198        }
    167199
     200        /**
     201         *
     202         * @covers Walker::walk
     203         */
    168204        function test_multiple_items_recursive() {
    169205
    170206                $items = array(
     
    185221
    186222        }
    187223
     224        /**
     225         *
     226         * @covers Walker::walk
     227         */
    188228        function test_single_item_child() {
    189229
    190230                $items = array(
     
    201241
    202242        }
    203243
     244        /**
     245         *
     246         * @covers Walker::walk
     247         */
    204248        function test_single_item_missing_parent_depth_1() {
    205249
    206250                $items = array(
     
    224268
    225269        }
    226270
     271        /**
     272         *
     273         * @covers Walker::walk
     274         */
    227275        function test_multiple_items_missing_parents() {
    228276
    229277                $items = array(
     
    248296
    249297        }
    250298
     299        /**
     300         *
     301         * @covers Walker::walk
     302         */
    251303        function test_multiple_items_missing_parents_depth_1() {
    252304
    253305                $items = array(
  • tests/phpunit/tests/widgets.php

     
    3131        /**
    3232         * @see register_widget()
    3333         * @see unregister_widget()
     34         *
     35         * @covers ::register_widget
     36         * @covers ::unregister_widget
    3437         */
    3538        function test_register_and_unregister_widget_core_widget() {
    3639                global $wp_widget_factory;
     
    4952         * @see register_widget()
    5053         * @see unregister_widget()
    5154         * @ticket 28216
     55         *
     56         * @covers ::register_widget
     57         * @covers ::unregister_widget
    5258         */
    5359        function test_register_and_unregister_widget_instance() {
    5460                global $wp_widget_factory, $wp_registered_widgets;
     
    125131
    126132        /**
    127133         * @group sidebar
     134         *
     135         * @covers ::register_sidebars
    128136         */
    129137        function test_register_sidebars_single() {
    130138
     
    138146
    139147        /**
    140148         * @group sidebar
     149         *
     150         * @covers ::register_sidebars
    141151         */
    142152        function test_register_sidebars_multiple() {
    143153
     
    161171
    162172        /**
    163173         * @group sidebar
     174         *
     175         * @covers ::register_sidebars
    164176         */
    165177        function test_register_sidebar_with_no_id() {
    166178                global $wp_registered_sidebars;
     
    178190
    179191        /**
    180192         * @group sidebar
     193         *
     194         * @covers ::register_sidebars
    181195         */
    182196        function test_unregister_sidebar_registered_with_no_id() {
    183197                global $wp_registered_sidebars;
     
    197211
    198212        /**
    199213         * @group sidebar
     214         *
     215         * @covers ::register_sidebars
    200216         */
    201217        function test_register_sidebar_with_string_id() {
    202218
     
    210226
    211227        /**
    212228         * @group sidebar
     229         *
     230         * @covers ::unregister_sidebar
    213231         */
    214232        function test_unregister_sidebar_with_string_id() {
    215233                global $wp_registered_sidebars;
     
    223241
    224242        /**
    225243         * @group sidebar
     244         *
     245         * @covers ::register_sidebars
    226246         */
    227247        function test_register_sidebar_with_numeric_id() {
    228248                global $wp_registered_sidebars;
     
    235255
    236256        /**
    237257         * @group sidebar
     258         *
     259         * @covers ::unregister_sidebar
    238260         */
    239261        function test_unregister_sidebar_with_numeric_id() {
    240262                global $wp_registered_sidebars;
     
    256278
    257279        /**
    258280         * @group sidebar
     281         *
     282         * @covers ::dynamic_sidebar
    259283         */
    260284        function test_dynamic_sidebar_using_sidebar_registered_with_no_id() {
    261285                $this->setExpectedIncorrectUsage( 'register_sidebar' );
     
    275299
    276300        /**
    277301         * @group sidebar
     302         *
     303         * @covers ::dynamic_sidebar
    278304         */
    279305        function test_dynamic_sidebar_using_invalid_sidebar_id() {
    280306                register_sidebar( array( 'id' => 'wp-unit-text' ) );
     
    293319
    294320        /**
    295321         * @group sidebar
     322         *
     323         * @covers ::dynamic_sidebar
    296324         */
    297325        function test_dynamic_sidebar_numeric_id() {
    298326                $sidebar_id = 2;
     
    307335
    308336        /**
    309337         * @group sidebar
     338         *
     339         * @covers ::dynamic_sidebar
    310340         */
    311341        function test_dynamic_sidebar_string_id() {
    312342                $sidebar_id = 'wp-unit-tests';
     
    321351
    322352        /**
    323353         * @see WP_Widget_Search::form()
     354         *
     355         * @covers WP_Widget_Search::form
    324356         */
    325357        function test_wp_widget_search_form() {
    326358                $widget = new WP_Widget_Search( 'foo', 'Foo' );
     
    343375
    344376        /**
    345377         * @see WP_Widget::form()
     378         *
     379         * @covers WP_Widget_Search::form
    346380         */
    347381        function test_wp_widget_form() {
    348382                $widget = new WP_Widget( 'foo', 'Foo' );
     
    355389
    356390        /**
    357391         * @see WP_Widget::__construct()
     392         *
     393         * @covers WP_Widget::__construct
    358394         */
    359395        function test_wp_widget_constructor() {
    360396                $id_base    = 'foo';
     
    385421        /**
    386422         * @see WP_Widget::get_field_name()
    387423         * @dataProvider data_wp_widget_get_field_name
     424         *
     425         * @covers WP_Widget::get_field_name
    388426         */
    389427        function test_wp_widget_get_field_name( $expected, $value_to_test ) {
    390428                $widget = new WP_Widget( 'foo', 'Foo' );
     
    435473        /**
    436474         * @see WP_Widget::get_field_id()
    437475         * @dataProvider data_wp_widget_get_field_id
     476         *
     477         * @covers WP_Widget::get_field_id
    438478         */
    439479        function test_wp_widget_get_field_id( $expected, $value_to_test ) {
    440480                $widget = new WP_Widget( 'foo', 'Foo' );
     
    484524
    485525        /**
    486526         * @see WP_Widget::_register()
     527         *
     528         * @covers WP_Widget::_register
     529         * @covers ::wp_widgets_init
    487530         */
    488531        function test_wp_widget__register() {
    489532                global $wp_registered_widgets;
     
    506549
    507550        /**
    508551         * @see WP_Widget::is_preview()
     552         *
     553         * @covers WP_Widget::is_preview
    509554         */
    510555        function test_wp_widget_is_preview() {
    511556                global $wp_customize;
     
    529574
    530575        /**
    531576         * @see WP_Widget::get_settings()
     577         *
     578         * @covers WP_Widget::get_settings
    532579         */
    533580        function test_wp_widget_get_settings() {
    534581                global $wp_registered_widgets;
     
    566613
    567614        /**
    568615         * @see WP_Widget::save_settings()
     616         *
     617         * @covers WP_Widget::save_settings
    569618         */
    570619        function test_wp_widget_save_settings() {
    571620                global $wp_registered_widgets;
     
    597646
    598647        /**
    599648         * @see WP_Widget::save_settings()
     649         *
     650         * @covers WP_Widget::save_settings
    600651         */
    601652        function test_wp_widget_save_settings_delete() {
    602653                global $wp_registered_widgets;
     
    614665
    615666        /**
    616667         * @see wp_widget_control()
     668         *
     669         * @covers ::wp_widget_control
    617670         */
    618671        function test_wp_widget_control() {
    619672                global $wp_registered_widgets;
     
    676729                }
    677730        }
    678731
     732        /**
     733         *
     734         * @covers ::the_widget
     735         */
    679736        function test_the_widget_custom_before_title_arg() {
    680737                register_widget( 'WP_Widget_Text' );
    681738
     
    704761         * display an unregistered widget.
    705762         *
    706763         * @see \the_widget()
     764         *
     765         * @covers ::the_widget
    707766         */
    708767        function test_the_widget_with_unregistered_widget() {
    709768                $this->setExpectedIncorrectUsage( 'the_widget' );
     
    712771
    713772        /**
    714773         * @ticket 34226
     774         *
     775         * @covers ::the_widget
    715776         */
    716777        public function test_the_widget_should_short_circuit_with_widget_display_callback() {
    717778                add_filter( 'widget_display_callback', '__return_false' );
     
    740801        /**
    741802         * Tests for when 'sidebars_widgets' theme mod is populated.
    742803         *
    743          * @covers ::retrieve_widgets()
     804         * @covers ::retrieve_widgets
    744805         */
    745806        function test_retrieve_widgets_with_theme_mod() {
    746807                global $sidebars_widgets, $_wp_sidebars_widgets;
     
    804865        /**
    805866         * Tests for when sidebars widgets matches registered sidebars.
    806867         *
    807          * @covers ::retrieve_widgets()
     868         * @covers ::retrieve_widgets
    808869         */
    809870        function test_retrieve_widgets_with_sidebars_widgets_matching_registered_sidebars() {
    810871                global $sidebars_widgets;
     
    842903        /**
    843904         * Tests for when sidebars widgets doesn't match registered sidebars.
    844905         *
    845          * @covers ::retrieve_widgets()
     906         * @covers ::retrieve_widgets
    846907         */
    847908        function test_retrieve_widgets_with_sidebars_widgets_not_matching_registered_sidebars() {
    848909                global $sidebars_widgets, $_wp_sidebars_widgets;
     
    936997        /**
    937998         * Tests for Customizer mode.
    938999         *
    939          * @covers ::retrieve_widgets()
     1000         * @covers ::retrieve_widgets
    9401001         */
    9411002        function test_retrieve_widgets_for_customizer() {
    9421003                global $sidebars_widgets, $_wp_sidebars_widgets;
     
    9831044                $this->assertNotEquals( $sidebars_widgets, wp_get_sidebars_widgets() );
    9841045        }
    9851046
     1047        /**
     1048         *
     1049         * @covers ::retrieve_widgets
     1050         */
    9861051        function test_retreive_widgets_with_single_widget() {
    9871052                global $sidebars_widgets;
    9881053
     
    10081073        /**
    10091074         * Tests for orphaned widgets being moved into inactive widgets.
    10101075         *
    1011          * @covers ::retrieve_widgets()
     1076         * @covers ::retrieve_widgets
    10121077         */
    10131078        function test_retrieve_widgets_move_orphaned_widgets_to_inactive() {
    10141079                global $sidebars_widgets;
     
    10431108        /**
    10441109         * Test _wp_remove_unregistered_widgets.
    10451110         *
    1046          * @covers ::_wp_remove_unregistered_widgets()
     1111         * @covers ::_wp_remove_unregistered_widgets
    10471112         */
    10481113        public function test__wp_remove_unregistered_widgets() {
    10491114                $widgets = array(
     
    10731138        /**
    10741139         * Two themes with one sidebar each should just map, switching to a theme not previously-active.
    10751140         *
    1076          * @covers ::wp_map_sidebars_widgets()
     1141         * @covers ::wp_map_sidebars_widgets
    10771142         */
    10781143        public function test_one_sidebar_each() {
    10791144                $this->register_sidebars( array( 'primary' ) );
     
    10931158        /**
    10941159         * Sidebars with the same name should map, switching to a theme not previously-active.
    10951160         *
    1096          * @covers ::wp_map_sidebars_widgets()
     1161         * @covers ::wp_map_sidebars_widgets
    10971162         */
    10981163        public function test_sidebars_with_same_slug() {
    10991164                $this->register_sidebars( array( 'primary', 'secondary' ) );
     
    11111176        /**
    11121177         * Make educated guesses on theme sidebars.
    11131178         *
    1114          * @covers ::wp_map_sidebars_widgets()
     1179         * @covers ::wp_map_sidebars_widgets
    11151180         */
    11161181        public function test_sidebar_guessing() {
    11171182                $this->register_sidebars( array( 'primary', 'secondary' ) );
     
    11341199        /**
    11351200         * Make sure two sidebars that fall in the same group don't get the same menu assigned.
    11361201         *
    1137          * @covers ::wp_map_sidebars_widgets()
     1202         * @covers ::wp_map_sidebars_widgets
    11381203         */
    11391204        public function test_sidebar_guessing_one_menu_per_group() {
    11401205                $this->register_sidebars( array( 'primary' ) );
     
    11551220        /**
    11561221         * Make sure two sidebars that fall in the same group get menus assigned from the same group.
    11571222         *
    1158          * @covers ::wp_map_sidebars_widgets()
     1223         * @covers ::wp_map_sidebars_widgets
    11591224         */
    11601225        public function test_sidebar_guessing_one_menu_per_sidebar() {
    11611226                $this->register_sidebars( array( 'primary', 'main' ) );
  • tests/phpunit/tests/wp.php

     
    1414                $this->wp = new WP();
    1515        }
    1616
     17        /**
     18         *
     19         * @covers WP::add_query_var
     20         */
    1721        public function test_add_query_var() {
    1822                $public_qv_count = count( $this->wp->public_query_vars );
    1923
     
    2630                $this->assertTrue( in_array( 'test2', $this->wp->public_query_vars, true ) );
    2731        }
    2832
     33        /**
     34         *
     35         * @covers WP::remove_query_var
     36         */
    2937        public function test_remove_query_var() {
    3038                $public_qv_count = count( $this->wp->public_query_vars );
    3139