Ticket #39265: root.2.patch
File root.2.patch, 260.0 KB (added by , 5 years ago) |
---|
-
tests/phpunit/tests/actions.php
7 7 */ 8 8 class Tests_Actions extends WP_UnitTestCase { 9 9 10 /** 11 * 12 * @covers ::do_action 13 */ 10 14 function test_simple_action() { 11 15 $a = new MockAction(); 12 16 $tag = __FUNCTION__; … … 24 28 $this->assertEquals( array( '' ), $args ); 25 29 } 26 30 31 /** 32 * @covers ::remove_action 33 */ 27 34 function test_remove_action() { 28 35 $a = new MockAction(); 29 36 $tag = __FUNCTION__; … … 43 50 44 51 } 45 52 53 /** 54 * @covers ::has_action 55 */ 46 56 function test_has_action() { 47 57 $tag = __FUNCTION__; 48 58 $func = __FUNCTION__ . '_func'; … … 57 67 $this->assertFalse( has_action( $tag ) ); 58 68 } 59 69 60 // One tag with multiple actions. 70 /** 71 * One tag with multiple actions. 72 * 73 * @covers ::add_action 74 */ 61 75 function test_multiple_actions() { 62 76 $a1 = new MockAction(); 63 77 $a2 = new MockAction(); … … 74 88 $this->assertEquals( 1, $a2->get_call_count() ); 75 89 } 76 90 91 /** 92 * One tag with multiple actions. 93 * 94 * @covers ::do_action 95 */ 77 96 function test_action_args_1() { 78 97 $a = new MockAction(); 79 98 $tag = __FUNCTION__; … … 89 108 $this->assertEquals( array( $val ), array_pop( $argsvar ) ); 90 109 } 91 110 111 /** 112 * One tag with multiple actions. 113 * 114 * @covers ::do_action 115 */ 92 116 function test_action_args_2() { 93 117 $a1 = new MockAction(); 94 118 $a2 = new MockAction(); … … 120 144 * 121 145 * @see https://core.trac.wordpress.org/ticket/17817#comment:72 122 146 * @ticket 17817 147 * 148 * @covers ::do_action 123 149 */ 124 150 function test_action_args_3() { 125 151 $a1 = new MockAction(); … … 157 183 * Tests PHP 4 notation for calling actions while passing in an object by reference. 158 184 * 159 185 * @ticket 48312 186 * 187 * @covers ::do_action 160 188 */ 161 189 function test_action_args_with_php4_syntax() { 162 190 $a = new MockAction(); … … 201 229 $this->assertEquals( $expected, $a->get_events() ); 202 230 } 203 231 232 /** 233 * @covers ::did_action 234 */ 204 235 function test_did_action() { 205 236 $tag1 = 'action1'; 206 237 $tag2 = 'action2'; … … 222 253 223 254 } 224 255 256 /** 257 * @covers ::add_action 258 */ 225 259 function test_all_action() { 226 260 $a = new MockAction(); 227 261 $tag1 = __FUNCTION__ . '_1'; … … 246 280 247 281 } 248 282 283 /** 284 * @covers ::remove_action 285 */ 249 286 function test_remove_all_action() { 250 287 $a = new MockAction(); 251 288 $tag = __FUNCTION__; … … 266 303 $this->assertEquals( array( $tag ), $a->get_tags() ); 267 304 } 268 305 306 /** 307 * @covers ::do_action_ref_array 308 */ 269 309 function test_action_ref_array() { 270 310 $obj = new stdClass(); 271 311 $a = new MockAction(); … … 284 324 285 325 /** 286 326 * @ticket 11241 327 * 328 * @covers ::add_action 287 329 */ 288 330 function test_action_keyed_array() { 289 331 $a = new MockAction(); … … 309 351 310 352 } 311 353 354 /** 355 * @covers ::do_action 356 */ 312 357 function test_action_self_removal() { 313 358 add_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) ); 314 359 do_action( 'test_action_self_removal' ); … … 321 366 322 367 /** 323 368 * @ticket 17817 369 * 370 * @covers ::do_action 324 371 */ 325 372 function test_action_recursion() { 326 373 $tag = __FUNCTION__; … … 336 383 $this->assertEquals( 2, $b->get_call_count(), 'recursive actions should call callbacks with later priority' ); 337 384 } 338 385 386 /** 387 * @covers ::do_action 388 */ 339 389 function action_that_causes_recursion( $tag ) { 340 390 static $recursing = false; 341 391 if ( ! $recursing ) { … … 348 398 /** 349 399 * @ticket 9968 350 400 * @ticket 17817 401 * 402 * @covers ::add_action 351 403 */ 352 404 function test_action_callback_manipulation_while_running() { 353 405 $tag = __FUNCTION__; … … 383 435 * 384 436 * This specificaly addresses the concern raised at 385 437 * https://core.trac.wordpress.org/ticket/17817#comment:52 438 * 439 * @covers ::remove_filter 386 440 */ 387 441 function test_remove_anonymous_callback() { 388 442 $tag = __FUNCTION__; … … 416 470 * Test the ArrayAccess methods of WP_Hook 417 471 * 418 472 * @ticket 17817 473 * 474 * @covers ::has_action 419 475 */ 420 476 function test_array_access_of_wp_filter_global() { 421 477 global $wp_filter; … … 442 498 * Make sure current_action() behaves as current_filter() 443 499 * 444 500 * @ticket 14994 501 * 502 * @covers ::current_action 445 503 */ 446 504 function test_current_action() { 447 505 global $wp_current_filter; … … 453 511 454 512 /** 455 513 * @ticket 14994 514 * 515 * @covers ::doing_filter 456 516 */ 457 517 function test_doing_filter() { 458 518 global $wp_current_filter; … … 472 532 473 533 /** 474 534 * @ticket 14994 535 * 536 * @covers ::doing_filter 475 537 */ 476 538 function test_doing_action() { 477 539 global $wp_current_filter; … … 491 553 492 554 /** 493 555 * @ticket 14994 556 * 557 * @covers ::doing_filter 494 558 */ 495 559 function test_doing_filter_real() { 496 560 $this->assertFalse( doing_filter() ); // No filter is passed in, and no filter is being processed. … … 509 573 $this->assertFalse( doing_filter( 'testing' ) ); // No longer doing this filter. 510 574 } 511 575 576 /** 577 * @covers ::doing_filter 578 */ 512 579 function apply_testing_filter() { 513 580 $this->apply_testing_filter = true; 514 581 … … 530 597 $this->assertFalse( doing_filter( 'testing_nested' ) ); 531 598 } 532 599 600 /** 601 * @covers ::doing_filter 602 */ 533 603 function apply_testing_nested_filter() { 534 604 $this->apply_testing_nested_filter = true; 535 605 $this->assertTrue( doing_filter() ); … … 541 611 /** 542 612 * @ticket 10441 543 613 * @expectedDeprecated tests_do_action_deprecated 614 * 615 * @covers ::do_action_deprecated 544 616 */ 545 617 public function test_do_action_deprecated() { 546 618 $p = new WP_Post( (object) array( 'post_title' => 'Foo' ) ); … … 559 631 /** 560 632 * @ticket 10441 561 633 * @expectedDeprecated tests_do_action_deprecated 634 * 635 * @covers ::do_action_deprecated 562 636 */ 563 637 public function test_do_action_deprecated_with_multiple_params() { 564 638 $p1 = new WP_Post( (object) array( 'post_title' => 'Foo1' ) ); -
tests/phpunit/tests/adminbar.php
31 31 32 32 /** 33 33 * @ticket 21117 34 * 35 * @covers WP_Admin_Bar::get_nodes 34 36 */ 35 37 function test_content_post_type() { 36 38 wp_set_current_user( self::$editor_id ); … … 50 52 51 53 /** 52 54 * @ticket 21117 55 * 56 * @covers WP_Admin_Bar::add_node 53 57 */ 54 58 function test_merging_existing_meta_values() { 55 59 wp_set_current_user( self::$editor_id ); … … 86 90 /** 87 91 * @ticket 25162 88 92 * @group ms-excluded 93 * 94 * @covers ::_wp_admin_bar_init 89 95 */ 90 96 public function test_admin_bar_contains_correct_links_for_users_with_no_role() { 91 97 $this->assertFalse( user_can( self::$no_role_id, 'read' ) ); … … 111 117 /** 112 118 * @ticket 25162 113 119 * @group ms-excluded 120 * 121 * @covers ::_wp_admin_bar_init 114 122 */ 115 123 public function test_admin_bar_contains_correct_links_for_users_with_role() { 116 124 $this->assertTrue( user_can( self::$editor_id, 'read' ) ); … … 139 147 * @ticket 25162 140 148 * @group multisite 141 149 * @group ms-required 150 * 151 * @covers ::_wp_admin_bar_init 142 152 */ 143 153 public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_blog() { 144 154 $blog_id = self::factory()->blog->create( … … 188 198 * @ticket 25162 189 199 * @group multisite 190 200 * @group ms-required 201 * 202 * @covers ::_wp_admin_bar_init 191 203 */ 192 204 public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_network() { 193 205 $this->assertTrue( user_can( self::$admin_id, 'read' ) ); … … 239 251 restore_current_blog(); 240 252 } 241 253 254 /** 255 * @return mixed 256 */ 242 257 protected function get_standard_admin_bar() { 243 258 global $wp_admin_bar; 244 259 … … 259 274 * 260 275 * @param array $node_data The data for a node, passed to `WP_Admin_Bar::add_node()`. 261 276 * @param string $expected_html The expected HTML when admin menu is rendered. 277 * 278 * @covers WP_Admin_Bar::add_node 262 279 */ 263 280 public function test_admin_bar_with_tabindex_meta( $node_data, $expected_html ) { 264 281 $admin_bar = new WP_Admin_Bar(); … … 347 364 348 365 /** 349 366 * @ticket 22247 367 * 368 * @covers ::_wp_admin_bar_init 369 * @covers WP_Admin_Bar::get_node 350 370 */ 351 371 public function test_admin_bar_has_edit_link_for_existing_posts() { 352 372 wp_set_current_user( self::$editor_id ); … … 374 394 375 395 /** 376 396 * @ticket 22247 397 * 398 * @covers WP_Admin_Bar::get_node 377 399 */ 378 400 public function test_admin_bar_has_no_edit_link_for_non_existing_posts() { 379 401 wp_set_current_user( self::$editor_id ); … … 393 415 394 416 /** 395 417 * @ticket 34113 418 * 419 * @covers WP_Admin_Bar::get_node 396 420 */ 397 421 public function test_admin_bar_has_no_archives_link_if_no_static_front_page() { 398 422 set_current_screen( 'edit-post' ); … … 407 431 408 432 /** 409 433 * @ticket 34113 434 * 435 * @covers WP_Admin_Bar::get_node 410 436 */ 411 437 public function test_admin_bar_contains_view_archive_link_if_static_front_page() { 412 438 update_option( 'show_on_front', 'page' ); … … 422 448 423 449 /** 424 450 * @ticket 34113 451 * 452 * @covers WP_Admin_Bar::get_node 425 453 */ 426 454 public function test_admin_bar_has_no_archives_link_for_pages() { 427 455 set_current_screen( 'edit-page' ); … … 437 465 /** 438 466 * @ticket 37949 439 467 * @group ms-excluded 468 * 469 * @covers WP_Admin_Bar::get_node 440 470 */ 441 471 public function test_admin_bar_contains_correct_about_link_for_users_with_role() { 442 472 wp_set_current_user( self::$editor_id ); … … 454 484 /** 455 485 * @ticket 37949 456 486 * @group ms-excluded 487 * 488 * @covers WP_Admin_Bar::get_node 457 489 */ 458 490 public function test_admin_bar_contains_correct_about_link_for_users_with_no_role() { 459 491 wp_set_current_user( self::$no_role_id ); … … 473 505 * @ticket 37949 474 506 * @group multisite 475 507 * @group ms-required 508 * 509 * @covers WP_Admin_Bar::get_node 476 510 */ 477 511 public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite() { 478 512 // User is not a member of a site. … … 492 526 493 527 /** 494 528 * @ticket 34113 529 * 530 * @covers WP_Admin_Bar::get_node 495 531 */ 496 532 public function test_admin_bar_has_no_archives_link_for_non_public_cpt() { 497 533 register_post_type( … … 516 552 517 553 /** 518 554 * @ticket 34113 555 * 556 * @covers WP_Admin_Bar::get_node 519 557 */ 520 558 public function test_admin_bar_has_no_archives_link_for_cpt_without_archive() { 521 559 register_post_type( … … 540 578 541 579 /** 542 580 * @ticket 34113 581 * 582 * @covers WP_Admin_Bar::get_node 543 583 */ 544 584 public function test_admin_bar_has_no_archives_link_for_cpt_not_shown_in_admin_bar() { 545 585 register_post_type( … … 596 636 597 637 /** 598 638 * @ticket 39252 639 * 640 * @covers WP_Admin_Bar::get_node 599 641 */ 600 642 public function test_new_user_link_exists_for_user_with_create_users() { 601 643 wp_set_current_user( self::$admin_id ); … … 615 657 616 658 /** 617 659 * @ticket 39252 660 * 661 * @covers WP_Admin_Bar::get_node 618 662 */ 619 663 public function test_new_user_link_existence_for_user_with_promote_users() { 620 664 wp_set_current_user( self::$admin_id ); … … 638 682 639 683 /** 640 684 * @ticket 39252 685 * 686 * @covers WP_Admin_Bar::get_node 641 687 */ 642 688 public function test_new_user_link_does_not_exist_for_user_without_create_or_promote_users() { 643 689 wp_set_current_user( self::$admin_id ); … … 657 703 /** 658 704 * @ticket 30937 659 705 * @covers ::wp_admin_bar_customize_menu 706 * 707 * @covers WP_Admin_Bar::get_node 660 708 */ 661 709 public function test_customize_link() { 662 710 global $wp_customize; … … 694 742 /** 695 743 * @ticket 39082 696 744 * @group ms-required 745 * 746 * @covers WP_Admin_Bar::get_nodes 697 747 */ 698 748 public function test_my_sites_network_menu_for_regular_user() { 699 749 wp_set_current_user( self::$editor_id ); … … 709 759 /** 710 760 * @ticket 39082 711 761 * @group ms-required 762 * 763 * @covers WP_Admin_Bar::get_nodes 712 764 */ 713 765 public function test_my_sites_network_menu_for_super_admin() { 714 766 wp_set_current_user( self::$editor_id ); … … 726 778 /** 727 779 * @ticket 39082 728 780 * @group ms-required 781 * 782 * @covers WP_Admin_Bar::get_nodes 729 783 */ 730 784 public function test_my_sites_network_menu_for_regular_user_with_network_caps() { 731 785 global $current_user; -
tests/phpunit/tests/auth.php
35 35 wp_set_current_user( self::$user_id ); 36 36 } 37 37 38 /** 39 * @covers ::wp_validate_auth_cookie 40 */ 38 41 function test_auth_cookie_valid() { 39 42 $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'auth' ); 40 43 $this->assertEquals( self::$user_id, wp_validate_auth_cookie( $cookie, 'auth' ) ); 41 44 } 42 45 46 /** 47 * @covers ::wp_validate_auth_cookie 48 */ 43 49 function test_auth_cookie_invalid() { 44 50 // 3600 or less and +3600 may occur in wp_validate_auth_cookie(), 45 51 // as an ajax test may have defined DOING_AJAX, failing the test. … … 56 62 $this->assertEquals( false, wp_validate_auth_cookie( self::$user_id, 'auth' ), 'altered cookie' ); 57 63 } 58 64 65 /** 66 * @covers ::wp_validate_auth_cookie 67 */ 59 68 function test_auth_cookie_scheme() { 60 69 // Arbitrary scheme name. 61 70 $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' ); … … 68 77 69 78 /** 70 79 * @ticket 23494 80 * 81 * @covers ::wp_authenticate 71 82 */ 72 83 function test_password_trimming() { 73 84 $passwords_to_test = array( … … 93 104 * wp_hash_password function 94 105 * 95 106 * @ticket 24973 107 * 108 * @covers ::wp_hash_password 96 109 */ 97 110 function test_wp_hash_password_trimming() { 98 111 99 112 $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 ) ) ); 101 114 102 115 $password = 'pass with trailing whitespace '; 103 116 $this->assertTrue( wp_check_password( 'pass with trailing whitespace', wp_hash_password( $password ) ) ); … … 114 127 115 128 /** 116 129 * @ticket 29217 130 * 131 * @covers ::wp_verify_nonce 117 132 */ 118 133 function test_wp_verify_nonce_with_empty_arg() { 119 134 $this->assertFalse( wp_verify_nonce( '' ) ); … … 122 137 123 138 /** 124 139 * @ticket 29542 140 * 141 * @covers ::wp_verify_nonce 125 142 */ 126 143 function test_wp_verify_nonce_with_integer_arg() { 127 144 $this->assertFalse( wp_verify_nonce( 1 ) ); … … 129 146 130 147 /** 131 148 * @ticket 24030 149 * 150 * @covers ::wp_verify_nonce 132 151 */ 133 152 function test_wp_nonce_verify_failed() { 134 153 $nonce = substr( md5( uniqid() ), 0, 10 ); … … 141 160 142 161 /** 143 162 * @ticket 24030 163 * 164 * @covers ::wp_verify_nonce 144 165 */ 145 166 function test_wp_nonce_verify_success() { 146 167 $nonce = wp_create_nonce( 'nonce_test_action' ); … … 153 174 154 175 /** 155 176 * @ticket 36361 177 * 178 * @covers ::check_admin_referer 156 179 */ 157 180 public function test_check_admin_referer_with_no_action_triggers_doing_it_wrong() { 158 181 $this->setExpectedIncorrectUsage( 'check_admin_referer' ); … … 165 188 unset( $_REQUEST['_wpnonce'] ); 166 189 } 167 190 191 /** 192 * @covers ::check_admin_referer 193 */ 168 194 public function test_check_admin_referer_with_default_action_as_string_not_doing_it_wrong() { 169 195 // A valid nonce needs to be set so the check doesn't die(). 170 196 $_REQUEST['_wpnonce'] = wp_create_nonce( '-1' ); … … 176 202 177 203 /** 178 204 * @ticket 36361 205 /** 206 * 207 * @c * 208 * @covers ::check_ajax_referer 179 209 */ 180 210 public function test_check_ajax_referer_with_no_action_triggers_doing_it_wrong() { 181 211 $this->setExpectedIncorrectUsage( 'check_ajax_referer' ); … … 188 218 unset( $_REQUEST['_wpnonce'] ); 189 219 } 190 220 221 /** 222 * @covers ::wp_authenticate 223 */ 191 224 function test_password_length_limit() { 192 225 $limit = str_repeat( 'a', 4096 ); 193 226 … … 237 270 238 271 /** 239 272 * @ticket 45746 273 * 274 * @covers ::check_password_reset_key 240 275 */ 241 276 function test_user_activation_key_is_saved() { 242 277 $user = get_userdata( $this->user->ID ); … … 251 286 252 287 /** 253 288 * @ticket 32429 289 * 290 * @covers ::check_password_reset_key 254 291 */ 255 292 function test_user_activation_key_is_checked() { 256 293 global $wpdb; … … 289 326 290 327 /** 291 328 * @ticket 32429 329 * 330 * @covers ::check_password_reset_key 292 331 */ 293 332 function test_expired_user_activation_key_is_rejected() { 294 333 global $wpdb; … … 312 351 313 352 /** 314 353 * @ticket 32429 354 * 355 * @covers ::check_password_reset_key 315 356 */ 316 357 function test_empty_user_activation_key_fails_key_check() { 317 358 // An empty user_activation_key should not allow any key to be accepted. … … 325 366 326 367 /** 327 368 * @ticket 32429 369 * 370 * @covers ::check_password_reset_key 328 371 */ 329 372 function test_legacy_user_activation_key_is_rejected() { 330 373 global $wpdb; … … 355 398 /** 356 399 * @ticket 32429 357 400 * @ticket 24783 401 * 402 * @covers ::check_password_reset_key 358 403 */ 359 404 function test_plaintext_user_activation_key_is_rejected() { 360 405 global $wpdb; … … 386 431 * Ensure users can log in using both their username and their email address. 387 432 * 388 433 * @ticket 9568 434 * 435 * @covers ::wp_authenticate 389 436 */ 390 437 public function test_log_in_using_email() { 391 438 $user_args = array( … … 401 448 402 449 /** 403 450 * @ticket 38744 451 * 452 * @covers ::wp_signon 404 453 */ 405 454 public function test_wp_signon_using_email_with_an_apostrophe() { 406 455 $user_args = array( -
tests/phpunit/tests/avatar.php
8 8 class Tests_Avatar extends WP_UnitTestCase { 9 9 /** 10 10 * @ticket 21195 11 * 12 * @covers ::get_avatar_url 11 13 */ 12 14 public function test_get_avatar_url_gravatar_url() { 13 15 $url = get_avatar_url( 1 ); … … 16 18 17 19 /** 18 20 * @ticket 21195 21 * 22 * @covers ::get_avatar_url 19 23 */ 20 24 public function test_get_avatar_url_size() { 21 25 $url = get_avatar_url( 1 ); … … 28 32 29 33 /** 30 34 * @ticket 21195 35 * 36 * @covers ::get_avatar_url 31 37 */ 32 38 public function test_get_avatar_url_default() { 33 39 $url = get_avatar_url( 1 ); … … 45 51 46 52 /** 47 53 * @ticket 21195 54 * 55 * @covers ::get_avatar_url 48 56 */ 49 57 public function test_get_avatar_url_rating() { 50 58 $url = get_avatar_url( 1 ); … … 57 65 58 66 /** 59 67 * @ticket 21195 68 * 69 * @covers ::get_avatar_url 60 70 */ 61 71 public function test_get_avatar_url_scheme() { 62 72 $url = get_avatar_url( 1 ); … … 73 83 74 84 /** 75 85 * @ticket 21195 86 * 87 * @covers ::get_avatar_url 76 88 */ 77 89 public function test_get_avatar_url_user() { 78 90 $url = get_avatar_url( 1 ); … … 106 118 protected $fake_url; 107 119 /** 108 120 * @ticket 21195 121 * 122 * @covers ::get_avatar_url 109 123 */ 110 124 public function test_pre_get_avatar_url_filter() { 111 125 $this->fake_url = 'haha wat'; … … 116 130 117 131 $this->assertEquals( $url, $this->fake_url ); 118 132 } 133 119 134 public function pre_get_avatar_url_filter( $args ) { 120 135 $args['url'] = $this->fake_url; 121 136 return $args; … … 123 138 124 139 /** 125 140 * @ticket 21195 141 * 142 * @covers ::get_avatar_url 126 143 */ 127 144 public function test_get_avatar_url_filter() { 128 145 $this->fake_url = 'omg lol'; … … 139 156 140 157 /** 141 158 * @ticket 21195 159 * 160 * @covers ::get_avatar_url 142 161 */ 143 162 public function test_get_avatar_comment_types_filter() { 144 163 $url = get_avatar_url( 1 ); … … 167 186 return $comment_types; 168 187 } 169 188 189 /** 190 * @covers ::get_avatar 191 */ 170 192 public function test_get_avatar() { 171 193 $img = get_avatar( 1 ); 172 194 $this->assertEquals( preg_match( "|^<img alt='[^']*' src='[^']*' srcset='[^']*' class='[^']*' height='[^']*' width='[^']*' loading='lazy'/>$|", $img ), 1 ); 173 195 } 174 196 197 /** 198 * @covers ::get_avatar 199 */ 175 200 public function test_get_avatar_size() { 176 201 $size = '100'; 177 202 $img = get_avatar( 1, $size ); … … 178 203 $this->assertEquals( preg_match( "|^<img .*height='$size'.*width='$size'|", $img ), 1 ); 179 204 } 180 205 206 /** 207 * @covers ::get_avatar 208 */ 181 209 public function test_get_avatar_alt() { 182 210 $alt = 'Mr Hyde'; 183 211 $img = get_avatar( 1, 96, '', $alt ); … … 184 212 $this->assertEquals( preg_match( "|^<img alt='$alt'|", $img ), 1 ); 185 213 } 186 214 215 /** 216 * @covers ::get_avatar 217 */ 187 218 public function test_get_avatar_class() { 188 219 $class = 'first'; 189 220 $img = get_avatar( 1, 96, '', '', array( 'class' => $class ) ); … … 190 221 $this->assertEquals( preg_match( "|^<img .*class='[^']*{$class}[^']*'|", $img ), 1 ); 191 222 } 192 223 224 /** 225 * @covers ::get_avatar 226 */ 193 227 public function test_get_avatar_default_class() { 194 228 $img = get_avatar( 1, 96, '', '', array( 'force_default' => true ) ); 195 229 $this->assertEquals( preg_match( "|^<img .*class='[^']*avatar-default[^']*'|", $img ), 1 ); 196 230 } 197 231 232 /** 233 * @covers ::get_avatar 234 */ 198 235 public function test_get_avatar_force_display() { 199 236 $old = get_option( 'show_avatars' ); 200 237 update_option( 'show_avatars', false ); … … 210 247 protected $fake_img; 211 248 /** 212 249 * @ticket 21195 250 * 251 * @covers ::get_avatar 213 252 */ 214 253 public function test_pre_get_avatar_filter() { 215 254 $this->fake_img = 'YOU TOO?!'; … … 226 265 227 266 /** 228 267 * @ticket 21195 268 * 269 * @covers ::get_avatar 229 270 */ 230 271 public function test_get_avatar_filter() { 231 272 $this->fake_url = 'YA RLY'; … … 244 285 * The `get_avatar_data()` function should return gravatar url when comment type allowed to retrieve avatars. 245 286 * 246 287 * @ticket 44033 288 * 289 * @covers ::is_avatar_comment_type 290 * @covers ::get_avatar 247 291 */ 248 292 public function test_get_avatar_data_should_return_gravatar_url_when_input_avatar_comment_type() { 249 293 $comment_type = 'comment'; … … 264 308 * The `get_avatar_data()` function should return invalid url when comment type not allowed to retrieve avatars. 265 309 * 266 310 * @ticket 44033 311 * 312 * @covers ::is_avatar_comment_type 313 * @covers ::get_avatar 267 314 */ 268 315 public function test_get_avatar_data_should_return_invalid_url_when_input_not_avatar_comment_type() { 269 316 $comment_type = 'review'; -
tests/phpunit/tests/basic.php
3 3 /** 4 4 * just make sure the test framework is working 5 5 * 6 * No Covers as this checks for content in files 7 * 6 8 * @group testsuite 7 9 */ 8 10 class Tests_Basic extends WP_UnitTestCase { 9 11 12 /** 13 * @coversNothing 14 */ 10 15 function test_license() { 11 16 // This test is designed to only run on trunk/master. 12 17 $this->skipOnAutomatedBranches(); … … 17 22 $this->assertEquals( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." ); 18 23 } 19 24 25 /** 26 * @coversNothing 27 */ 20 28 function test_security_md() { 21 29 // This test is designed to only run on trunk/master. 22 30 $this->skipOnAutomatedBranches(); … … 28 36 $this->assertEquals( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." ); 29 37 } 30 38 39 /** 40 * @coversNothing 41 */ 31 42 function test_package_json() { 32 43 $package_json = file_get_contents( dirname( ABSPATH ) . '/package.json' ); 33 44 $package_json = json_decode( $package_json, true ); … … 42 53 43 54 /** 44 55 * @depends test_package_json 56 * 57 * @coversNothing 45 58 */ 46 59 function test_package_json_node_engine( $package_json ) { 47 60 $this->assertArrayHasKey( 'engines', $package_json ); … … 50 63 $this->assertRegExp( '~^=?\d+\.\d+\.\d+$~', $node, "package.json's node version cannot be a range." ); 51 64 } 52 65 53 // Test some helper utility functions. 54 66 /** 67 * Test some helper utility functions. 68 * 69 * @coversNothing 70 */ 55 71 function test_strip_ws() { 56 72 $this->assertEquals( '', strip_ws( '' ) ); 57 73 $this->assertEquals( 'foo', strip_ws( 'foo' ) ); … … 79 95 80 96 } 81 97 98 /** 99 * @coversNothing 100 */ 82 101 function test_mask_input_value() { 83 102 $in = <<<EOF 84 103 <h2>Assign Authors</h2> -
tests/phpunit/tests/cache.php
26 26 return $cache; 27 27 } 28 28 29 /** 30 * 31 * @covers WP_Object_Cache::test_miss 32 */ 29 33 function test_miss() { 30 34 $this->assertEquals( null, $this->cache->get( 'test_miss' ) ); 31 35 } 32 36 37 /** 38 * 39 * @covers WP_Object_Cache::add 40 */ 33 41 function test_add_get() { 34 42 $key = __FUNCTION__; 35 43 $val = 'val'; … … 38 46 $this->assertEquals( $val, $this->cache->get( $key ) ); 39 47 } 40 48 49 /** 50 * 51 * @covers WP_Object_Cache::add 52 */ 41 53 function test_add_get_0() { 42 54 $key = __FUNCTION__; 43 55 $val = 0; … … 47 59 $this->assertEquals( $val, $this->cache->get( $key ) ); 48 60 } 49 61 62 /** 63 * 64 * @covers WP_Object_Cache::add 65 */ 50 66 function test_add_get_null() { 51 67 $key = __FUNCTION__; 52 68 $val = null; … … 56 72 $this->assertEquals( '', $this->cache->get( $key ) ); 57 73 } 58 74 75 /** 76 * 77 * @covers WP_Object_Cache::add 78 */ 59 79 function test_add() { 60 80 $key = __FUNCTION__; 61 81 $val1 = 'val1'; … … 69 89 $this->assertEquals( $val1, $this->cache->get( $key ) ); 70 90 } 71 91 92 /** 93 * 94 * @covers WP_Object_Cache::replace 95 */ 72 96 function test_replace() { 73 97 $key = __FUNCTION__; 74 98 $val = 'val1'; … … 83 107 $this->assertEquals( $val2, $this->cache->get( $key ) ); 84 108 } 85 109 110 /** 111 * 112 * @covers WP_Object_Cache::set 113 */ 86 114 function test_set() { 87 115 $key = __FUNCTION__; 88 116 $val1 = 'val1'; … … 96 124 $this->assertEquals( $val2, $this->cache->get( $key ) ); 97 125 } 98 126 127 /** 128 * 129 * @covers WP_Object_Cache::flush 130 */ 99 131 function test_flush() { 100 132 global $_wp_using_ext_object_cache; 101 133 … … 114 146 $this->assertFalse( $this->cache->get( $key ) ); 115 147 } 116 148 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 */ 118 155 function test_object_refs() { 119 156 $key = __FUNCTION__ . '_1'; 120 157 $object_a = new stdClass; … … 137 174 $this->assertEquals( 'bravo', $object_a->foo ); 138 175 } 139 176 177 /** 178 * 179 * @covers WP_Object_Cache::incr 180 */ 140 181 function test_incr() { 141 182 $key = __FUNCTION__; 142 183 … … 150 191 $this->assertEquals( 3, $this->cache->get( $key ) ); 151 192 } 152 193 194 /** 195 * 196 * @covers ::wp_cache_incr 197 */ 153 198 function test_wp_cache_incr() { 154 199 $key = __FUNCTION__; 155 200 … … 163 208 $this->assertEquals( 3, wp_cache_get( $key ) ); 164 209 } 165 210 211 /** 212 * 213 * @covers WP_Object_Cache::decr 214 */ 166 215 function test_decr() { 167 216 $key = __FUNCTION__; 168 217 … … 182 231 183 232 /** 184 233 * @ticket 21327 234 * 235 * @covers ::wp_cache_decr 185 236 */ 186 237 function test_wp_cache_decr() { 187 238 $key = __FUNCTION__; … … 200 251 $this->assertEquals( 0, wp_cache_get( $key ) ); 201 252 } 202 253 254 /** 255 * 256 * @covers WP_Object_Cache::delete 257 */ 203 258 function test_delete() { 204 259 $key = __FUNCTION__; 205 260 $val = 'val'; … … 215 270 $this->assertFalse( $this->cache->delete( $key, 'default' ) ); 216 271 } 217 272 273 /** 274 * 275 * @covers ::wp_cache_delete 276 * @covers ::wp_cache_get 277 * @covers ::wp_cache_set 278 */ 218 279 function test_wp_cache_delete() { 219 280 $key = __FUNCTION__; 220 281 $val = 'val'; … … 234 295 $this->assertFalse( wp_cache_delete( $key, 'default' ) ); 235 296 } 236 297 298 /** 299 * 300 * @covers WP_Object_Cache::switch_to_blog 301 */ 237 302 function test_switch_to_blog() { 238 303 if ( ! method_exists( $this->cache, 'switch_to_blog' ) ) { 239 304 return; … … 280 345 $this->assertEquals( $val2, $this->cache->get( $key, 'global-cache-test' ) ); 281 346 } 282 347 348 /** 349 * 350 * @covers ::wp_cache_init 351 */ 283 352 function test_wp_cache_init() { 284 353 $new_blank_cache_object = new WP_Object_Cache(); 285 354 wp_cache_init(); … … 294 363 } 295 364 } 296 365 366 /** 367 * 368 * @covers ::wp_cache_replace 369 */ 297 370 function test_wp_cache_replace() { 298 371 $key = 'my-key'; 299 372 $val1 = 'first-val'; … … 318 391 319 392 /** 320 393 * @ticket 20875 394 * 395 * @covers ::wp_cache_get_multiple 321 396 */ 322 397 public function test_get_multiple() { 323 398 wp_cache_set( 'foo1', 'bar', 'group1' ); -
tests/phpunit/tests/canonical.php
17 17 18 18 /** 19 19 * @dataProvider data_canonical 20 * 21 * @covers ::redirect_canonical 20 22 */ 21 23 function test_canonical( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { 22 24 … … 232 234 233 235 /** 234 236 * @ticket 16557 237 * 238 * @covers ::redirect_guess_404_permalink 235 239 */ 236 240 public function test_do_redirect_guess_404_permalink() { 237 241 // Test disable do_redirect_guess_404_permalink(). … … 242 246 243 247 /** 244 248 * @ticket 16557 249 * 250 * @covers ::redirect_guess_404_permalink 245 251 */ 246 252 public function test_pre_redirect_guess_404_permalink() { 247 253 // Test short-circuit filter. … … 257 263 258 264 /** 259 265 * @ticket 16557 266 * 267 * @covers ::redirect_guess_404_permalink 260 268 */ 261 269 public function test_strict_redirect_guess_404_permalink() { 262 270 $post = self::factory()->post->create( … … 277 285 278 286 /** 279 287 * @ticket 43745 288 * 289 * @covers ::redirect_canonical 280 290 */ 281 291 public function test_utf8_query_keys_canonical() { 282 292 $p = self::factory()->post->create( -
tests/phpunit/tests/category.php
18 18 * Validate get_all_category_ids 19 19 * 20 20 * @expectedDeprecated get_all_category_ids 21 * 22 * @covers ::get_all_category_ids 21 23 */ 22 24 function test_get_all_category_ids() { 23 25 // Ccreate categories. … … 34 36 35 37 /** 36 38 * Validate get_category_by_slug function 39 * 40 * @covers ::get_category_by_slug 37 41 */ 38 42 function test_get_category_by_slug() { 39 43 … … 64 68 65 69 /** 66 70 * Validate _make_cat_compat function 71 * 72 * @covers ::_make_cat_compat 67 73 */ 68 74 function test__make_cat_compat() { 69 75 … … 141 147 142 148 /** 143 149 * Validate get_cat_name function 150 * 151 * @covers ::get_cat_name 144 152 */ 145 153 function test_get_cat_name() { 146 154 … … 161 169 162 170 /** 163 171 * Validate get_cat_name function 172 * 173 * @covers ::get_cat_ID 164 174 */ 165 175 function test_get_cat_ID() { 166 176 … … 181 191 182 192 /** 183 193 * Validate get_category_by_path function 194 * 195 * @covers ::get_category_by_path 184 196 */ 185 197 function test_get_category_by_path() { 186 198 -
tests/phpunit/tests/comment-submission.php
39 39 require_once ABSPATH . WPINC . '/class-phpass.php'; 40 40 } 41 41 42 /** 43 * @covers ::wp_handle_comment_submission 44 */ 42 45 public function test_submitting_comment_to_invalid_post_returns_error() { 43 46 $error = 'comment_id_not_found'; 44 47 … … 55 58 56 59 } 57 60 61 /** 62 * @covers ::wp_handle_comment_submission 63 */ 58 64 public function test_submitting_comment_to_post_with_closed_comments_returns_error() { 59 65 60 66 $error = 'comment_closed'; … … 78 84 79 85 } 80 86 87 /** 88 * @covers ::wp_handle_comment_submission 89 */ 81 90 public function test_submitting_comment_to_trashed_post_returns_error() { 82 91 83 92 $error = 'comment_on_trash'; … … 99 108 100 109 } 101 110 111 /** 112 * @covers ::wp_handle_comment_submission 113 */ 102 114 public function test_submitting_comment_to_draft_post_returns_error() { 103 115 $error = 'comment_on_draft'; 104 116 … … 124 136 125 137 /** 126 138 * @ticket 39650 139 * 140 * @covers ::wp_handle_comment_submission 127 141 */ 128 142 public function test_submitting_comment_to_draft_post_returns_error_message_for_user_with_correct_caps() { 129 143 $error = 'comment_on_draft'; … … 150 164 $this->assertNotEmpty( $comment->get_error_message() ); 151 165 } 152 166 167 /** 168 * @covers ::wp_handle_comment_submission 169 */ 153 170 public function test_submitting_comment_to_scheduled_post_returns_error() { 154 171 155 172 // Same error as commenting on a draft. … … 176 193 177 194 } 178 195 196 /** 197 * @covers ::wp_handle_comment_submission 198 */ 179 199 public function test_submitting_comment_to_password_required_post_returns_error() { 180 200 181 201 $error = 'comment_on_password_protected'; … … 199 219 200 220 } 201 221 222 /** 223 * @covers ::wp_handle_comment_submission 224 */ 202 225 public function test_submitting_comment_to_password_protected_post_succeeds() { 203 226 204 227 $password = 'password'; … … 227 250 228 251 } 229 252 253 /** 254 * @covers ::wp_handle_comment_submission 255 */ 230 256 public function test_submitting_valid_comment_as_logged_in_user_succeeds() { 231 257 232 258 $user = self::factory()->user->create_and_get( … … 254 280 255 281 } 256 282 283 /** 284 * @covers ::wp_handle_comment_submission 285 */ 257 286 public function test_submitting_valid_comment_anonymously_succeeds() { 258 287 259 288 $data = array( … … 280 309 * wp_handle_comment_submission() expects un-slashed data. 281 310 * 282 311 * @group slashes 312 * 313 * @covers ::wp_handle_comment_submission 283 314 */ 284 315 public function test_submitting_comment_handles_slashes_correctly_handles_slashes() { 285 316 … … 300 331 301 332 } 302 333 334 /** 335 * @covers ::wp_handle_comment_submission 336 */ 303 337 public function test_submitting_comment_anonymously_to_private_post_returns_error() { 304 338 305 339 $error = 'comment_id_not_found'; … … 321 355 322 356 } 323 357 358 /** 359 * @covers ::wp_handle_comment_submission 360 */ 324 361 public function test_submitting_comment_as_logged_in_user_to_inaccessible_private_post_returns_error() { 325 362 326 363 $error = 'comment_id_not_found'; … … 351 388 352 389 } 353 390 391 /** 392 * @covers ::wp_handle_comment_submission 393 */ 354 394 public function test_submitting_comment_to_private_post_with_closed_comments_returns_correct_error() { 355 395 356 396 $error = 'comment_id_not_found'; … … 382 422 383 423 } 384 424 425 /** 426 * @covers ::wp_handle_comment_submission 427 */ 385 428 public function test_submitting_comment_to_own_private_post_succeeds() { 386 429 387 430 wp_set_current_user( self::$author_id ); … … 405 448 406 449 } 407 450 451 /** 452 * @covers ::wp_handle_comment_submission 453 */ 408 454 public function test_submitting_comment_to_accessible_private_post_succeeds() { 409 455 410 456 wp_set_current_user( self::$editor_id ); … … 428 474 429 475 } 430 476 477 /** 478 * @covers ::wp_handle_comment_submission 479 */ 431 480 public function test_anonymous_user_cannot_comment_unfiltered_html() { 432 481 433 482 $data = array( … … 444 493 445 494 } 446 495 496 /** 497 * @covers ::wp_handle_comment_submission 498 */ 447 499 public function test_unprivileged_user_cannot_comment_unfiltered_html() { 448 500 449 501 wp_set_current_user( self::$author_id ); … … 462 514 463 515 } 464 516 517 /** 518 * @covers ::wp_handle_comment_submission 519 */ 465 520 public function test_unprivileged_user_cannot_comment_unfiltered_html_even_with_valid_nonce() { 466 521 467 522 wp_set_current_user( self::$author_id ); … … 486 541 487 542 } 488 543 544 /** 545 * @covers ::wp_handle_comment_submission 546 */ 489 547 public function test_privileged_user_can_comment_unfiltered_html_with_valid_nonce() { 490 548 491 549 $this->assertFalse( defined( 'DISALLOW_UNFILTERED_HTML' ) ); … … 518 576 519 577 } 520 578 579 /** 580 * @covers ::wp_handle_comment_submission 581 */ 521 582 public function test_privileged_user_cannot_comment_unfiltered_html_without_valid_nonce() { 522 583 523 584 if ( is_multisite() ) { … … 542 603 543 604 } 544 605 606 /** 607 * @covers ::wp_handle_comment_submission 608 */ 545 609 public function test_submitting_comment_as_anonymous_user_when_registration_required_returns_error() { 546 610 547 611 $error = 'not_logged_in'; … … 561 625 562 626 } 563 627 628 /** 629 * @covers ::wp_handle_comment_submission 630 */ 564 631 public function test_submitting_comment_with_no_name_when_name_email_required_returns_error() { 565 632 566 633 $error = 'require_name_email'; … … 582 649 583 650 } 584 651 652 /** 653 * @covers ::wp_handle_comment_submission 654 */ 585 655 public function test_submitting_comment_with_no_email_when_name_email_required_returns_error() { 586 656 587 657 $error = 'require_name_email'; … … 603 673 604 674 } 605 675 676 /** 677 * @covers ::wp_handle_comment_submission 678 */ 606 679 public function test_submitting_comment_with_invalid_email_when_name_email_required_returns_error() { 607 680 608 681 $error = 'require_valid_email'; … … 625 698 626 699 } 627 700 701 /** 702 * @covers ::wp_handle_comment_submission 703 */ 628 704 public function test_submitting_comment_with_no_comment_content_returns_error() { 629 705 630 706 $error = 'require_valid_comment'; … … 644 720 645 721 /** 646 722 * @ticket 10377 723 * 724 * @covers ::wp_handle_comment_submission 647 725 */ 648 726 public function test_submitting_comment_with_content_too_long_returns_error() { 649 727 $error = 'comment_content_column_length'; … … 662 740 663 741 /** 664 742 * @ticket 10377 743 * 744 * @covers ::wp_handle_comment_submission 665 745 */ 666 746 public function test_submitting_comment_with_author_too_long_returns_error() { 667 747 $error = 'comment_author_column_length'; … … 680 760 681 761 /** 682 762 * @ticket 10377 763 * 764 * @covers ::wp_handle_comment_submission 683 765 */ 684 766 public function test_submitting_comment_with_email_too_long_returns_error() { 685 767 $error = 'comment_author_email_column_length'; … … 698 780 699 781 /** 700 782 * @ticket 10377 783 * 784 * @covers ::wp_handle_comment_submission 701 785 */ 702 786 public function test_submitting_comment_with_url_too_long_returns_error() { 703 787 $error = 'comment_author_url_column_length'; … … 717 801 718 802 /** 719 803 * @ticket 49236 804 * 805 * @covers ::wp_handle_comment_submission 720 806 */ 721 807 public function test_submitting_comment_with_empty_type_results_in_correct_type() { 722 808 $data = array( … … 736 822 737 823 /** 738 824 * @ticket 49236 825 * 826 * @covers ::wp_handle_comment_submission 739 827 */ 740 828 public function test_inserting_comment_with_empty_type_results_in_correct_type() { 741 829 $data = array( … … 756 844 757 845 /** 758 846 * @ticket 34997 847 * 848 * @covers ::wp_handle_comment_submission 759 849 */ 760 850 public function test_comment_submission_sends_all_expected_parameters_to_preprocess_comment_filter() { 761 851 … … 798 888 799 889 /** 800 890 * @ticket 36901 891 * 892 * @covers ::wp_handle_comment_submission 801 893 */ 802 894 public function test_submitting_duplicate_comments() { 803 895 $data = array( … … 814 906 815 907 /** 816 908 * @ticket 36901 909 * 910 * @covers ::wp_handle_comment_submission 817 911 */ 818 912 public function test_comments_flood() { 819 913 $data = array( … … 833 927 834 928 /** 835 929 * @ticket 36901 930 * 931 * @covers ::wp_handle_comment_submission 836 932 */ 837 933 public function test_comments_flood_user_is_admin() { 838 934 $user = self::factory()->user->create_and_get( -
tests/phpunit/tests/comment.php
30 30 ); 31 31 } 32 32 33 /** 34 * 35 * 36 * @covers ::wp_update_comment 37 */ 33 38 public function test_wp_update_comment() { 34 39 $post = self::factory()->post->create_and_get( 35 40 array( … … 78 83 79 84 /** 80 85 * @ticket 30627 86 * 87 * @covers ::wp_update_comment 81 88 */ 82 89 public function test_wp_update_comment_updates_comment_type() { 83 90 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); … … 95 102 96 103 /** 97 104 * @ticket 36784 105 * 106 * @covers ::wp_update_comment 98 107 */ 99 108 public function test_wp_update_comment_updates_comment_meta() { 100 109 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); … … 114 123 115 124 /** 116 125 * @ticket 30307 126 * 127 * @covers ::wp_update_comment 117 128 */ 118 129 public function test_wp_update_comment_updates_user_id() { 119 130 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); … … 131 142 132 143 /** 133 144 * @ticket 34954 145 * 146 * @covers ::wp_update_comment 134 147 */ 135 148 public function test_wp_update_comment_with_no_post_id() { 136 149 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => 0 ) ); … … 152 165 153 166 /** 154 167 * @ticket 39732 168 * 169 * @covers ::wp_update_comment 155 170 */ 156 171 public function test_wp_update_comment_returns_false_for_invalid_comment_or_post_id() { 157 172 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); … … 175 190 176 191 /** 177 192 * @ticket 39732 193 * 194 * @covers ::wp_update_comment 178 195 */ 179 196 public function test_wp_update_comment_is_wp_error() { 180 197 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); … … 201 218 return new WP_Error( 'comment_wrong', 'wp_update_comment_data filter fails for this comment.', 500 ); 202 219 } 203 220 221 /** 222 * 223 * 224 * @covers ::get_approved_comments 225 */ 204 226 public function test_get_approved_comments() { 205 227 $ca1 = self::factory()->comment->create( 206 228 array( … … 257 279 258 280 /** 259 281 * @ticket 30412 282 * 283 * @covers ::get_approved_comments 260 284 */ 261 285 public function test_get_approved_comments_with_post_id_0_should_return_empty_array() { 262 286 $ca1 = self::factory()->comment->create( … … 273 297 274 298 /** 275 299 * @ticket 14279 300 * 301 * @covers ::wp_new_comment 276 302 */ 277 303 public function test_wp_new_comment_respects_dates() { 278 304 $data = array( … … 296 322 297 323 /** 298 324 * @ticket 14601 325 * 326 * @covers ::wp_new_comment 299 327 */ 300 328 public function test_wp_new_comment_respects_author_ip() { 301 329 $data = array( … … 317 345 318 346 /** 319 347 * @ticket 14601 348 * 349 * @covers ::wp_new_comment 320 350 */ 321 351 public function test_wp_new_comment_respects_author_ip_empty_string() { 322 352 $data = array( … … 338 368 339 369 /** 340 370 * @ticket 14601 371 * 372 * @covers ::wp_new_comment 341 373 */ 342 374 public function test_wp_new_comment_respects_comment_agent() { 343 375 $data = array( … … 360 392 361 393 /** 362 394 * @ticket 14601 395 * 396 * @covers ::wp_new_comment 363 397 */ 364 398 public function test_wp_new_comment_should_trim_provided_comment_agent_to_254_chars() { 365 399 $data = array( … … 382 416 383 417 /** 384 418 * @ticket 14601 419 * 420 * @covers ::wp_new_comment 385 421 */ 386 422 public function test_wp_new_comment_respects_comment_agent_empty_string() { 387 423 $data = array( … … 402 438 $this->assertEquals( $data['comment_agent'], $comment->comment_agent ); 403 439 } 404 440 405 441 /** 442 * @covers ::wp_new_comment 443 */ 406 444 public function test_comment_field_lengths() { 407 445 $data = array( 408 446 'comment_post_ID' => self::$post_id, … … 424 462 425 463 /** 426 464 * @ticket 32566 465 * 466 * @covers ::wp_notify_moderator 427 467 */ 428 468 public function test_wp_notify_moderator_should_not_throw_notice_when_post_author_is_0() { 429 469 $p = self::factory()->post->create( … … 441 481 $this->assertTrue( wp_notify_moderator( $c ) ); 442 482 } 443 483 484 /** 485 * 486 * 487 * @covers ::wp_new_comment_notify_postauthor 488 */ 444 489 public function test_wp_new_comment_notify_postauthor_should_send_email_when_comment_is_approved() { 445 490 $c = self::factory()->comment->create( 446 491 array( … … 452 497 $this->assertTrue( $sent ); 453 498 } 454 499 500 /** 501 * 502 * 503 * @covers ::wp_new_comment_notify_postauthor 504 */ 455 505 public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_is_unapproved() { 456 506 $c = self::factory()->comment->create( 457 507 array( … … 466 516 467 517 /** 468 518 * @ticket 33587 519 * 520 * @covers ::wp_new_comment_notify_postauthor 469 521 */ 470 522 public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() { 471 523 $c = self::factory()->comment->create( … … 481 533 482 534 /** 483 535 * @ticket 35006 536 * 537 * @covers ::wp_new_comment_notify_postauthor 484 538 */ 485 539 public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_trashed() { 486 540 $c = self::factory()->comment->create( … … 496 550 497 551 /** 498 552 * @ticket 43805 553 * 554 * @covers ::wp_new_comment_notify_postauthor 499 555 */ 500 556 public function test_wp_new_comment_notify_postauthor_content_should_include_link_to_parent() { 501 557 $c1 = self::factory()->comment->create( … … 520 576 521 577 /** 522 578 * @ticket 43805 579 * 580 * @covers ::wp_new_comment_notify_moderator 523 581 */ 524 582 public function test_wp_new_comment_notify_moderator_content_should_include_link_to_parent() { 525 583 $c1 = self::factory()->comment->create( … … 556 614 557 615 /** 558 616 * @ticket 12431 617 * 618 * @covers ::get_comment_meta 559 619 */ 560 620 public function test_wp_new_comment_with_meta() { 561 621 $c = self::factory()->comment->create( … … 573 633 574 634 /** 575 635 * @ticket 8071 636 * 637 * @covers WP_Comment::get_children 576 638 */ 577 639 public function test_wp_comment_get_children_should_fill_children() { 578 640 $c1 = self::factory()->comment->create( … … 633 695 634 696 /** 635 697 * @ticket 27571 698 * 699 * @covers ::get_comment 636 700 */ 637 701 public function test_post_properties_should_be_lazyloaded() { 638 702 $c = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); … … 684 748 685 749 /** 686 750 * @ticket 761 751 * 752 * @covers ::wp_new_comment 687 753 */ 688 754 public function test_wp_notify_moderator_filter_moderation_notify_option_true_filter_false() { 689 755 $comment_data = $this->setup_notify_comment(); … … 705 771 706 772 /** 707 773 * @ticket 761 774 * 775 * @covers ::wp_new_comment 708 776 */ 709 777 public function test_wp_notify_moderator_filter_moderation_notify_option_false_filter_true() { 710 778 $comment_data = $this->setup_notify_comment(); … … 726 794 727 795 /** 728 796 * @ticket 761 797 * 798 * @covers ::wp_new_comment 729 799 */ 730 800 public function test_wp_notify_post_author_filter_comments_notify_option_true_filter_false() { 731 801 … … 748 818 749 819 /** 750 820 * @ticket 761 821 * 822 * @covers ::wp_new_comment 751 823 */ 752 824 public function test_wp_notify_post_author_filter_comments_notify_option_false_filter_true() { 753 825 $comment_data = $this->setup_notify_comment(); … … 852 924 return $email_sent_when_comment_approved || $email_sent_when_comment_added; 853 925 } 854 926 927 /** 928 * 929 * 930 * @covers ::_close_comments_for_old_post 931 */ 855 932 public function test_close_comments_for_old_post() { 856 933 update_option( 'close_comments_for_old_posts', true ); 857 934 // Close comments more than one day old. … … 867 944 $this->assertTrue( $new_post_comment_status ); 868 945 } 869 946 947 /** 948 * 949 * 950 * @covers ::_close_comments_for_old_post 951 */ 870 952 public function test_close_comments_for_old_post_undated_draft() { 871 953 $draft_id = self::factory()->post->create( 872 954 array( … … 881 963 882 964 /** 883 965 * @ticket 35276 966 * 967 * @covers ::wp_update_comment 884 968 */ 885 969 public function test_wp_update_comment_author_id_and_agent() { 886 970 … … 917 1001 $this->assertSame( 'SHIELD_AGENT', $updated->comment_agent ); 918 1002 } 919 1003 1004 /** 1005 * @covers ::wp_get_comment_fields_max_lengths 1006 */ 920 1007 public function test_wp_get_comment_fields_max_lengths() { 921 1008 $expected = array( 922 1009 'comment_author' => 245, … … 937 1024 * 938 1025 * @group privacy 939 1026 * @ticket 43442 1027 * 1028 * @covers ::wp_comments_personal_data_eraser 940 1029 */ 941 1030 public function test_wp_comments_personal_data_eraser() { 942 1031 … … 994 1083 * 995 1084 * @group privacy 996 1085 * @ticket 43442 1086 * 1087 * @covers ::wp_comments_personal_data_eraser 997 1088 */ 998 1089 public function test_wp_comments_personal_data_eraser_empty_first_page_output() { 999 1090 … … 1013 1104 * 1014 1105 * @group privacy 1015 1106 * @ticket 43442 1107 * 1108 * @covers ::wp_comments_personal_data_eraser 1016 1109 */ 1017 1110 public function test_wp_comments_personal_data_eraser_non_empty_first_page_output() { 1018 1111 … … 1045 1138 * 1046 1139 * @group privacy 1047 1140 * @ticket 43442 1141 * 1142 * @covers ::wp_comments_personal_data_eraser 1048 1143 */ 1049 1144 public function test_wp_comments_personal_data_eraser_empty_second_page_output() { 1050 1145 … … 1077 1172 * 1078 1173 * @group privacy 1079 1174 * @ticket 43442 1175 * 1176 * @covers ::wp_comments_personal_data_eraser 1080 1177 */ 1081 1178 public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization() { 1082 1179 … … 1114 1211 * 1115 1212 * @group privacy 1116 1213 * @ticket 43442 1214 * 1215 * @covers ::wp_comments_personal_data_eraser 1117 1216 */ 1118 1217 public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization_with_custom_message() { 1119 1218 … … 1179 1278 $this->assertSame( 'Bar', $comment->comment_author ); 1180 1279 } 1181 1280 1281 /** 1282 * 1283 * 1284 * @covers ::wp_trash_comment 1285 */ 1182 1286 public function test_trash_should_invalidate_comment_cache() { 1183 1287 global $wpdb; 1184 1288 … … 1193 1297 $this->assertSame( 'trash', $comment->comment_approved ); 1194 1298 } 1195 1299 1300 /** 1301 * 1302 * 1303 * @covers ::wp_untrash_comment 1304 */ 1196 1305 public function test_untrash_should_invalidate_comment_cache() { 1197 1306 global $wpdb; 1198 1307 … … 1209 1318 $this->assertSame( '1', $comment->comment_approved ); 1210 1319 } 1211 1320 1321 /** 1322 * 1323 * 1324 * @covers ::wp_spam_comment 1325 */ 1212 1326 public function test_spam_should_invalidate_comment_cache() { 1213 1327 global $wpdb; 1214 1328 … … 1223 1337 $this->assertSame( 'spam', $comment->comment_approved ); 1224 1338 } 1225 1339 1340 /** 1341 * 1342 * 1343 * @covers ::wp_unspam_comment 1344 */ 1226 1345 public function test_unspam_should_invalidate_comment_cache() { 1227 1346 global $wpdb; 1228 1347 … … 1244 1363 * 1245 1364 * @group privacy 1246 1365 * @ticket 43440 1366 * 1367 * @covers ::wp_comments_personal_data_exporter 1247 1368 */ 1248 1369 public function test_wp_comments_personal_data_exporter() { 1249 1370 $args = array( … … 1290 1411 * 1291 1412 * @group privacy 1292 1413 * @ticket 43440 1414 * 1415 * @covers ::wp_comments_personal_data_exporter 1293 1416 */ 1294 1417 public function test_wp_comments_personal_data_exporter_no_comments_found() { 1295 1418 … … 1308 1431 * 1309 1432 * @group privacy 1310 1433 * @ticket 43440 1434 * 1435 * @covers ::wp_comments_personal_data_exporter 1311 1436 */ 1312 1437 public function test_wp_comments_personal_data_exporter_empty_comment_prop() { 1313 1438 $args = array( … … 1339 1464 * 1340 1465 * @group privacy 1341 1466 * @ticket 43440 1467 * 1468 * @covers ::wp_comments_personal_data_exporter 1342 1469 */ 1343 1470 public function test_wp_comments_personal_data_exporter_empty_second_page() { 1344 1471 $args = array( -
tests/phpunit/tests/compat.php
34 34 35 35 /** 36 36 * @dataProvider utf8_string_lengths 37 * 38 * @covers ::_mb_strlen 37 39 */ 38 40 function test_mb_strlen( $string, $expected_character_length ) { 39 41 $this->assertEquals( $expected_character_length, _mb_strlen( $string, 'UTF-8' ) ); … … 41 43 42 44 /** 43 45 * @dataProvider utf8_string_lengths 46 * 47 * @covers ::_mb_strlen 44 48 */ 45 49 function test_mb_strlen_via_regex( $string, $expected_character_length ) { 46 50 _wp_can_use_pcre_u( false ); … … 50 54 51 55 /** 52 56 * @dataProvider utf8_string_lengths 57 * 58 * @covers ::_mb_strlen 53 59 */ 54 60 function test_8bit_mb_strlen( $string, $expected_character_length, $expected_byte_length ) { 55 61 $this->assertEquals( $expected_byte_length, _mb_strlen( $string, '8bit' ) ); … … 57 63 58 64 /** 59 65 * @dataProvider utf8_substrings 66 * 67 * @covers ::_mb_substr 60 68 */ 61 69 function test_mb_substr( $string, $start, $length, $expected_character_substring ) { 62 70 $this->assertEquals( $expected_character_substring, _mb_substr( $string, $start, $length, 'UTF-8' ) ); … … 64 72 65 73 /** 66 74 * @dataProvider utf8_substrings 75 * 76 * @covers ::_mb_substr 67 77 */ 68 78 function test_mb_substr_via_regex( $string, $start, $length, $expected_character_substring ) { 69 79 _wp_can_use_pcre_u( false ); … … 73 83 74 84 /** 75 85 * @dataProvider utf8_substrings 86 * 87 * @covers ::_mb_substr 76 88 */ 77 89 function test_8bit_mb_substr( $string, $start, $length, $expected_character_substring, $expected_byte_substring ) { 78 90 $this->assertEquals( $expected_byte_substring, _mb_substr( $string, $start, $length, '8bit' ) ); 79 91 } 80 92 93 /** 94 * 95 * @covers ::_mb_substr 96 */ 81 97 function test_mb_substr_phpcore() { 82 98 /* https://github.com/php/php-src/blob/php-5.6.8/ext/mbstring/tests/mb_substr_basic.phpt */ 83 99 $string_ascii = 'ABCDEF'; … … 164 180 165 181 } 166 182 183 /** 184 * 185 * @covers ::_hash_hmac 186 */ 167 187 function test_hash_hmac_simple() { 168 188 $this->assertEquals( '140d1cb79fa12e2a31f32d35ad0a2723', _hash_hmac( 'md5', 'simple', 'key' ) ); 169 189 $this->assertEquals( '993003b95758e0ac2eba451a4c5877eb1bb7b92a', _hash_hmac( 'sha1', 'simple', 'key' ) ); 170 190 } 171 191 192 /** 193 * 194 * @covers ::_hash_hmac 195 */ 172 196 function test_hash_hmac_padding() { 173 197 $this->assertEquals( '3c1399103807cf12ec38228614416a8c', _hash_hmac( 'md5', 'simple', '65 character key 65 character key 65 character key 65 character k' ) ); 174 198 $this->assertEquals( '4428826d20003e309d6c2a6515891370daf184ea', _hash_hmac( 'sha1', 'simple', '65 character key 65 character key 65 character key 65 character k' ) ); 175 199 } 176 200 201 /** 202 * 203 * @covers ::_hash_hmac 204 */ 177 205 function test_hash_hmac_output() { 178 206 $this->assertEquals( array( 1 => '140d1cb79fa12e2a31f32d35ad0a2723' ), unpack( 'H32', _hash_hmac( 'md5', 'simple', 'key', true ) ) ); 179 207 $this->assertEquals( array( 1 => '993003b95758e0ac2eba451a4c5877eb1bb7b92a' ), unpack( 'H40', _hash_hmac( 'sha1', 'simple', 'key', true ) ) ); … … 181 209 182 210 /** 183 211 * @expectedException PHPUnit_Framework_Error_Deprecated 212 * 213 * @covers Services_JSON::encodeUnsafe 214 * @covers Services_JSON::decode 184 215 */ 185 216 function test_json_encode_decode() { 186 217 require_once ABSPATH . WPINC . '/class-json.php'; … … 194 225 * Test that is_countable() is always available (either from PHP or WP). 195 226 * 196 227 * @ticket 43583 228 * 229 * @covers ::is_countable 197 230 */ 198 231 function test_is_countable_availability() { 199 232 $this->assertTrue( function_exists( 'is_countable' ) ); … … 208 241 * 209 242 * @param mixed $variable Variable to check. 210 243 * @param bool $is_countable The expected return value of PHP 7.3 is_countable() function. 244 * 245 * @covers ::is_countable 211 246 */ 212 247 function test_is_countable_functionality( $variable, $is_countable ) { 213 248 $this->assertSame( is_countable( $variable ), $is_countable ); … … 243 278 * Test is_countable() polyfill for ResourceBundle. 244 279 * 245 280 * @ticket 43583 281 * 282 * @covers ::is_countable 246 283 */ 247 284 function test_is_countable_ResourceBundle() { 248 285 if ( ! class_exists( 'ResourceBundle' ) ) { … … 256 293 * Test is_countable() polyfill for SimpleXMLElement. 257 294 * 258 295 * @ticket 43583 296 * 297 * @covers ::is_countable 259 298 */ 260 299 function test_is_countable_SimpleXMLElement() { 261 300 if ( ! class_exists( 'SimpleXMLElement' ) ) { … … 269 308 * Test that is_iterable() is always available (either from PHP or WP). 270 309 * 271 310 * @ticket 43619 311 * 312 * @covers ::is_iterable 272 313 */ 273 314 function test_is_iterable_availability() { 274 315 $this->assertTrue( function_exists( 'is_iterable' ) ); … … 283 324 * 284 325 * @param mixed $variable Variable to check. 285 326 * @param bool $is_iterable The expected return value of PHP 7.1 is_iterable() function. 327 * 328 * @covers ::is_iterable 286 329 */ 287 330 function test_is_iterable_functionality( $variable, $is_iterable ) { 288 331 $this->assertSame( is_iterable( $variable ), $is_iterable ); -
tests/phpunit/tests/cron.php
30 30 parent::tearDown(); 31 31 } 32 32 33 /** 34 * 35 * @covers ::wp_get_schedule 36 */ 33 37 function test_wp_get_schedule_empty() { 34 38 // Nothing scheduled. 35 39 $hook = __FUNCTION__; … … 36 40 $this->assertFalse( wp_get_schedule( $hook ) ); 37 41 } 38 42 43 /** 44 * 45 * @covers ::wp_schedule_single_event 46 */ 39 47 function test_schedule_event_single() { 40 48 // Schedule an event and make sure it's returned by wp_next_scheduled(). 41 49 $hook = __FUNCTION__; … … 50 58 51 59 } 52 60 61 /** 62 * 63 * @covers ::wp_schedule_single_event 64 */ 53 65 function test_schedule_event_single_args() { 54 66 // Schedule an event with arguments and make sure it's returned by wp_next_scheduled(). 55 67 $hook = 'event'; … … 68 80 $this->assertEquals( '', wp_get_schedule( $hook, $args ) ); 69 81 } 70 82 83 /** 84 * 85 * @covers ::wp_schedule_event 86 */ 71 87 function test_schedule_event() { 72 88 // Schedule an event and make sure it's returned by wp_next_scheduled(). 73 89 $hook = __FUNCTION__; … … 82 98 $this->assertEquals( $recur, wp_get_schedule( $hook ) ); 83 99 } 84 100 101 /** 102 * 103 * @covers ::wp_schedule_event 104 */ 85 105 function test_schedule_event_args() { 86 106 // Schedule an event and make sure it's returned by wp_next_scheduled(). 87 107 $hook = 'event'; … … 101 121 102 122 } 103 123 124 /** 125 * 126 * @covers ::wp_unschedule_event 127 */ 104 128 function test_unschedule_event() { 105 129 // Schedule an event and make sure it's returned by wp_next_scheduled(). 106 130 $hook = __FUNCTION__; … … 115 139 $this->assertEquals( false, wp_next_scheduled( $hook ) ); 116 140 } 117 141 142 /** 143 * 144 * @covers ::wp_clear_scheduled_hook 145 */ 118 146 function test_clear_schedule() { 119 147 $hook = __FUNCTION__; 120 148 $args = array( 'arg1' ); … … 142 170 $this->assertFalse( wp_next_scheduled( $hook, $args ) ); 143 171 } 144 172 173 /** 174 * 175 * @covers ::wp_clear_scheduled_hook 176 */ 145 177 function test_clear_undefined_schedule() { 146 178 $hook = __FUNCTION__; 147 179 $args = array( 'arg1' ); … … 154 186 $this->assertSame( 0, $hook_unscheduled ); 155 187 } 156 188 189 /** 190 * 191 * @covers ::wp_clear_scheduled_hook 192 */ 157 193 function test_clear_schedule_multiple_args() { 158 194 $hook = __FUNCTION__; 159 195 $args = array( 'arg1', 'arg2' ); … … 182 218 183 219 /** 184 220 * @ticket 10468 221 * 222 * @covers ::wp_clear_scheduled_hook 185 223 */ 186 224 function test_clear_schedule_new_args() { 187 225 $hook = __FUNCTION__; … … 220 258 221 259 /** 222 260 * @ticket 18997 261 * 262 * @covers ::wp_clear_scheduled_hook 223 263 */ 224 264 function test_unschedule_hook() { 225 265 $hook = __FUNCTION__; … … 240 280 $this->assertSame( 4, $unschedule_hook ); 241 281 $this->assertFalse( wp_next_scheduled( $hook ) ); 242 282 } 243 283 /** 284 * 285 * @covers ::wp_clear_scheduled_hook 286 */ 244 287 function test_unschedule_undefined_hook() { 245 288 $hook = __FUNCTION__; 246 289 $unrelated_hook = __FUNCTION__ . '_two'; … … 261 304 262 305 /** 263 306 * @ticket 6966 307 * 308 * @covers ::wp_schedule_single_event 264 309 */ 265 310 function test_duplicate_event() { 266 311 // Duplicate events close together should be skipped. … … 280 325 281 326 /** 282 327 * @ticket 6966 328 * 329 * @covers ::wp_schedule_single_event 283 330 */ 284 331 function test_not_duplicate_event() { 285 332 // Duplicate events far apart should work normally. … … 300 347 $this->assertEquals( $ts1, wp_next_scheduled( $hook, $args ) ); 301 348 } 302 349 350 /** 351 * 352 * @covers ::wp_schedule_single_event 353 */ 303 354 function test_not_duplicate_event_reversed() { 304 355 // Duplicate events far apart should work normally regardless of order. 305 356 $hook = __FUNCTION__; … … 324 375 * modification of the cron_array_option. 325 376 * 326 377 * @ticket 32656 378 * 379 * @covers ::wp_schedule_single_event 327 380 */ 328 381 function test_pre_schedule_event_filter() { 329 382 $hook = __FUNCTION__; … … 376 429 * modification of the cron_array_option. 377 430 * 378 431 * @ticket 32656 432 * 433 * @covers ::wp_schedule_event 379 434 */ 380 435 function test_pre_reschedule_event_filter() { 381 436 $hook = __FUNCTION__; … … 400 455 * modification of the cron_array_option. 401 456 * 402 457 * @ticket 32656 458 * 459 * @covers ::wp_unschedule_event 403 460 */ 404 461 function test_pre_unschedule_event_filter() { 405 462 $hook = __FUNCTION__; … … 424 481 * modification of the cron_array_option. 425 482 * 426 483 * @ticket 32656 484 * 485 * @covers ::wp_clear_scheduled_hook 427 486 */ 428 487 function test_pre_clear_scheduled_hook_filters() { 429 488 $hook = __FUNCTION__; … … 455 514 * return a filtered value as expected. 456 515 * 457 516 * @ticket 32656 517 * 518 * @covers ::wp_get_scheduled_event 458 519 */ 459 520 function test_pre_scheduled_event_hooks() { 460 521 add_filter( 'pre_get_scheduled_event', array( $this, 'filter_pre_scheduled_event_hooks' ) ); … … 489 550 * When a timestamp is specified, a particular event should be returned. 490 551 * 491 552 * @ticket 45976. 553 * 554 * @covers ::wp_get_scheduled_event 492 555 */ 493 556 function test_get_scheduled_event_singles() { 494 557 $hook = __FUNCTION__; … … 532 595 * When a timestamp is specified, a particular event should be returned. 533 596 * 534 597 * @ticket 45976. 598 * 599 * @covers ::wp_get_scheduled_event 535 600 */ 536 601 function test_get_scheduled_event_recurring() { 537 602 $hook = __FUNCTION__; … … 576 641 * Ensure wp_get_scheduled_event() returns false when expected. 577 642 * 578 643 * @ticket 45976. 644 * 645 * @covers ::wp_get_scheduled_event 579 646 */ 580 647 function test_get_scheduled_event_false() { 581 648 $hook = __FUNCTION__; … … 601 668 * Ensure any past event counts as a duplicate. 602 669 * 603 670 * @ticket 44818 671 * 672 * @covers ::wp_get_scheduled_event 604 673 */ 605 674 function test_duplicate_past_event() { 606 675 $hook = __FUNCTION__; … … 623 692 * Ensure any near future event counts as a duplicate. 624 693 * 625 694 * @ticket 44818 695 * 696 * @covers ::wp_get_scheduled_event 626 697 */ 627 698 function test_duplicate_near_future_event() { 628 699 $hook = __FUNCTION__; … … 645 716 * Duplicate future events are disallowed. 646 717 * 647 718 * @ticket 44818 719 * 720 * @covers ::wp_get_scheduled_event 648 721 */ 649 722 function test_duplicate_future_event() { 650 723 $hook = __FUNCTION__; … … 665 738 * Future events are allowed. 666 739 * 667 740 * @ticket 44818 741 * 742 * @covers ::wp_get_scheduled_event 668 743 */ 669 744 function test_not_duplicate_future_event() { 670 745 $hook = __FUNCTION__; -
tests/phpunit/tests/db.php
58 58 * Test that WPDB will reconnect when the DB link dies 59 59 * 60 60 * @ticket 5932 61 * 62 * @covers wpdb::db_connect 61 63 */ 62 64 public function test_db_reconnect() { 63 65 global $wpdb; … … 82 84 * @global mixed $wpdb 83 85 * 84 86 * @ticket 19861 87 * 88 * @covers wpdb::update 85 89 */ 86 90 public function test_locale_floats() { 87 91 global $wpdb; … … 128 132 129 133 /** 130 134 * @ticket 10041 135 * 136 * @covers wpdb::esc_like 131 137 */ 132 138 function test_esc_like() { 133 139 global $wpdb; … … 164 170 * @param $data string The haystack, raw. 165 171 * @param $like string The like phrase, raw. 166 172 * @param $result string The expected comparison result; '1' = true, '0' = false 173 * 174 * @covers wpdb::esc_like 167 175 */ 168 176 function test_like_query( $data, $like, $result ) { 169 177 global $wpdb; … … 227 235 228 236 /** 229 237 * @ticket 18510 238 * 239 * @coversNothing 230 240 */ 231 241 function test_wpdb_supposedly_protected_properties() { 232 242 global $wpdb; … … 243 253 244 254 /** 245 255 * @ticket 21212 256 * 257 * @coversNothing 246 258 */ 247 259 function test_wpdb_actually_protected_properties() { 248 260 global $wpdb; … … 274 286 * Test that an escaped %%f is not altered 275 287 * 276 288 * @ticket 19861 289 * 290 * @covers wpdb::placeholder_escape 291 * @covers wpdb::remove_placeholder_escape 277 292 */ 278 293 public function test_double_escaped_placeholders() { 279 294 global $wpdb; … … 289 304 * Test that SQL modes are set correctly 290 305 * 291 306 * @ticket 26847 307 * 308 * @covers wpdb::set_sql_mode 292 309 */ 293 310 function test_set_sql_mode() { 294 311 global $wpdb; … … 309 326 * Test that incompatible SQL modes are blocked 310 327 * 311 328 * @ticket 26847 329 * 330 * @covers wpdb::set_sql_mode 312 331 */ 313 332 function test_set_incompatible_sql_mode() { 314 333 global $wpdb; … … 327 346 * Test that incompatible SQL modes can be changed 328 347 * 329 348 * @ticket 26847 349 * 350 * @covers wpdb::set_sql_mode 330 351 */ 331 352 function test_set_allowed_incompatible_sql_mode() { 332 353 global $wpdb; … … 360 381 /** 361 382 * @ticket 25604 362 383 * @expectedIncorrectUsage wpdb::prepare 384 * 385 * @covers wpdb::prepare 363 386 */ 364 387 function test_prepare_without_arguments() { 365 388 global $wpdb; … … 370 393 $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0", $prepared ); 371 394 } 372 395 396 /** 397 * 398 * @covers wpdb::prepare 399 */ 373 400 function test_prepare_sprintf() { 374 401 global $wpdb; 375 402 … … 379 406 380 407 /** 381 408 * @expectedIncorrectUsage wpdb::prepare 409 * 410 * @covers wpdb::prepare 382 411 */ 383 412 function test_prepare_sprintf_invalid_args() { 384 413 global $wpdb; … … 392 421 $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared ); 393 422 } 394 423 424 /** 425 * 426 * @covers wpdb::prepare 427 */ 395 428 function test_prepare_vsprintf() { 396 429 global $wpdb; 397 430 … … 401 434 402 435 /** 403 436 * @expectedIncorrectUsage wpdb::prepare 437 * 438 * @covers wpdb::prepare 404 439 */ 405 440 function test_prepare_vsprintf_invalid_args() { 406 441 global $wpdb; … … 418 453 * @ticket 42040 419 454 * @dataProvider data_prepare_incorrect_arg_count 420 455 * @expectedIncorrectUsage wpdb::prepare 456 * 457 * @covers wpdb::prepare 421 458 */ 422 459 public function test_prepare_incorrect_arg_count( $query, $args, $expected ) { 423 460 global $wpdb; … … 479 516 ); 480 517 } 481 518 519 /** 520 * 521 * @covers wpdb::db_version 522 */ 482 523 function test_db_version() { 483 524 global $wpdb; 484 525 485 526 $this->assertTrue( version_compare( $wpdb->db_version(), '5.0', '>=' ) ); 486 527 } 487 528 /** 529 * 530 * @covers wpdb::get_caller 531 */ 488 532 function test_get_caller() { 489 533 global $wpdb; 490 534 $str = $wpdb->get_caller(); … … 493 537 $this->assertEquals( $called, end( $calls ) ); 494 538 } 495 539 540 /** 541 * 542 * @covers wpdb::has_cap 543 */ 496 544 function test_has_cap() { 497 545 global $wpdb; 498 546 $this->assertTrue( $wpdb->has_cap( 'collation' ) ); … … 513 561 514 562 /** 515 563 * @expectedDeprecated supports_collation 564 * 565 * @covers wpdb::supports_collation 516 566 */ 517 567 function test_supports_collation() { 518 568 global $wpdb; … … 519 569 $this->assertTrue( $wpdb->supports_collation() ); 520 570 } 521 571 572 /** 573 * 574 * @covers wpdb::check_database_version 575 */ 522 576 function test_check_database_version() { 523 577 global $wpdb; 524 578 $this->assertEmpty( $wpdb->check_database_version() ); … … 526 580 527 581 /** 528 582 * @expectedException WPDieException 583 * 584 * @covers wpdb::bail 529 585 */ 530 586 function test_bail() { 531 587 global $wpdb; 532 588 $wpdb->bail( 'Database is dead.' ); 533 589 } 534 590 /** 591 * 592 * @covers wpdb::timer_start 593 * @covers wpdb::timer_stop 594 */ 535 595 function test_timers() { 536 596 global $wpdb; 537 597 … … 542 602 $this->assertNotEquals( $wpdb->time_start, $stop ); 543 603 $this->assertGreaterThan( $stop, $wpdb->time_start ); 544 604 } 545 605 /** 606 * 607 * @covers wpdb::get_col_info 608 */ 546 609 function test_get_col_info() { 547 610 global $wpdb; 548 611 … … 552 615 $this->assertEquals( array( $wpdb->users ), $wpdb->get_col_info( 'table' ) ); 553 616 $this->assertEquals( $wpdb->users, $wpdb->get_col_info( 'table', 0 ) ); 554 617 } 555 618 /** 619 * 620 * @covers wpdb::query 621 * @covers wpdb::delete 622 */ 556 623 function test_query_and_delete() { 557 624 global $wpdb; 558 625 $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); … … 561 628 $d_rows = $wpdb->delete( $wpdb->users, array( 'ID' => $wpdb->insert_id ) ); 562 629 $this->assertEquals( 1, $d_rows ); 563 630 } 564 631 /** 632 * 633 * @covers wpdb::query 634 * @covers wpdb::get_row 635 */ 565 636 function test_get_row() { 566 637 global $wpdb; 567 638 $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); … … 584 655 * @dataProvider data_test_get_col 585 656 * 586 657 * @ticket 45299 658 * 659 * @covers wpdb::get_col 587 660 */ 588 661 function test_get_col( $query, $expected, $last_result, $column ) { 589 662 global $wpdb; … … 664 737 ); 665 738 } 666 739 740 /** 741 * 742 * @covers wpdb::replace 743 */ 667 744 function test_replace() { 668 745 global $wpdb; 669 746 $rows1 = $wpdb->insert( $wpdb->users, array( 'display_name' => 'Walter Sobchak' ) ); … … 691 768 * wpdb::update() requires a WHERE condition. 692 769 * 693 770 * @ticket 26106 771 * 772 * @covers wpdb::update 694 773 */ 695 774 function test_empty_where_on_update() { 696 775 global $wpdb; … … 713 792 * mysqli_ incorrect flush and further sync issues. 714 793 * 715 794 * @ticket 28155 795 * 796 * @coversNothing 716 797 */ 717 798 function test_mysqli_flush_sync() { 718 799 global $wpdb; … … 873 954 /** 874 955 * @dataProvider data_get_table_from_query 875 956 * @ticket 21212 957 * 958 * @covers wpdb::get_table_from_query 876 959 */ 877 960 function test_get_table_from_query( $query, $table ) { 878 961 $this->assertEquals( $table, self::$_wpdb->get_table_from_query( $query ) ); … … 888 971 /** 889 972 * @dataProvider data_get_table_from_query_false 890 973 * @ticket 21212 974 * 975 * @covers wpdb::get_table_from_query 891 976 */ 892 977 function test_get_table_from_query_false( $query ) { 893 978 $this->assertFalse( self::$_wpdb->get_table_from_query( $query ) ); … … 915 1000 /** 916 1001 * @dataProvider data_get_escaped_table_from_show_query 917 1002 * @ticket 38751 1003 * 1004 * @covers wpdb::get_table_from_query 918 1005 */ 919 1006 function test_get_escaped_table_from_show_query( $query, $table ) { 920 1007 $this->assertEquals( $table, self::$_wpdb->get_table_from_query( $query ) ); … … 1030 1117 /** 1031 1118 * @dataProvider data_process_field_formats 1032 1119 * @ticket 21212 1120 * 1121 * @covers wpdb::process_field_formats 1033 1122 */ 1034 1123 function test_process_field_formats( $data, $format, $expected, $message ) { 1035 1124 $actual = self::$_wpdb->process_field_formats( $data, $format ); … … 1038 1127 1039 1128 /** 1040 1129 * @ticket 21212 1130 * 1131 * @covers wpdb::process_fields 1041 1132 */ 1042 1133 function test_process_fields() { 1043 1134 global $wpdb; … … 1068 1159 /** 1069 1160 * @ticket 21212 1070 1161 * @depends test_process_fields 1162 * 1163 * @covers wpdb::process_fields 1071 1164 */ 1072 1165 function test_process_fields_on_nonexistent_table( $data ) { 1073 1166 self::$_wpdb->suppress_errors( true ); … … 1078 1171 1079 1172 /** 1080 1173 * @ticket 21212 1174 * 1175 * @covers wpdb::get_table_charset 1081 1176 */ 1082 1177 function test_pre_get_table_charset_filter() { 1083 1178 add_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10, 2 ); … … 1092 1187 1093 1188 /** 1094 1189 * @ticket 21212 1190 * 1191 * @covers wpdb::get_col_charset 1095 1192 */ 1096 1193 function test_pre_get_col_charset_filter() { 1097 1194 add_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10, 3 ); … … 1106 1203 1107 1204 /** 1108 1205 * @ticket 15158 1206 * 1207 * @covers wpdb::insert 1109 1208 */ 1110 1209 function test_null_insert() { 1111 1210 global $wpdb; … … 1128 1227 1129 1228 /** 1130 1229 * @ticket 15158 1230 * 1231 * @covers wpdb::insert 1131 1232 */ 1132 1233 function test_null_update_value() { 1133 1234 global $wpdb; … … 1166 1267 1167 1268 /** 1168 1269 * @ticket 15158 1270 * 1271 * @covers wpdb::update 1169 1272 */ 1170 1273 function test_null_update_where() { 1171 1274 global $wpdb; … … 1204 1307 1205 1308 /** 1206 1309 * @ticket 15158 1310 * 1311 * @covers wpdb::delete 1207 1312 */ 1208 1313 function test_null_delete() { 1209 1314 global $wpdb; … … 1240 1345 1241 1346 /** 1242 1347 * @ticket 34903 1348 * 1349 * @covers wpdb::close 1243 1350 */ 1244 1351 function test_close() { 1245 1352 global $wpdb; … … 1259 1366 1260 1367 /** 1261 1368 * @ticket 36917 1369 * 1370 * @covers wpdb::determine_charset 1262 1371 */ 1263 1372 function test_charset_not_determined_when_disconnected() { 1264 1373 global $wpdb; … … 1277 1386 1278 1387 /** 1279 1388 * @ticket 36917 1389 * 1390 * @covers wpdb::determine_charset 1280 1391 */ 1281 1392 function test_charset_switched_to_utf8mb4() { 1282 1393 global $wpdb; … … 1296 1407 /** 1297 1408 * @ticket 32105 1298 1409 * @ticket 36917 1410 * 1411 * @covers wpdb::determine_charset 1299 1412 */ 1300 1413 function test_collate_switched_to_utf8mb4_520() { 1301 1414 global $wpdb; … … 1315 1428 /** 1316 1429 * @ticket 32405 1317 1430 * @ticket 36917 1431 * 1432 * @covers wpdb::determine_charset 1318 1433 */ 1319 1434 function test_non_unicode_collations() { 1320 1435 global $wpdb; … … 1333 1448 1334 1449 /** 1335 1450 * @ticket 37982 1451 * 1452 * @covers wpdb::determine_charset 1336 1453 */ 1337 1454 function test_charset_switched_to_utf8() { 1338 1455 global $wpdb; … … 1352 1469 1353 1470 /** 1354 1471 * @dataProvider data_prepare_with_placeholders 1472 * 1473 * @covers wpdb::prepare 1355 1474 */ 1356 1475 function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) { 1357 1476 global $wpdb; … … 1371 1490 1372 1491 /** 1373 1492 * @dataProvider data_prepare_with_placeholders 1493 * 1494 * @covers wpdb::prepare 1374 1495 */ 1375 1496 function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) { 1376 1497 global $wpdb; … … 1565 1686 1566 1687 /** 1567 1688 * @dataProvider data_escape_and_prepare 1689 * 1690 * @covers ::esc_sql 1691 /** 1692 * @coversNothing 1568 1693 */ 1694 */ 1569 1695 function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) { 1570 1696 global $wpdb; 1571 1697 … … 1612 1738 1613 1739 /** 1614 1740 * @expectedIncorrectUsage wpdb::prepare 1741 * 1742 * @covers wpdb::prepare 1615 1743 */ 1616 1744 function test_double_prepare() { 1617 1745 global $wpdb; … … 1623 1751 $this->assertNull( $query ); 1624 1752 } 1625 1753 1754 /** 1755 * 1756 * @covers wpdb::prepare 1757 */ 1626 1758 function test_prepare_numeric_placeholders_float_args() { 1627 1759 global $wpdb; 1628 1760 … … 1638 1770 $this->assertContains( ' second=2.2', $actual ); 1639 1771 } 1640 1772 1773 /** 1774 * 1775 * @covers wpdb::prepare 1776 */ 1641 1777 function test_prepare_numeric_placeholders_float_array() { 1642 1778 global $wpdb; 1643 1779 … … 1652 1788 $this->assertContains( ' second=2.2', $actual ); 1653 1789 } 1654 1790 1791 /** 1792 * 1793 * @covers wpdb::prepare 1794 */ 1655 1795 function test_query_unescapes_placeholders() { 1656 1796 global $wpdb; 1657 1797 … … 1671 1811 $this->assertEquals( $value, $actual ); 1672 1812 } 1673 1813 1814 /** 1815 * 1816 * @covers wpdb::placeholder_escape 1817 */ 1674 1818 function test_esc_sql_with_unsupported_placeholder_type() { 1675 1819 global $wpdb; 1676 1820 … … 1684 1828 /** 1685 1829 * @dataProvider parse_db_host_data_provider 1686 1830 * @ticket 41722 1831 * 1832 * @covers wpdb::parse_db_host 1687 1833 */ 1688 1834 public function test_parse_db_host( $host_string, $expect_bail, $host, $port, $socket, $is_ipv6 ) { 1689 1835 global $wpdb; -
tests/phpunit/tests/dbdelta.php
96 96 97 97 /** 98 98 * Test table creation. 99 * 100 * @covers ::dbDelta 99 101 */ 100 102 public function test_creating_a_table() { 101 103 … … 133 135 134 136 /** 135 137 * Test that it does nothing for an existing table. 138 * 139 * @covers ::dbDelta 136 140 */ 137 141 public function test_existing_table() { 138 142 … … 155 159 156 160 /** 157 161 * Test the column type is updated. 162 * 163 * @covers ::dbDelta 158 164 */ 159 165 public function test_column_type_change() { 160 166 … … 184 190 185 191 /** 186 192 * Test new column added. 193 * 194 * @covers ::dbDelta 187 195 */ 188 196 public function test_column_added() { 189 197 … … 218 226 * Test that it does nothing when a column is removed. 219 227 * 220 228 * @ticket 26801 229 * 230 * @covers ::dbDelta 221 231 */ 222 232 public function test_columns_arent_removed() { 223 233 … … 242 252 243 253 /** 244 254 * Test that nothing happens with $execute is false. 255 * 256 * @covers ::dbDelta 245 257 */ 246 258 public function test_no_execution() { 247 259 … … 275 287 276 288 /** 277 289 * Test inserting into the database 290 * 291 * @covers ::dbDelta 278 292 */ 279 293 public function test_insert_into_table() { 280 294 global $wpdb; … … 296 310 * Test that FULLTEXT indexes are detected. 297 311 * 298 312 * @ticket 14445 313 * 314 * @covers ::dbDelta 299 315 */ 300 316 public function test_fulltext_index() { 301 317 global $wpdb; … … 401 417 402 418 /** 403 419 * @ticket 31869 420 * 421 * @covers ::dbDelta 404 422 */ 405 423 function test_truncated_index() { 406 424 global $wpdb; … … 441 459 442 460 /** 443 461 * @ticket 36748 462 * 463 * @covers ::dbDelta 444 464 */ 445 465 function test_dont_downsize_text_fields() { 446 466 global $wpdb; … … 466 486 467 487 /** 468 488 * @ticket 36748 489 * 490 * @covers ::dbDelta 469 491 */ 470 492 function test_dont_downsize_blob_fields() { 471 493 global $wpdb; … … 491 513 492 514 /** 493 515 * @ticket 36748 516 * 517 * @covers ::dbDelta 494 518 */ 495 519 function test_upsize_text_fields() { 496 520 global $wpdb; … … 522 546 523 547 /** 524 548 * @ticket 36748 549 * 550 * @covers ::dbDelta 525 551 */ 526 552 function test_upsize_blob_fields() { 527 553 global $wpdb; … … 553 579 554 580 /** 555 581 * @ticket 20263 582 * 583 * @covers ::dbDelta 556 584 */ 557 585 function test_query_with_backticks_does_not_throw_an_undefined_index_warning() { 558 586 global $wpdb; … … 578 606 579 607 /** 580 608 * @ticket 36948 609 * 610 * @covers ::dbDelta 581 611 */ 582 612 function test_spatial_indices() { 583 613 global $wpdb; … … 639 669 640 670 /** 641 671 * @ticket 20263 672 * 673 * @covers ::dbDelta 642 674 */ 643 675 function test_query_with_backticks_does_not_cause_a_query_to_alter_all_columns_and_indices_to_run_even_if_none_have_changed() { 644 676 global $wpdb; … … 668 700 669 701 /** 670 702 * @ticket 20263 703 * 704 * @covers ::dbDelta 671 705 */ 672 706 function test_index_with_a_reserved_keyword_can_be_created() { 673 707 global $wpdb; … … 704 738 705 739 /** 706 740 * @ticket 20263 741 * 742 * @covers ::dbDelta 707 743 */ 708 744 function test_wp_get_db_schema_does_no_alter_queries_on_existing_install() { 709 745 $updates = dbDelta( wp_get_db_schema() ); … … 713 749 714 750 /** 715 751 * @ticket 20263 752 * 753 * @covers ::dbDelta 716 754 */ 717 755 function test_key_and_index_and_fulltext_key_and_fulltext_index_and_unique_key_and_unique_index_indicies() { 718 756 global $wpdb; … … 751 789 752 790 /** 753 791 * @ticket 20263 792 * 793 * @covers ::dbDelta 754 794 */ 755 795 function test_index_and_key_are_synonyms_and_do_not_recreate_indices() { 756 796 global $wpdb; … … 775 815 776 816 /** 777 817 * @ticket 20263 818 * 819 * @covers ::dbDelta 778 820 */ 779 821 function test_indices_with_prefix_limits_are_created_and_do_not_recreate_indices() { 780 822 global $wpdb; … … 809 851 810 852 /** 811 853 * @ticket 34959 854 * 855 * @covers ::dbDelta 812 856 */ 813 857 function test_index_col_names_with_order_do_not_recreate_indices() { 814 858 global $wpdb; … … 833 877 834 878 /** 835 879 * @ticket 34873 880 * 881 * @covers ::dbDelta 836 882 */ 837 883 function test_primary_key_with_single_space_does_not_recreate_index() { 838 884 global $wpdb; … … 857 903 858 904 /** 859 905 * @ticket 34869 906 * 907 * @covers ::dbDelta 860 908 */ 861 909 function test_index_definitions_with_spaces_do_not_recreate_indices() { 862 910 global $wpdb; … … 881 929 882 930 /** 883 931 * @ticket 34871 932 * 933 * @covers ::dbDelta 884 934 */ 885 935 function test_index_types_are_not_case_sensitive_and_do_not_recreate_indices() { 886 936 global $wpdb; … … 905 955 906 956 /** 907 957 * @ticket 34874 958 * 959 * @covers ::dbDelta 908 960 */ 909 961 function test_key_names_are_not_case_sensitive_and_do_not_recreate_indices() { 910 962 global $wpdb; … … 930 982 931 983 /** 932 984 * @ticket 34870 985 * 986 * @covers ::dbDelta 933 987 */ 934 988 function test_unchanged_key_lengths_do_not_recreate_index() { 935 989 global $wpdb; … … 955 1009 956 1010 /** 957 1011 * @ticket 34870 1012 * 1013 * @covers ::dbDelta 958 1014 */ 959 1015 function test_changed_key_lengths_do_not_recreate_index() { 960 1016 global $wpdb; … … 1039 1095 1040 1096 /** 1041 1097 * @ticket 31679 1098 * 1099 * @covers ::dbDelta 1042 1100 */ 1043 1101 function test_column_type_change_with_hyphens_in_name() { 1044 1102 global $wpdb; -
tests/phpunit/tests/dependencies.php
4 4 * @group scripts 5 5 */ 6 6 class Tests_Dependencies extends WP_UnitTestCase { 7 8 /** 9 * 10 * @covers WP_Dependencies::add 11 */ 7 12 function test_add() { 8 13 $dep = new WP_Dependencies; 9 14 … … 16 21 // Cannot reuse names. 17 22 $this->assertFalse( $dep->add( 'one', '' ) ); 18 23 } 19 24 /** 25 * 26 * @covers WP_Dependencies::remove 27 */ 20 28 function test_remove() { 21 29 $dep = new WP_Dependencies; 22 30 … … 29 37 $this->assertInstanceOf( '_WP_Dependency', $dep->query( 'two' ) ); 30 38 31 39 } 32 40 /** 41 * 42 * @covers WP_Dependencies::enqueue 43 */ 33 44 function test_enqueue() { 34 45 $dep = new WP_Dependencies; 35 46 … … 45 56 $this->assertTrue( $dep->query( 'one', 'queue' ) ); 46 57 $this->assertTrue( $dep->query( 'two', 'queue' ) ); 47 58 } 48 59 /** 60 * 61 * @covers WP_Dependencies::dequeue 62 */ 49 63 function test_dequeue() { 50 64 $dep = new WP_Dependencies; 51 65 … … 65 79 $this->assertFalse( $dep->query( 'one', 'queue' ) ); 66 80 $this->assertFalse( $dep->query( 'two', 'queue' ) ); 67 81 } 68 82 /** 83 * 84 * @covers WP_Dependencies::enqueue 85 */ 69 86 function test_enqueue_args() { 70 87 $dep = new WP_Dependencies; 71 88 … … 83 100 $this->assertTrue( $dep->query( 'two', 'queue' ) ); 84 101 $this->assertEquals( 'arg', $dep->args['two'] ); 85 102 } 86 103 /** 104 * 105 * @covers WP_Dependencies::dequeue 106 */ 87 107 function test_dequeue_args() { 88 108 $dep = new WP_Dependencies; 89 109 … … 110 130 111 131 /** 112 132 * @ticket 21741 133 * 134 * @covers WP_Dependencies::query 113 135 */ 114 136 function test_query_and_registered_enqueued() { 115 137 $dep = new WP_Dependencies; -
tests/phpunit/tests/dependencies/scripts.php
1045 1045 * Testing `wp_enqueue_code_editor` with file path. 1046 1046 * 1047 1047 * @ticket 41871 1048 * @covers ::wp_enqueue_code_editor ()1048 * @covers ::wp_enqueue_code_editor 1049 1049 */ 1050 1050 public function test_wp_enqueue_code_editor_when_php_file_will_be_passed() { 1051 1051 $real_file = WP_PLUGIN_DIR . '/hello.php'; … … 1132 1132 * Testing `wp_enqueue_code_editor` with `compact`. 1133 1133 * 1134 1134 * @ticket 41871 1135 * @covers ::wp_enqueue_code_editor ()1135 * @covers ::wp_enqueue_code_editor 1136 1136 */ 1137 1137 public function test_wp_enqueue_code_editor_when_generated_array_by_compact_will_be_passed() { 1138 1138 $file = ''; … … 1215 1215 * Testing `wp_enqueue_code_editor` with `array_merge`. 1216 1216 * 1217 1217 * @ticket 41871 1218 * @covers ::wp_enqueue_code_editor ()1218 * @covers ::wp_enqueue_code_editor 1219 1219 */ 1220 1220 public function test_wp_enqueue_code_editor_when_generated_array_by_array_merge_will_be_passed() { 1221 1221 $wp_enqueue_code_editor = wp_enqueue_code_editor( … … 1312 1312 * Testing `wp_enqueue_code_editor` with `array`. 1313 1313 * 1314 1314 * @ticket 41871 1315 * @covers ::wp_enqueue_code_editor ()1315 * @covers ::wp_enqueue_code_editor 1316 1316 */ 1317 1317 public function test_wp_enqueue_code_editor_when_simple_array_will_be_passed() { 1318 1318 $wp_enqueue_code_editor = wp_enqueue_code_editor( -
tests/phpunit/tests/file.php
16 16 /** 17 17 * @group plugins 18 18 * @group themes 19 * 20 * @cover ::get_file_data 19 21 */ 20 22 function test_get_file_data() { 21 23 $theme_headers = array( … … 46 48 /** 47 49 * @group plugins 48 50 * @group themes 51 * 52 * @cover ::get_file_data 49 53 */ 50 54 function test_get_file_data_cr_line_endings() { 51 55 $headers = array( … … 88 92 return $result; 89 93 } 90 94 95 /** 96 * 97 * @cover ::wp_unique_filename 98 */ 91 99 function test_unique_filename_is_valid() { 92 100 // Make sure it produces a valid, writable, unique filename. 93 101 $filename = wp_unique_filename( $this->dir, __FUNCTION__ . '.txt' ); … … 97 105 unlink( $this->dir . DIRECTORY_SEPARATOR . $filename ); 98 106 } 99 107 108 /** 109 * 110 * @cover ::wp_unique_filename 111 */ 100 112 function test_unique_filename_is_unique() { 101 113 // Make sure it produces two unique filenames. 102 114 $name = __FUNCTION__; … … 113 125 unlink( $this->dir . DIRECTORY_SEPARATOR . $filename2 ); 114 126 } 115 127 128 /** 129 * 130 * @cover ::wp_unique_filename 131 */ 116 132 function test_unique_filename_is_sanitized() { 117 133 $name = __FUNCTION__; 118 134 $filename = wp_unique_filename( $this->dir, $name . $this->badchars . '.txt' ); … … 125 141 unlink( $this->dir . DIRECTORY_SEPARATOR . $filename ); 126 142 } 127 143 144 /** 145 * 146 * @cover ::wp_unique_filename 147 */ 128 148 function test_unique_filename_with_slashes() { 129 149 $name = __FUNCTION__; 130 150 // "foo/foo.txt" … … 138 158 unlink( $this->dir . DIRECTORY_SEPARATOR . $filename ); 139 159 } 140 160 161 /** 162 * 163 * @cover ::wp_unique_filename 164 */ 141 165 function test_unique_filename_multiple_ext() { 142 166 $name = __FUNCTION__; 143 167 $filename = wp_unique_filename( $this->dir, $name . '.php.txt' ); … … 150 174 unlink( $this->dir . DIRECTORY_SEPARATOR . $filename ); 151 175 } 152 176 177 /** 178 * 179 * @cover ::wp_unique_filename 180 */ 153 181 function test_unique_filename_no_ext() { 154 182 $name = __FUNCTION__; 155 183 $filename = wp_unique_filename( $this->dir, $name ); … … 163 191 164 192 /** 165 193 * @dataProvider data_wp_tempnam_filenames 194 * 195 * @cover ::wp_tempnam 166 196 */ 167 197 function test_wp_tempnam( $case ) { 168 198 $file = wp_tempnam( $case ); … … 183 213 184 214 /** 185 215 * @ticket 47186 216 * 217 * @cover ::verify_file_signature 186 218 */ 187 219 function test_file_signature_functions_as_expected() { 188 220 $file = wp_tempnam(); … … 216 248 217 249 /** 218 250 * @ticket 47186 251 * 252 * @cover ::verify_file_signature 219 253 */ 220 254 function test_file_signature_expected_failure() { 221 255 $file = wp_tempnam(); -
tests/phpunit/tests/filters.php
7 7 */ 8 8 class Tests_Filters extends WP_UnitTestCase { 9 9 10 /** 11 * @covers ::add_filter 12 */ 10 13 function test_simple_filter() { 11 14 $a = new MockAction(); 12 15 $tag = __FUNCTION__; … … 25 28 $this->assertEquals( array( $val ), $args ); 26 29 } 27 30 31 /** 32 * @covers ::remove_filter 33 */ 28 34 function test_remove_filter() { 29 35 $a = new MockAction(); 30 36 $tag = __FUNCTION__; … … 45 51 46 52 } 47 53 54 /** 55 * @covers ::has_filter 56 */ 48 57 function test_has_filter() { 49 58 $tag = __FUNCTION__; 50 59 $func = __FUNCTION__ . '_func'; … … 59 68 $this->assertFalse( has_filter( $tag ) ); 60 69 } 61 70 62 // One tag with multiple filters. 71 /** 72 * One tag with multiple filters. 73 * 74 * @covers ::add_filter 75 */ 63 76 function test_multiple_filters() { 64 77 $a1 = new MockAction(); 65 78 $a2 = new MockAction(); … … 77 90 $this->assertEquals( 1, $a2->get_call_count() ); 78 91 } 79 92 93 /** 94 * One tag with multiple filters. 95 * 96 * @covers ::add_filter 97 */ 80 98 function test_filter_args_1() { 81 99 $a = new MockAction(); 82 100 $tag = __FUNCTION__; … … 92 110 $this->assertEquals( array( $val, $arg1 ), array_pop( $argsvar ) ); 93 111 } 94 112 113 /** 114 * One tag with multiple filters. 115 * 116 * @covers ::add_filter 117 */ 95 118 function test_filter_args_2() { 96 119 $a1 = new MockAction(); 97 120 $a2 = new MockAction(); … … 117 140 $this->assertEquals( array( $val ), array_pop( $argsvar2 ) ); 118 141 } 119 142 143 /** 144 * One tag with multiple filters. 145 * 146 * @covers ::add_filter 147 */ 120 148 function test_filter_priority() { 121 149 $a = new MockAction(); 122 150 $tag = __FUNCTION__; … … 148 176 $this->assertEquals( $expected, $a->get_events() ); 149 177 } 150 178 179 /** 180 * One tag with multiple filters. 181 * 182 * @covers ::add_filter 183 */ 151 184 function test_all_filter() { 152 185 $a = new MockAction(); 153 186 $tag1 = __FUNCTION__ . '_1'; … … 172 205 173 206 } 174 207 208 /** 209 * One tag with multiple filters. 210 * 211 * @covers ::add_filter 212 */ 175 213 function test_remove_all_filter() { 176 214 $a = new MockAction(); 177 215 $tag = __FUNCTION__; … … 198 236 199 237 /** 200 238 * @ticket 20920 239 * 240 * @covers ::add_filter 201 241 */ 202 242 function test_remove_all_filters_should_respect_the_priority_argument() { 203 243 $a = new MockAction(); … … 217 257 218 258 /** 219 259 * @ticket 9886 260 * 261 * @covers ::add_filter 220 262 */ 221 263 function test_filter_ref_array() { 222 264 $obj = new stdClass(); … … 236 278 237 279 /** 238 280 * @ticket 12723 281 * 282 * @covers ::add_filter 239 283 */ 240 284 function test_filter_ref_array_result() { 241 285 $obj = new stdClass(); … … 271 315 272 316 /** 273 317 * @ticket 29070 318 * 319 * @covers ::has_filter 274 320 */ 275 321 function test_has_filter_after_remove_all_filters() { 276 322 $a = new MockAction(); … … 298 344 /** 299 345 * @ticket 10441 300 346 * @expectedDeprecated tests_apply_filters_deprecated 347 * 348 * @covers ::apply_filters_deprecated 301 349 */ 302 350 public function test_apply_filters_deprecated() { 303 351 $p = 'Foo'; … … 317 365 /** 318 366 * @ticket 10441 319 367 * @expectedDeprecated tests_apply_filters_deprecated 368 * 369 * @covers ::apply_filters_deprecated 320 370 */ 321 371 public function test_apply_filters_deprecated_with_multiple_params() { 322 372 $p1 = 'Foo1'; … … 341 391 342 392 /** 343 393 * @ticket 10441 394 * 395 * @covers ::apply_filters_deprecated 344 396 */ 345 397 public function test_apply_filters_deprecated_without_filter() { 346 398 $val = 'Foobar'; … … 351 403 private $current_priority; 352 404 /** 353 405 * @ticket 39007 406 * 407 * @covers ::add_action 354 408 */ 355 409 public function test_current_priority() { 356 410 add_action( 'test_current_priority', array( $this, '_current_priority_action' ), 99 ); … … 360 414 $this->assertSame( 99, $this->current_priority ); 361 415 } 362 416 417 /** 418 * One tag with multiple filters. 419 */ 363 420 public function _current_priority_action() { 364 421 global $wp_filter; 365 422 $this->current_priority = $wp_filter[ current_filter() ]->current_priority(); … … 367 424 368 425 /** 369 426 * @ticket 39007 427 * 428 * @covers ::add_action 370 429 */ 371 430 public function test_other_priority() { 372 431 add_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 ); -
tests/phpunit/tests/functions.php
4 4 * @group functions.php 5 5 */ 6 6 class Tests_Functions extends WP_UnitTestCase { 7 8 /** 9 * 10 * @covers ::wp_parse_args 11 */ 7 12 function test_wp_parse_args_object() { 8 13 $x = new MockClass; 9 14 $x->_baba = 5; … … 21 26 $this->assertEquals( array(), wp_parse_args( $y ) ); 22 27 } 23 28 29 30 /** 31 * 32 * @covers ::wp_parse_args 33 */ 24 34 function test_wp_parse_args_array() { 25 35 // Arrays. 26 36 $a = array(); … … 40 50 ); 41 51 } 42 52 53 54 /** 55 * 56 * @covers ::wp_parse_args 57 */ 43 58 function test_wp_parse_args_defaults() { 44 59 $x = new MockClass; 45 60 $x->_baba = 5; … … 66 81 ); 67 82 } 68 83 84 85 /** 86 * 87 * @covers ::wp_parse_args 88 */ 69 89 function test_wp_parse_args_other() { 70 90 $b = true; 71 91 wp_parse_str( $b, $s ); … … 77 97 78 98 /** 79 99 * @ticket 30753 100 * 101 * @covers ::wp_parse_args 80 102 */ 81 103 function test_wp_parse_args_boolean_strings() { 82 104 $args = wp_parse_args( 'foo=false&bar=true' ); … … 86 108 87 109 /** 88 110 * @ticket 35972 111 * 112 * @covers ::bool_from_yn 89 113 */ 90 114 function test_bool_from_yn() { 91 115 $this->assertTrue( bool_from_yn( 'Y' ) ); … … 93 117 $this->assertFalse( bool_from_yn( 'n' ) ); 94 118 } 95 119 120 /** 121 * 122 * @covers ::path_is_absolute 123 */ 96 124 function test_path_is_absolute() { 97 125 $absolute_paths = array( 98 126 '/', … … 111 139 } 112 140 } 113 141 142 /** 143 * 144 * @covers ::path_is_absolute 145 */ 114 146 function test_path_is_not_absolute() { 115 147 $relative_paths = array( 116 148 '', … … 134 166 * @ticket 35996 135 167 * 136 168 * @dataProvider data_wp_normalize_path 169 * @covers ::wp_normalize_path 137 170 */ 138 171 function test_wp_normalize_path( $path, $expected ) { 139 172 $this->assertEquals( $expected, wp_normalize_path( $path ) ); … … 163 196 ); 164 197 } 165 198 199 200 /** 201 * 202 * @covers ::wp_unique_filename 203 */ 166 204 function test_wp_unique_filename() { 167 205 168 206 $testdir = DIR_TESTDATA . '/images/'; … … 198 236 199 237 /** 200 238 * @ticket 42437 239 * 240 * @covers ::wp_unique_filename 201 241 */ 202 242 function test_unique_filename_with_dimension_like_filename() { 203 243 $testdir = DIR_TESTDATA . '/images/'; … … 223 263 224 264 /** 225 265 * @dataProvider data_is_not_serialized 266 * 267 * @covers ::serialize 226 268 */ 227 269 function test_maybe_serialize( $value ) { 228 270 if ( is_array( $value ) || is_object( $value ) ) { … … 236 278 237 279 /** 238 280 * @dataProvider data_is_serialized 281 * 282 * @covers ::serialize 239 283 */ 240 284 function test_maybe_serialize_with_double_serialization( $value ) { 241 285 $expected = serialize( $value ); … … 246 290 /** 247 291 * @dataProvider data_is_serialized 248 292 * @dataProvider data_is_not_serialized 293 * 294 * @covers ::maybe_unserialize 249 295 */ 250 296 function test_maybe_unserialize( $value, $is_serialized ) { 251 297 if ( $is_serialized ) { … … 264 310 /** 265 311 * @dataProvider data_is_serialized 266 312 * @dataProvider data_is_not_serialized 313 * 314 * @covers ::is_serialized 267 315 */ 268 316 function test_is_serialized( $value, $expected ) { 269 317 $this->assertSame( $expected, is_serialized( $value ) ); … … 324 372 /** 325 373 * @ticket 46570 326 374 * @dataProvider data_is_serialized_should_return_true_for_large_floats 375 * 376 * @covers ::is_serialized 327 377 */ 328 378 function test_is_serialized_should_return_true_for_large_floats( $value ) { 329 379 $this->assertTrue( is_serialized( $value ) ); … … 338 388 339 389 /** 340 390 * @ticket 17375 391 * 392 * @covers ::is_serialized 341 393 */ 342 394 function test_no_new_serializable_types() { 343 395 $this->assertFalse( is_serialized( 'C:16:"Serialized_Class":6:{a:0:{}}' ) ); … … 345 397 346 398 /** 347 399 * @group add_query_arg 400 * 401 * @covers ::add_query_arg 348 402 */ 349 403 function test_add_query_arg() { 350 404 $old_req_uri = $_SERVER['REQUEST_URI']; … … 533 587 534 588 /** 535 589 * @ticket 31306 590 * 591 * @covers ::add_query_arg 536 592 */ 537 593 function test_add_query_arg_numeric_keys() { 538 594 $url = add_query_arg( array( 'foo' => 'bar' ), '1=1' ); … … 553 609 554 610 /** 555 611 * @ticket 21594 612 * 613 * @covers ::get_allowed_mime_types 556 614 */ 557 615 function test_get_allowed_mime_types() { 558 616 $mimes = get_allowed_mime_types(); … … 573 631 574 632 /** 575 633 * @ticket 21594 634 * 635 * @covers ::wp_get_mime_types 576 636 */ 577 637 function test_wp_get_mime_types() { 578 638 $mimes = wp_get_mime_types(); … … 605 665 606 666 /** 607 667 * @ticket 23688 668 * 669 * @covers ::get_option 670 * @covers ::_canonical_charset 608 671 */ 609 672 function test_canonical_charset() { 610 673 $orig_blog_charset = get_option( 'blog_charset' ); … … 643 706 /** 644 707 * @ticket 43977 645 708 * @dataProvider data_wp_parse_list 709 * 710 * @covers ::wp_parse_list 646 711 */ 647 712 function test_wp_parse_list( $expected, $actual ) { 648 713 $this->assertSame( $expected, array_values( wp_parse_list( $actual ) ) ); … … 666 731 667 732 /** 668 733 * @dataProvider data_wp_parse_id_list 734 * 735 * @covers ::wp_parse_id_list 669 736 */ 670 737 function test_wp_parse_id_list( $expected, $actual ) { 671 738 $this->assertSame( $expected, array_values( wp_parse_id_list( $actual ) ) ); … … 701 768 702 769 /** 703 770 * @dataProvider data_device_can_upload 771 * 772 * @covers ::_device_can_upload 704 773 */ 705 774 function test_device_can_upload( $user_agent, $expected ) { 706 775 $_SERVER['HTTP_USER_AGENT'] = $user_agent; … … 761 830 762 831 /** 763 832 * @ticket 9064 833 * 834 * @covers ::wp_extract_urls 764 835 */ 765 836 function test_wp_extract_urls() { 766 837 $original_urls = array( … … 928 999 929 1000 /** 930 1001 * @ticket 28786 1002 * 1003 * @covers ::wp_json_encode 931 1004 */ 932 1005 function test_wp_json_encode() { 933 1006 $this->assertEquals( wp_json_encode( 'a' ), '"a"' ); … … 935 1008 936 1009 /** 937 1010 * @ticket 28786 1011 * 1012 * @covers ::wp_json_encode 938 1013 */ 939 1014 function test_wp_json_encode_utf8() { 940 1015 $this->assertEquals( wp_json_encode( '这' ), '"\u8fd9"' ); … … 942 1017 943 1018 /** 944 1019 * @ticket 28786 1020 * 1021 * @covers ::wp_json_encode 945 1022 */ 946 1023 function test_wp_json_encode_non_utf8() { 947 1024 if ( ! function_exists( 'mb_detect_order' ) ) { … … 967 1044 968 1045 /** 969 1046 * @ticket 28786 1047 * 1048 * @covers ::wp_json_encode 970 1049 */ 971 1050 function test_wp_json_encode_non_utf8_in_array() { 972 1051 if ( ! function_exists( 'mb_detect_order' ) ) { … … 992 1071 993 1072 /** 994 1073 * @ticket 28786 1074 * 1075 * @covers ::wp_json_encode 995 1076 */ 996 1077 function test_wp_json_encode_array() { 997 1078 $this->assertEquals( wp_json_encode( array( 'a' ) ), '["a"]' ); … … 999 1080 1000 1081 /** 1001 1082 * @ticket 28786 1083 * 1084 * @covers ::wp_json_encode 1002 1085 */ 1003 1086 function test_wp_json_encode_object() { 1004 1087 $object = new stdClass; … … 1008 1091 1009 1092 /** 1010 1093 * @ticket 28786 1094 * 1095 * @covers ::wp_json_encode 1011 1096 */ 1012 1097 function test_wp_json_encode_depth() { 1013 1098 $data = array( array( array( 1, 2, 3 ) ) ); … … 1022 1107 /** 1023 1108 * @ticket 36054 1024 1109 * @dataProvider datetime_provider 1110 * 1111 * @covers ::mysql_to_rfc3339 1025 1112 */ 1026 1113 function test_mysql_to_rfc3339( $expected, $actual ) { 1027 1114 $date_return = mysql_to_rfc3339( $actual ); … … 1044 1131 1045 1132 /** 1046 1133 * @ticket 35987 1134 * 1135 * @covers ::wp_get_ext_types 1047 1136 */ 1048 1137 public function test_wp_get_ext_types() { 1049 1138 $extensions = wp_get_ext_types(); … … 1063 1152 1064 1153 /** 1065 1154 * @ticket 35987 1155 * 1156 * @covers ::wp_get_ext_types 1066 1157 */ 1067 1158 public function test_wp_ext2type() { 1068 1159 $extensions = wp_get_ext_types(); … … 1084 1175 * test suite is -1, we can not test the memory limit negotiations. 1085 1176 * 1086 1177 * @ticket 32075 1178 * 1179 * @covers ::wp_raise_memory_limit 1087 1180 */ 1088 1181 function test_wp_raise_memory_limit() { 1089 1182 if ( -1 !== WP_MAX_MEMORY_LIMIT ) { … … 1102 1195 /** 1103 1196 * Tests wp_generate_uuid4(). 1104 1197 * 1198 * @ticket 38164 1199 * 1105 1200 * @covers ::wp_generate_uuid4 1106 * @ticket 381641107 1201 */ 1108 1202 function test_wp_generate_uuid4() { 1109 1203 $uuids = array(); … … 1120 1214 /** 1121 1215 * Tests wp_is_uuid(). 1122 1216 * 1217 * @ticket 39778 1218 * 1123 1219 * @covers ::wp_is_uuid 1124 * @ticket 397781125 1220 */ 1126 1221 function test_wp_is_valid_uuid() { 1127 1222 $uuids_v4 = array( … … 1170 1265 /** 1171 1266 * Tests wp_unique_id(). 1172 1267 * 1268 * @ticket 44883 1269 * 1173 1270 * @covers ::wp_unique_id 1174 * @ticket 448831175 1271 */ 1176 1272 function test_wp_unique_id() { 1177 1273 … … 1198 1294 /** 1199 1295 * @ticket 40017 1200 1296 * @dataProvider _wp_get_image_mime 1297 * 1298 * @covers ::wp_get_image_mime 1201 1299 */ 1202 1300 public function test_wp_get_image_mime( $file, $expected ) { 1203 1301 if ( ! is_callable( 'exif_imagetype' ) && ! function_exists( 'getimagesize' ) ) { … … 1210 1308 /** 1211 1309 * @ticket 39550 1212 1310 * @dataProvider _wp_check_filetype_and_ext_data 1311 * 1312 * @covers ::wp_check_filetype_and_ext 1213 1313 */ 1214 1314 function test_wp_check_filetype_and_ext( $file, $filename, $expected ) { 1215 1315 if ( ! extension_loaded( 'fileinfo' ) ) { … … 1222 1322 /** 1223 1323 * @ticket 39550 1224 1324 * @group ms-excluded 1325 * 1326 * @covers ::wp_check_filetype_and_ext 1225 1327 */ 1226 1328 function test_wp_check_filetype_and_ext_with_filtered_svg() { 1227 1329 if ( ! extension_loaded( 'fileinfo' ) ) { … … 1247 1349 /** 1248 1350 * @ticket 39550 1249 1351 * @group ms-excluded 1352 * 1353 * @covers ::wp_check_filetype_and_ext 1250 1354 */ 1251 1355 function test_wp_check_filetype_and_ext_with_filtered_woff() { 1252 1356 if ( ! extension_loaded( 'fileinfo' ) ) { … … 1488 1592 * @param string $file File path. 1489 1593 * @param array $allowed_files List of allowed files. 1490 1594 * @param int $expected Expected result. 1595 * 1596 * @covers ::validate_file 1491 1597 */ 1492 1598 public function test_validate_file( $file, $allowed_files, $expected ) { 1493 1599 $this->assertSame( $expected, validate_file( $file, $allowed_files ) ); … … 1630 1736 * 1631 1737 * @param string $path The resource path or URL. 1632 1738 * @param bool $expected Expected result. 1739 * 1740 * @covers ::wp_is_stream 1633 1741 */ 1634 1742 public function test_wp_is_stream( $path, $expected ) { 1635 1743 if ( ! extension_loaded( 'openssl' ) && false !== strpos( $path, 'https://' ) ) { … … 1674 1782 * 1675 1783 * @param string $input Duration. 1676 1784 * @param string $expected Expected human readable duration. 1785 * 1786 * @covers ::human_readable_duration 1677 1787 */ 1678 1788 public function test_human_readable_duration( $input, $expected ) { 1679 1789 $this->assertSame( $expected, human_readable_duration( $input ) ); -
tests/phpunit/tests/kses.php
9 9 10 10 /** 11 11 * @ticket 20210 12 * 13 * @covers ::wp_kses 12 14 */ 13 15 function test_wp_filter_post_kses_address() { 14 16 global $allowedposttags; … … 36 38 37 39 /** 38 40 * @ticket 20210 41 * 42 * @covers ::wp_kses 39 43 */ 40 44 function test_wp_filter_post_kses_a() { 41 45 global $allowedposttags; … … 77 81 * @param string $source Source HTML. 78 82 * @param string $context Context to use for parsing source. 79 83 * @param string $expected Expected output following KSES parsing. 84 * 85 * @covers ::wp_kses 80 86 */ 81 87 function test_wp_kses_video( $source, $context, $expected ) { 82 88 $actual = wp_kses( $source, $context ); … … 123 129 124 130 /** 125 131 * @ticket 20210 132 * 133 * @covers ::wp_kses 126 134 */ 127 135 function test_wp_filter_post_kses_abbr() { 128 136 global $allowedposttags; … … 141 149 } 142 150 } 143 151 152 /** 153 * 154 * @covers ::wp_kses 155 */ 144 156 function test_feed_links() { 145 157 global $allowedposttags; 146 158 … … 175 187 $this->assertEquals( $expected, wp_kses( $content, $allowedposttags ) ); 176 188 } 177 189 190 /** 191 * 192 * @covers ::wp_kses_bad_protocol 193 */ 178 194 function test_wp_kses_bad_protocol() { 179 195 $bad = array( 180 196 'dummy:alert(1)', … … 277 293 } 278 294 } 279 295 296 /** 297 * 298 * @covers ::wp_kses_data 299 */ 280 300 public function test_hackers_attacks() { 281 301 $xss = simplexml_load_file( DIR_TESTDATA . '/formatting/xssAttacks.xml' ); 282 302 foreach ( $xss->attack as $attack ) { … … 421 441 422 442 /** 423 443 * @ticket 20210 444 * 445 * @covers ::wp_kses_allowed_html 424 446 */ 425 447 public function test_wp_kses_allowed_html() { 426 448 global $allowedposttags, $allowedtags, $allowedentitynames; … … 470 492 $this->assertEquals( $allowedtags, wp_kses_allowed_html( 'data' ) ); 471 493 } 472 494 495 /** 496 * 497 * @covers ::wp_kses_post 498 */ 473 499 function test_hyphenated_tag() { 474 500 $string = '<hyphenated-tag attribute="value" otherattribute="value2">Alot of hyphens.</hyphenated-tag>'; 475 501 $custom_tags = array( … … 486 512 487 513 /** 488 514 * @ticket 26290 515 * 516 * @covers ::wp_kses_normalize_entities 489 517 */ 490 518 public function test_wp_kses_normalize_entities() { 491 519 $this->assertEquals( '♠', wp_kses_normalize_entities( '♠' ) ); … … 504 532 * 505 533 * @ticket 28506 506 534 * @dataProvider data_ctrl_removal 535 * 536 * @covers ::wp_kses 507 537 */ 508 538 function test_ctrl_removal( $input, $output ) { 509 539 global $allowedposttags; … … 541 571 * 542 572 * @ticket 28699 543 573 * @dataProvider data_slash_zero_removal 574 * 575 * @covers ::wp_kses 544 576 */ 545 577 function test_slash_zero_removal( $input, $output ) { 546 578 global $allowedposttags; … … 593 625 * Test new function wp_kses_hair_parse(). 594 626 * 595 627 * @dataProvider data_hair_parse 628 * 629 * @covers ::wp_kses_hair_parse 596 630 */ 597 631 function test_hair_parse( $input, $output ) { 598 632 return $this->assertEquals( $output, wp_kses_hair_parse( $input ) ); … … 659 693 * Test new function wp_kses_attr_parse(). 660 694 * 661 695 * @dataProvider data_attr_parse 696 * 697 * @covers ::wp_kses_attr_parse 662 698 */ 663 699 function test_attr_parse( $input, $output ) { 664 700 return $this->assertEquals( $output, wp_kses_attr_parse( $input ) ); … … 717 753 * Test new function wp_kses_one_attr(). 718 754 * 719 755 * @dataProvider data_one_attr 756 * 757 * @covers ::wp_kses_one_attr 720 758 */ 721 759 function test_one_attr( $element, $input, $output ) { 722 760 return $this->assertEquals( $output, wp_kses_one_attr( $input, $element ) ); … … 794 832 795 833 /** 796 834 * @ticket 34063 835 * 836 * @covers ::wp_kses 797 837 */ 798 838 function test_bdo() { 799 839 global $allowedposttags; … … 805 845 806 846 /** 807 847 * @ticket 35079 848 * 849 * @covers ::wp_kses 808 850 */ 809 851 function test_ol_reversed() { 810 852 global $allowedposttags; … … 816 858 817 859 /** 818 860 * @ticket 40680 861 * 862 * @covers ::wp_kses_attr 819 863 */ 820 864 function test_wp_kses_attr_no_attributes_allowed_with_empty_array() { 821 865 $element = 'foo'; … … 826 870 827 871 /** 828 872 * @ticket 40680 873 * 874 * @covers ::wp_kses_attr 829 875 */ 830 876 function test_wp_kses_attr_no_attributes_allowed_with_true() { 831 877 $element = 'foo'; … … 836 882 837 883 /** 838 884 * @ticket 40680 885 * 886 * @covers ::wp_kses_attr 839 887 */ 840 888 function test_wp_kses_attr_single_attribute_is_allowed() { 841 889 $element = 'foo'; … … 846 894 847 895 /** 848 896 * @ticket 43312 897 * 898 * @covers ::wp_kses_attr 849 899 */ 850 900 function test_wp_kses_attr_no_attributes_allowed_with_false() { 851 901 $element = 'foo'; … … 864 914 * 865 915 * @param string $css A string of CSS rules. 866 916 * @param string $expected Expected string of CSS rules. 917 * 918 * @covers ::safecss_filter_attr 867 919 */ 868 920 public function test_safecss_filter_attr( $css, $expected ) { 869 921 $this->assertSame( $expected, safecss_filter_attr( $css ) ); … … 1052 1104 * Data attributes are globally accepted. 1053 1105 * 1054 1106 * @ticket 33121 1107 * 1108 * @covers ::wp_kses_post 1055 1109 */ 1056 1110 function test_wp_kses_attr_data_attribute_is_allowed() { 1057 1111 $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>'; … … 1064 1118 * Ensure wildcard attributes block unprefixed wildcard uses. 1065 1119 * 1066 1120 * @ticket 33121 1121 * 1122 * @covers ::wp_kses 1067 1123 */ 1068 1124 function test_wildcard_requires_hyphen_after_prefix() { 1069 1125 $allowed_html = array( … … 1085 1141 * Ensure wildcard allows two hyphen. 1086 1142 * 1087 1143 * @ticket 33121 1144 * 1145 * @covers ::wp_kses 1088 1146 */ 1089 1147 function test_wildcard_allows_two_hyphens() { 1090 1148 $allowed_html = array( … … 1107 1165 * @dataProvider data_wildcard_attribute_prefixes 1108 1166 * 1109 1167 * @ticket 33121 1168 * 1169 * @covers ::wp_kses_attr_check 1110 1170 */ 1111 1171 function test_wildcard_attribute_prefixes( $wildcard_attribute, $expected ) { 1112 1172 $allowed_html = array( … … 1152 1212 * 1153 1213 * @param $input string The style attribute saved in the editor. 1154 1214 * @param $expected string The sanitized style attribute. 1215 * 1216 * @covers ::safecss_filter_attr 1155 1217 */ 1156 1218 function test_kses_style_attr_with_url( $input, $expected ) { 1157 1219 $actual = safecss_filter_attr( $input ); … … 1299 1361 * 1300 1362 * @param string $css A string of CSS rules. 1301 1363 * @param string $expected Expected string of CSS rules. 1364 * 1365 * @covers ::safecss_filter_attr 1302 1366 */ 1303 1367 public function test_safecss_filter_attr_filtered( $css, $expected ) { 1304 1368 add_filter( 'safecss_filter_attr_allow_css', '__return_true' ); … … 1366 1430 * Test filtering a standard img tag. 1367 1431 * 1368 1432 * @ticket 50731 1433 * 1434 * @covers ::wp_kses_post 1369 1435 */ 1370 1436 function test_wp_kses_img_tag_standard_attributes() { 1371 1437 $html = array( -
tests/phpunit/tests/l10n.php
17 17 18 18 /** 19 19 * @ticket 35961 20 * 21 * @covers ::_n_noop 20 22 */ 21 23 function test_n_noop() { 22 24 $text_domain = 'text-domain'; … … 30 32 31 33 /** 32 34 * @ticket 35961 35 * 36 * @covers ::_nx_noop 33 37 */ 34 38 function test_nx_noop() { 35 39 $text_domain = 'text-domain'; … … 44 48 45 49 /** 46 50 * @ticket 35073 51 * 52 * @covers ::before_last_bar 47 53 */ 48 54 function test_before_last_bar() { 49 55 $this->assertEquals( 'no-bar-at-all', before_last_bar( 'no-bar-at-all' ) ); … … 53 59 54 60 /** 55 61 * @ticket 35950 62 * 63 * @covers ::get_available_languages 56 64 */ 57 65 function test_get_available_languages() { 58 66 $array = get_available_languages(); … … 67 75 68 76 /** 69 77 * @ticket 35284 78 * 79 * @covers ::wp_get_installed_translations 70 80 */ 71 81 function test_wp_get_installed_translations_for_core() { 72 82 $installed_translations = wp_get_installed_translations( 'core' ); … … 89 99 90 100 /** 91 101 * @ticket 35294 102 * 103 * @covers ::wp_dropdown_languages 92 104 */ 93 105 function test_wp_dropdown_languages() { 94 106 $args = array( … … 111 123 112 124 /** 113 125 * @ticket 38632 126 * 127 * @covers ::wp_dropdown_languages 114 128 */ 115 129 function test_wp_dropdown_languages_site_default() { 116 130 $args = array( … … 135 149 136 150 /** 137 151 * @ticket 44494 152 * 153 * @covers ::wp_dropdown_languages 138 154 */ 139 155 function test_wp_dropdown_languages_exclude_en_us() { 140 156 $args = array( … … 153 169 154 170 /** 155 171 * @ticket 38632 172 * 173 * @covers ::wp_dropdown_languages 156 174 */ 157 175 function test_wp_dropdown_languages_en_US_selected() { 158 176 $args = array( … … 175 193 176 194 /** 177 195 * Add site default language to ja_JP in dropdown 196 * 197 * @covers ::wp_dropdown_languages 178 198 */ 179 199 function test_wp_dropdown_languages_site_default_ja_JP() { 180 200 $args = array( … … 199 219 200 220 /** 201 221 * Select dropdown language from de_DE to ja_JP 222 * 223 * @covers ::wp_dropdown_languages 202 224 */ 203 225 function test_wp_dropdown_languages_ja_JP_selected() { 204 226 $args = array( … … 246 268 247 269 /** 248 270 * @ticket 35284 271 * 272 * @covers ::wp_get_pomo_file_data 249 273 */ 250 274 function test_wp_get_pomo_file_data() { 251 275 $file = DIR_TESTDATA . '/pomo/empty.po'; … … 272 296 273 297 /** 274 298 * @ticket 44541 299 * 300 * @covers ::the_excerpt 275 301 */ 276 302 function test_length_of_excerpt_should_be_counted_by_words() { 277 303 global $post; … … 296 322 297 323 /** 298 324 * @ticket 44541 325 * 326 * @covers ::the_excerpt 299 327 */ 300 328 function test_length_of_excerpt_should_be_counted_by_chars() { 301 329 global $post; … … 320 348 321 349 /** 322 350 * @ticket 44541 351 * 352 * @covers ::the_excerpt 323 353 */ 324 354 function test_length_of_excerpt_should_be_counted_by_chars_in_japanese() { 325 355 global $post; … … 344 374 345 375 /** 346 376 * @ticket 44541 377 * 378 * @covers ::the_excerpt_rss 347 379 */ 348 380 function test_length_of_excerpt_rss_should_be_counted_by_words() { 349 381 global $post; … … 368 400 369 401 /** 370 402 * @ticket 44541 403 * 404 * @covers ::the_excerpt_rss 371 405 */ 372 406 function test_length_of_excerpt_rss_should_be_counted_by_chars() { 373 407 global $post; … … 393 427 394 428 /** 395 429 * @ticket 44541 430 * 431 * @covers ::wp_dashboard_recent_drafts 396 432 */ 397 433 function test_length_of_draft_should_be_counted_by_words() { 398 434 require_once ABSPATH . 'wp-admin/includes/dashboard.php'; … … 417 453 418 454 /** 419 455 * @ticket 44541 456 * 457 * @covers ::wp_dashboard_recent_drafts 420 458 */ 421 459 function test_length_of_draft_should_be_counted_by_chars() { 422 460 require_once ABSPATH . 'wp-admin/includes/dashboard.php'; … … 441 479 442 480 /** 443 481 * @ticket 44541 482 * 483 * @covers ::wp_dashboard_recent_drafts 444 484 */ 445 485 function test_length_of_draft_should_be_counted_by_chars_in_japanese() { 446 486 require_once ABSPATH . 'wp-admin/includes/dashboard.php'; … … 465 505 466 506 /** 467 507 * @ticket 44541 508 * 509 * @covers ::get_comment_excerpt 468 510 */ 469 511 function test_length_of_comment_excerpt_should_be_counted_by_words() { 470 512 switch_to_locale( 'en_US' ); … … 483 525 484 526 /** 485 527 * @ticket 44541 528 * 529 * @covers ::get_comment_excerpt 486 530 */ 487 531 function test_length_of_comment_excerpt_should_be_counted_by_chars() { 488 532 switch_to_locale( 'ja_JP' ); … … 501 545 502 546 /** 503 547 * @ticket 44541 548 * 549 * @covers ::get_comment_excerpt 504 550 */ 505 551 function test_length_of_comment_excerpt_should_be_counted_by_chars_in_Japanese() { 506 552 switch_to_locale( 'ja_JP' ); -
tests/phpunit/tests/link.php
10 10 11 11 /** 12 12 * @ticket 8847 13 * 14 * @covers ::get_pagenum_link 13 15 */ 14 16 function test_get_pagenum_link_case_insensitivity() { 15 17 $old_req_uri = $_SERVER['REQUEST_URI']; … … 26 28 $_SERVER['REQUEST_URI'] = $old_req_uri; 27 29 } 28 30 31 /** 32 * 33 * @covers ::wp_get_shortlink 34 */ 29 35 function test_wp_get_shortlink() { 30 36 $post_id = self::factory()->post->create(); 31 37 $post_id2 = self::factory()->post->create(); … … 70 76 $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink() ); 71 77 } 72 78 79 /** 80 * 81 * @covers ::wp_get_shortlink 82 */ 73 83 function test_wp_get_shortlink_with_page() { 74 84 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 75 85 … … 84 94 85 95 /** 86 96 * @ticket 26871 97 * 98 * @covers ::wp_get_shortlink 87 99 */ 88 100 function test_wp_get_shortlink_with_home_page() { 89 101 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); … … 99 111 100 112 /** 101 113 * @ticket 30910 114 * 115 * @covers ::get_permalink 102 116 */ 103 117 public function test_get_permalink_should_not_reveal_post_name_for_post_with_post_status_future() { 104 118 update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' ); … … 114 128 115 129 $non_pretty_permalink = add_query_arg( 'p', $p, trailingslashit( home_url() ) ); 116 130 117 $this->assert Equals( $non_pretty_permalink, get_permalink( $p ) );131 $this->assertSame( $non_pretty_permalink, get_permalink( $p ) ); 118 132 } 119 133 120 134 /** 121 135 * @ticket 30910 136 * 137 * @covers ::get_permalink 122 138 */ 123 139 public function test_get_permalink_should_not_reveal_post_name_for_cpt_with_post_status_future() { 124 140 update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' ); … … 148 164 149 165 /** 150 166 * @ticket 1914 167 * 168 * @covers ::get_permalink 151 169 */ 152 170 public function test_unattached_attachment_has_a_pretty_permalink() { 153 171 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); … … 170 188 171 189 /** 172 190 * @ticket 1914 191 * 192 * @covers ::get_permalink 173 193 */ 174 194 public function test_attachment_attached_to_non_existent_post_type_has_a_pretty_permalink() { 175 195 global $wp_post_types; -
tests/phpunit/tests/locale.php
15 15 $this->locale = new WP_Locale(); 16 16 } 17 17 18 /** 19 * 20 * @covers WP_Locale::get_weekday 21 */ 18 22 public function test_get_weekday() { 19 23 $this->assertEquals( __( 'Sunday' ), $this->locale->get_weekday( 0 ) ); 20 24 $this->assertEquals( __( 'Monday' ), $this->locale->get_weekday( 1 ) ); … … 27 31 28 32 /** 29 33 * @expectedException PHPUnit_Framework_Error_Notice 34 * 35 * @covers WP_Locale::get_weekday 30 36 */ 31 37 public function test_get_weekday_undefined_index() { 32 38 $this->locale->get_weekday( 7 ); 33 39 } 34 40 41 /** 42 * 43 * @covers WP_Locale::get_weekday_initial 44 */ 35 45 public function test_get_weekday_initial() { 36 46 $this->assertEquals( __( 'S' ), $this->locale->get_weekday_initial( __( 'Sunday' ) ) ); 37 47 $this->assertEquals( __( 'M' ), $this->locale->get_weekday_initial( __( 'Monday' ) ) ); … … 42 52 $this->assertEquals( __( 'S' ), $this->locale->get_weekday_initial( __( 'Saturday' ) ) ); 43 53 } 44 54 55 /** 56 * 57 * @covers WP_Locale::get_weekday_abbrev 58 */ 45 59 public function test_get_weekday_abbrev() { 46 60 $this->assertEquals( __( 'Sun' ), $this->locale->get_weekday_abbrev( __( 'Sunday' ) ) ); 47 61 $this->assertEquals( __( 'Mon' ), $this->locale->get_weekday_abbrev( __( 'Monday' ) ) ); … … 52 66 $this->assertEquals( __( 'Sat' ), $this->locale->get_weekday_abbrev( __( 'Saturday' ) ) ); 53 67 } 54 68 69 /** 70 * 71 * @covers WP_Locale::get_month 72 */ 55 73 public function test_get_month() { 56 74 $this->assertEquals( __( 'January' ), $this->locale->get_month( 1 ) ); 57 75 $this->assertEquals( __( 'February' ), $this->locale->get_month( 2 ) ); … … 67 85 $this->assertEquals( __( 'December' ), $this->locale->get_month( 12 ) ); 68 86 } 69 87 88 /** 89 * 90 * @covers WP_Locale::get_month 91 */ 70 92 public function test_get_month_leading_zero() { 71 93 $this->assertEquals( __( 'January' ), $this->locale->get_month( '01' ) ); 72 94 $this->assertEquals( __( 'February' ), $this->locale->get_month( '02' ) ); … … 79 101 $this->assertEquals( __( 'September' ), $this->locale->get_month( '09' ) ); 80 102 } 81 103 104 /** 105 * 106 * @covers WP_Locale::get_month_abbrev 107 */ 82 108 public function test_get_month_abbrev() { 83 109 $this->assertEquals( __( 'Jan' ), $this->locale->get_month_abbrev( __( 'January' ) ) ); 84 110 $this->assertEquals( __( 'Feb' ), $this->locale->get_month_abbrev( __( 'February' ) ) ); … … 94 120 $this->assertEquals( __( 'Dec' ), $this->locale->get_month_abbrev( __( 'December' ) ) ); 95 121 } 96 122 123 /** 124 * 125 * @covers WP_Locale::get_meridiem 126 */ 97 127 public function test_get_meridiem() { 98 128 $this->assertEquals( __( 'am' ), $this->locale->get_meridiem( 'am' ) ); 99 129 $this->assertEquals( __( 'AM' ), $this->locale->get_meridiem( 'AM' ) ); … … 101 131 $this->assertEquals( __( 'PM' ), $this->locale->get_meridiem( 'PM' ) ); 102 132 } 103 133 134 /** 135 * 136 * @covers WP_Locale::is_rtl 137 */ 104 138 public function test_is_rtl() { 105 139 $this->assertFalse( $this->locale->is_rtl() ); 106 140 $this->locale->text_direction = 'foo'; -
tests/phpunit/tests/mail.php
21 21 * when it encounters a line longer than 999 characters. But PHPMailer doesn't clean up after itself / presets 22 22 * all variables, which means that following tests would fail. To solve this issue we set `$this->Encoding` 23 23 * back to 8bit in `MockPHPMailer::preSend`. 24 * 25 * @covers ::wp_mail 24 26 */ 25 27 function test_wp_mail_break_it() { 26 28 $content = str_repeat( 'A', 1000 ); … … 27 29 $this->assertTrue( wp_mail( WP_TESTS_EMAIL, 'Looong line testing', $content ) ); 28 30 } 29 31 32 /** 33 * 34 * @covers ::wp_mail 35 */ 30 36 function test_wp_mail_custom_boundaries() { 31 37 $to = 'user@example.com'; 32 38 $subject = 'Test email with custom boundaries'; … … 87 93 88 94 /** 89 95 * @ticket 17305 96 * 97 * @covers ::wp_mail 90 98 */ 91 99 function test_wp_mail_rfc2822_addresses() { 92 100 $to = 'Name <address@tld.com>'; … … 117 125 118 126 /** 119 127 * @ticket 17305 128 * 129 * @covers ::wp_mail 120 130 */ 121 131 function test_wp_mail_multiple_rfc2822_to_addresses() { 122 132 $to = 'Name <address@tld.com>, Another Name <another_address@different-tld.com>'; … … 135 145 $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); 136 146 } 137 147 148 /** 149 * 150 * @covers ::wp_mail 151 */ 138 152 function test_wp_mail_multiple_to_addresses() { 139 153 $to = 'address@tld.com, another_address@different-tld.com'; 140 154 $subject = 'RFC2822 Testing'; … … 150 164 151 165 /** 152 166 * @ticket 18463 167 * 168 * @covers ::wp_mail 153 169 */ 154 170 function test_wp_mail_to_address_no_name() { 155 171 $to = '<address@tld.com>'; … … 165 181 166 182 /** 167 183 * @ticket 23642 184 * 185 * @covers ::wp_mail 168 186 */ 169 187 function test_wp_mail_return_value() { 170 188 // No errors. … … 179 197 180 198 /** 181 199 * @ticket 30266 200 * 201 * @covers ::wp_mail 182 202 */ 183 203 public function test_wp_mail_with_valid_from_header() { 184 204 $to = 'address@tld.com'; … … 195 215 196 216 /** 197 217 * @ticket 30266 218 * 219 * @covers ::wp_mail 198 220 */ 199 221 public function test_wp_mail_with_empty_from_header() { 200 222 $to = 'address@tld.com'; … … 211 233 212 234 /** 213 235 * @ticket 30266 236 * 237 * @covers ::wp_mail 214 238 */ 215 239 public function test_wp_mail_with_empty_from_name_for_the_from_header() { 216 240 $to = 'address@tld.com'; … … 227 251 228 252 /** 229 253 * @ticket 30266 254 * 255 * @covers ::wp_mail 230 256 */ 231 257 public function test_wp_mail_with_valid_content_type_header() { 232 258 $to = 'address@tld.com'; … … 243 269 244 270 /** 245 271 * @ticket 30266 272 * 273 * @covers ::wp_mail 246 274 */ 247 275 public function test_wp_mail_with_empty_content_type_header() { 248 276 $to = 'address@tld.com'; … … 259 287 260 288 /** 261 289 * @ticket 30266 290 * 291 * @covers ::wp_mail 262 292 */ 263 293 public function test_wp_mail_with_empty_charset_for_the_content_type_header() { 264 294 $to = 'address@tld.com'; … … 275 305 276 306 /** 277 307 * @ticket 43542 308 * 309 * @covers ::wp_mail 278 310 */ 279 311 public function test_wp_mail_does_not_duplicate_mime_version_header() { 280 312 $to = 'user@example.com'; … … 308 340 * https://tools.ietf.org/html/rfc2045#section-6.1 309 341 * 310 342 * @ticket 28039 343 * 344 * @covers ::wp_mail 311 345 */ 312 346 function test_wp_mail_content_transfer_encoding_in_quoted_printable_multipart() { 313 347 add_action( 'phpmailer_init', array( $this, 'wp_mail_quoted_printable' ) ); … … 325 359 326 360 /** 327 361 * @ticket 21659 362 * 363 * @covers ::wp_mail 328 364 */ 329 365 public function test_wp_mail_addresses_arent_encoded() { 330 366 $to = 'Lukáš To <to@example.org>'; … … 367 403 * set it correctly. 368 404 * 369 405 * @ticket 37736 406 * 407 * @covers ::wp_mail 370 408 */ 371 409 public function test_wp_mail_sender_not_set() { 372 410 wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should not have been set.' ); … … 378 416 379 417 /** 380 418 * @ticket 35598 419 * 420 * @covers ::wp_mail 381 421 */ 382 422 public function test_phpmailer_exception_thrown() { 383 423 $to = 'an_invalid_address'; … … 410 450 411 451 /** 412 452 * @ticket 50720 453 * 454 * @coversNothing 413 455 */ 414 456 function test_phpmailer_validator() { 415 457 $phpmailer = $GLOBALS['phpmailer']; -
tests/phpunit/tests/media.php
46 46 ); 47 47 } 48 48 49 /** 50 * @covers ::add_shortcode 51 */ 49 52 function test_img_caption_shortcode_added() { 50 53 global $shortcode_tags; 51 54 $this->assertEquals( 'img_caption_shortcode', $shortcode_tags['caption'] ); … … 52 55 $this->assertEquals( 'img_caption_shortcode', $shortcode_tags['wp_caption'] ); 53 56 } 54 57 58 /** 59 * @covers ::img_caption_shortcode 60 */ 55 61 function test_img_caption_shortcode_with_empty_params() { 56 62 $result = img_caption_shortcode( array() ); 57 63 $this->assertNull( $result ); … … 59 65 60 66 /** 61 67 * @ticket 33981 68 * 69 * @covers ::img_caption_shortcode 62 70 */ 63 71 function test_img_caption_shortcode_with_empty_params_but_content() { 64 72 $result = img_caption_shortcode( array(), $this->caption ); … … 67 75 68 76 /** 69 77 * @ticket 33981 78 * 79 * @covers ::img_caption_shortcode 70 80 */ 71 81 function test_img_caption_shortcode_short_circuit_filter() { 72 82 add_filter( 'img_caption_shortcode', array( $this, '_return_alt_caption' ) ); … … 84 94 85 95 /** 86 96 * @ticket 33981 97 * 98 * @covers ::img_caption_shortcode 87 99 */ 88 100 function test_img_caption_shortcode_empty_width() { 89 101 $result = img_caption_shortcode( … … 97 109 98 110 /** 99 111 * @ticket 33981 112 * 113 * @covers ::img_caption_shortcode 100 114 */ 101 115 function test_img_caption_shortcode_empty_caption() { 102 116 $result = img_caption_shortcode( … … 109 123 110 124 /** 111 125 * @ticket 33981 126 * 127 * @covers ::img_caption_shortcode 112 128 */ 113 129 function test_img_caption_shortcode_empty_caption_and_content() { 114 130 $result = img_caption_shortcode( … … 120 136 $this->assertEquals( $this->caption, $result ); 121 137 } 122 138 139 /** 140 * @covers ::img_caption_shortcode 141 */ 123 142 function test_img_caption_shortcode_with_old_format() { 124 143 $result = img_caption_shortcode( 125 144 array( … … 139 158 } 140 159 } 141 160 161 /** 162 * @covers ::img_caption_shortcode 163 */ 142 164 function test_img_caption_shortcode_with_old_format_id_and_align() { 143 165 $result = img_caption_shortcode( 144 166 array( … … 153 175 $this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); 154 176 } 155 177 178 /** 179 * @covers ::img_caption_shortcode 180 */ 156 181 function test_img_caption_shortcode_with_old_format_and_class() { 157 182 $result = img_caption_shortcode( 158 183 array( … … 165 190 166 191 } 167 192 193 /** 194 * @covers ::img_caption_shortcode 195 */ 168 196 function test_new_img_caption_shortcode_with_html_caption() { 169 197 $result = img_caption_shortcode( 170 198 array( … … 177 205 $this->assertEquals( 1, preg_match_all( "~{$our_preg}~", $result, $_r ) ); 178 206 } 179 207 208 /** 209 * @covers ::img_caption_shortcode 210 */ 180 211 function test_new_img_caption_shortcode_new_format() { 181 212 $result = img_caption_shortcode( 182 213 array( 'width' => 20 ), … … 189 220 $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); 190 221 } 191 222 223 /** 224 * @covers ::img_caption_shortcode 225 */ 192 226 function test_new_img_caption_shortcode_new_format_and_linked_image() { 193 227 $linked_image = "<a href='#'>{$this->img_content}</a>"; 194 228 $result = img_caption_shortcode( … … 202 236 $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); 203 237 } 204 238 239 /** 240 * @covers ::img_caption_shortcode 241 */ 205 242 function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() { 206 243 $linked_image = "<a href='#'>{$this->img_content}</a>"; 207 244 $result = img_caption_shortcode( … … 217 254 218 255 /** 219 256 * @ticket 34595 257 * 258 * @covers ::img_caption_shortcode 220 259 */ 221 260 function test_img_caption_shortcode_has_aria_describedby() { 222 261 $result = img_caption_shortcode( … … 230 269 $this->assertEquals( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) ); 231 270 } 232 271 272 /** 273 * @covers ::wp_oembed_remove_provider 274 */ 233 275 function test_add_remove_oembed_provider() { 234 276 wp_oembed_add_provider( 'http://foo.bar/*', 'http://foo.bar/oembed' ); 235 277 $this->assertTrue( wp_oembed_remove_provider( 'http://foo.bar/*' ) ); … … 238 280 239 281 /** 240 282 * @ticket 23776 283 * 284 * @covers WP_Embed::autoembed 241 285 */ 242 286 function test_autoembed_empty() { 243 287 global $wp_embed; … … 250 294 251 295 /** 252 296 * @ticket 23776 297 * 298 * @covers WP_Embed::autoembed 253 299 */ 254 300 function test_autoembed_no_paragraphs_around_urls() { 255 301 global $wp_embed; … … 329 375 330 376 /** 331 377 * @dataProvider data_autoembed 378 * 379 * @covers WP_Embed::autoembed 332 380 */ 333 381 function test_autoembed( $content, $result = null ) { 334 382 $wp_embed = new Test_Autoembed; … … 336 384 $this->assertEquals( $wp_embed->autoembed( $content ), $result ? $result : $content ); 337 385 } 338 386 387 /** 388 * @covers ::wp_prepare_attachment_for_js 389 */ 339 390 function test_wp_prepare_attachment_for_js() { 340 391 // Attachment without media. 341 392 $id = wp_insert_attachment( … … 389 440 390 441 /** 391 442 * @ticket 38965 443 * 444 * @covers ::wp_prepare_attachment_for_js 392 445 */ 393 446 function test_wp_prepare_attachment_for_js_without_image_sizes() { 394 447 // Create the attachement post. … … 420 473 /** 421 474 * @ticket 19067 422 475 * @expectedDeprecated wp_convert_bytes_to_hr 476 * 477 * @covers ::wp_convert_bytes_to_hr 478 * @covers ::size_format 423 479 */ 424 480 function test_wp_convert_bytes_to_hr() { 425 481 $kb = 1024; … … 458 514 459 515 /** 460 516 * @ticket 22960 517 * 518 * @covers ::get_attached_media 461 519 */ 462 520 function test_get_attached_images() { 463 521 $post_id = self::factory()->post->create(); … … 476 534 477 535 /** 478 536 * @ticket 22960 537 * 538 * @covers ::wp_update_attachment_metadata 479 539 */ 480 540 function test_post_galleries_images() { 481 541 $ids1 = array(); … … 527 587 528 588 /** 529 589 * @ticket 39304 590 * 591 * @covers ::get_post_galleries 530 592 */ 531 593 function test_post_galleries_images_without_global_post() { 532 594 // Set up an unattached image. … … 552 614 553 615 /** 554 616 * @ticket 39304 617 * 618 * @covers ::get_post_galleries 555 619 */ 556 620 function test_post_galleries_ignores_global_post() { 557 621 $global_post_id = $this->factory->post->create( … … 587 651 588 652 /** 589 653 * @ticket 39304 654 * 655 * @covers ::get_post_galleries 590 656 */ 591 657 function test_post_galleries_respects_id_attrs() { 592 658 $post_id = $this->factory->post->create( … … 626 692 627 693 /** 628 694 * @ticket 22960 695 * 696 * @covers ::get_post_gallery_images 629 697 */ 630 698 function test_post_gallery_images() { 631 699 $ids1 = array(); … … 675 743 $this->assertEquals( $srcs, $ids1_srcs ); 676 744 } 677 745 746 /** 747 * @covers ::get_media_embedded_in_content 748 */ 678 749 function test_get_media_embedded_in_content() { 679 750 $object = <<<OBJ 680 751 <object src="this" data="that"> … … 739 810 $this->assertEquals( $contents, $matches ); 740 811 } 741 812 813 /** 814 * @covers ::get_media_embedded_in_content 815 */ 742 816 function test_get_media_embedded_in_content_order() { 743 817 $audio = <<<AUDIO 744 818 <audio preload="none"> … … 769 843 770 844 /** 771 845 * @ticket 35367 846 * 847 * @covers ::wp_audio_shortcode 772 848 */ 773 849 function test_wp_audio_shortcode_with_bad_attr() { 774 850 $this->assertSame( … … 783 859 784 860 /** 785 861 * @ticket 35367 862 * 863 * @covers ::wp_audio_shortcode 786 864 */ 787 865 function test_wp_audio_shortcode_attributes() { 788 866 $actual = wp_audio_shortcode( … … 819 897 820 898 /** 821 899 * Test [video] shortcode processing 900 * 901 * @covers ::wp_video_shortcode 822 902 */ 823 903 function test_video_shortcode_body() { 824 904 $width = 720; … … 865 945 /** 866 946 * @ticket 35367 867 947 * @depends test_video_shortcode_body 948 * 949 * @covers ::wp_video_shortcode 868 950 */ 869 951 function test_wp_video_shortcode_with_empty_params() { 870 952 $this->assertNull( wp_video_shortcode( array() ) ); … … 873 955 /** 874 956 * @ticket 35367 875 957 * @depends test_video_shortcode_body 958 * 959 * @covers ::wp_video_shortcode 876 960 */ 877 961 function test_wp_video_shortcode_with_bad_attr() { 878 962 $this->assertSame( … … 888 972 /** 889 973 * @ticket 35367 890 974 * @depends test_video_shortcode_body 975 * 976 * @covers ::wp_video_shortcode 891 977 */ 892 978 function test_wp_video_shortcode_attributes() { 893 979 $actual = wp_video_shortcode( … … 930 1016 /** 931 1017 * @ticket 40866 932 1018 * @depends test_video_shortcode_body 1019 * 1020 * @covers ::wp_video_shortcode 933 1021 */ 934 1022 function test_wp_video_shortcode_youtube_remove_feature() { 935 1023 $actual = wp_video_shortcode( … … 944 1032 /** 945 1033 * @ticket 40866 946 1034 * @depends test_video_shortcode_body 1035 * 1036 * @covers ::wp_video_shortcode 947 1037 */ 948 1038 function test_wp_video_shortcode_youtube_force_ssl() { 949 1039 $actual = wp_video_shortcode( … … 958 1048 /** 959 1049 * @ticket 40866 960 1050 * @depends test_video_shortcode_body 1051 * 1052 * @covers ::wp_video_shortcode 961 1053 */ 962 1054 function test_wp_video_shortcode_vimeo_force_ssl_remove_query_args() { 963 1055 $actual = wp_video_shortcode( … … 973 1065 /** 974 1066 * @ticket 40977 975 1067 * @depends test_video_shortcode_body 1068 * 1069 * @covers ::wp_video_shortcode 976 1070 */ 977 1071 function test_wp_video_shortcode_vimeo_adds_loop() { 978 1072 $actual = wp_video_shortcode( … … 987 1081 /** 988 1082 * @ticket 40977 989 1083 * @depends test_video_shortcode_body 1084 * 1085 * @covers ::wp_video_shortcode 990 1086 */ 991 1087 function test_wp_video_shortcode_vimeo_force_adds_loop_true() { 992 1088 $actual = wp_video_shortcode( … … 1001 1097 1002 1098 /** 1003 1099 * @ticket 26768 1100 * 1101 * @covers ::add_image_size 1004 1102 */ 1005 1103 function test_add_image_size() { 1006 1104 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1022 1120 1023 1121 /** 1024 1122 * @ticket 26768 1123 * 1124 * @covers ::remove_image_size 1025 1125 */ 1026 1126 function test_remove_image_size() { 1027 1127 add_image_size( 'test-size', 200, 600 ); … … 1032 1132 1033 1133 /** 1034 1134 * @ticket 26951 1135 * 1136 * @covers ::has_image_size 1035 1137 */ 1036 1138 function test_has_image_size() { 1037 1139 add_image_size( 'test-size', 200, 600 ); … … 1043 1145 1044 1146 /** 1045 1147 * @ticket 30346 1148 * 1149 * @covers ::attachment_url_to_postid 1046 1150 */ 1047 1151 function test_attachment_url_to_postid() { 1048 1152 $image_path = '2014/11/' . $this->img_name; … … 1061 1165 1062 1166 /** 1063 1167 * @ticket 33109 1168 * 1169 * @covers ::attachment_url_to_postid 1064 1170 */ 1065 1171 function test_attachment_url_to_postid_with_different_scheme() { 1066 1172 $image_path = '2014/11/' . $this->img_name; … … 1079 1185 1080 1186 /** 1081 1187 * @ticket 39768 1188 * 1189 * @covers ::attachment_url_to_postid 1082 1190 */ 1083 1191 function test_attachment_url_to_postid_should_be_case_sensitive() { 1084 1192 $image_path_lower_case = '2014/11/' . $this->img_name; … … 1105 1213 $this->assertEquals( $attachment_id_upper_case, attachment_url_to_postid( $image_url ) ); 1106 1214 } 1107 1215 1216 /** 1217 * @covers ::attachment_url_to_postid 1218 */ 1108 1219 function test_attachment_url_to_postid_filtered() { 1109 1220 $image_path = '2014/11/' . $this->img_name; 1110 1221 $attachment_id = self::factory()->attachment->create_object( … … 1129 1240 1130 1241 /** 1131 1242 * @ticket 31044 1243 * 1244 * @covers ::attachment_url_to_postid 1132 1245 */ 1133 1246 function test_attachment_url_to_postid_with_empty_url() { 1134 1247 $post_id = attachment_url_to_postid( '' ); … … 1138 1251 1139 1252 /** 1140 1253 * @ticket 22768 1254 * 1255 * @covers ::media_handle_upload 1141 1256 */ 1142 1257 public function test_media_handle_upload_sets_post_excerpt() { 1143 1258 $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg'; … … 1177 1292 1178 1293 /** 1179 1294 * @ticket 37989 1295 * 1296 * @covers ::media_handle_upload 1180 1297 */ 1181 1298 public function test_media_handle_upload_expected_titles() { 1182 1299 $test_file = DIR_TESTDATA . '/images/test-image.jpg'; … … 1216 1333 1217 1334 /** 1218 1335 * @ticket 33016 1336 * 1337 * @covers WP_Embed::autoembed 1219 1338 */ 1220 1339 function test_multiline_cdata() { 1221 1340 global $wp_embed; … … 1233 1352 1234 1353 /** 1235 1354 * @ticket 33016 1355 * 1356 * @covers WP_Embed::autoembed 1236 1357 */ 1237 1358 function test_multiline_comment() { 1238 1359 global $wp_embed; … … 1250 1371 1251 1372 /** 1252 1373 * @ticket 33016 1374 * 1375 * @covers WP_Embed::autoembed 1253 1376 */ 1254 1377 function test_multiline_comment_with_embeds() { 1255 1378 $content = <<<EOF … … 1293 1416 1294 1417 /** 1295 1418 * @ticket 33016 1419 * 1420 * @covers WP_Embed::autoembed 1296 1421 */ 1297 1422 function test_oembed_explicit_media_link() { 1298 1423 global $wp_embed; … … 1330 1455 * Tests the default output of `wp_get_attachment_image()`. 1331 1456 * 1332 1457 * @ticket 34635 1458 * 1459 * @covers ::wp_get_attachment_image 1333 1460 */ 1334 1461 function test_wp_get_attachment_image_defaults() { 1335 1462 $image = image_downsize( self::$large_id, 'thumbnail' ); … … 1347 1474 * Test that `wp_get_attachment_image()` returns a proper alt value. 1348 1475 * 1349 1476 * @ticket 34635 1477 * 1478 * @covers ::wp_get_attachment_image 1350 1479 */ 1351 1480 function test_wp_get_attachment_image_with_alt() { 1352 1481 // Add test alt metadata. … … 1368 1497 1369 1498 /** 1370 1499 * @ticket 33878 1500 * 1501 * @covers ::wp_get_attachment_image 1371 1502 */ 1372 1503 function test_wp_get_attachment_image_url() { 1373 1504 $this->assertFalse( wp_get_attachment_image_url( 0 ) ); … … 1389 1520 1390 1521 /** 1391 1522 * @ticket 12235 1523 * 1524 * @covers ::wp_get_attachment_caption 1392 1525 */ 1393 1526 function test_wp_get_attachment_caption() { 1394 1527 $this->assertFalse( wp_get_attachment_caption( 0 ) ); … … 1413 1546 1414 1547 /** 1415 1548 * @ticket 12235 1549 * 1550 * @covers ::wp_get_attachment_caption 1416 1551 */ 1417 1552 function test_wp_get_attachment_caption_empty() { 1418 1553 $post_id = self::factory()->post->create(); … … 1463 1598 1464 1599 /** 1465 1600 * @ticket 33641 1601 * 1602 * @covers ::wp_calculate_image_srcset 1466 1603 */ 1467 1604 function test_wp_calculate_image_srcset() { 1468 1605 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1510 1647 1511 1648 /** 1512 1649 * @ticket 33641 1650 * 1651 * @covers ::wp_calculate_image_srcset 1513 1652 */ 1514 1653 function test_wp_calculate_image_srcset_no_date_uploads() { 1515 1654 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1566 1705 1567 1706 /** 1568 1707 * @ticket 33641 1708 * 1709 * @covers ::wp_calculate_image_srcset 1569 1710 */ 1570 1711 function test_wp_calculate_image_srcset_with_edits() { 1571 1712 // For this test we're going to mock metadata changes from an edit. … … 1599 1740 1600 1741 /** 1601 1742 * @ticket 35106 1743 * 1744 * @covers ::wp_calculate_image_srcset 1602 1745 */ 1603 1746 function test_wp_calculate_image_srcset_with_absolute_path_in_meta() { 1604 1747 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1650 1793 1651 1794 /** 1652 1795 * @ticket 33641 1796 * 1797 * @covers ::wp_calculate_image_srcset 1653 1798 */ 1654 1799 function test_wp_calculate_image_srcset_false() { 1655 1800 $sizes = wp_calculate_image_srcset( array( 400, 300 ), 'file.png', array() ); … … 1660 1805 1661 1806 /** 1662 1807 * @ticket 33641 1808 * 1809 * @covers ::wp_calculate_image_srcset 1663 1810 */ 1664 1811 function test_wp_calculate_image_srcset_no_width() { 1665 1812 $file = get_attached_file( self::$large_id ); … … 1677 1824 /** 1678 1825 * @ticket 34955 1679 1826 * @ticket 33641 1827 * 1828 * @covers ::wp_calculate_image_srcset 1680 1829 */ 1681 1830 function test_wp_calculate_image_srcset_ratio_variance() { 1682 1831 // Mock data for this test. … … 1726 1875 /** 1727 1876 * @ticket 35108 1728 1877 * @ticket 33641 1878 * 1879 * @covers ::wp_calculate_image_srcset 1729 1880 */ 1730 1881 function test_wp_calculate_image_srcset_include_src() { 1731 1882 // Mock data for this test. … … 1775 1926 1776 1927 /** 1777 1928 * @ticket 35480 1929 * 1930 * @covers ::wp_calculate_image_srcset 1778 1931 */ 1779 1932 function test_wp_calculate_image_srcset_corrupted_image_meta() { 1780 1933 $size_array = array( 300, 150 ); … … 1849 2002 /** 1850 2003 * @ticket 36549 1851 2004 * @ticket 33641 2005 * 2006 * @covers ::wp_calculate_image_srcset 1852 2007 */ 1853 2008 function test_wp_calculate_image_srcset_with_spaces_in_filenames() { 1854 2009 // Mock data for this test. … … 1896 2051 1897 2052 /** 1898 2053 * @ticket 33641 2054 * 2055 * @covers ::wp_calculate_image_srcset 1899 2056 */ 1900 2057 function test_wp_get_attachment_image_srcset() { 1901 2058 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1935 2092 1936 2093 /** 1937 2094 * @ticket 33641 2095 * 2096 * @covers ::wp_calculate_image_srcset 1938 2097 */ 1939 2098 function test_wp_get_attachment_image_srcset_single_srcset() { 1940 2099 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 1950 2109 1951 2110 /** 1952 2111 * @ticket 33641 2112 * 2113 * @covers ::wp_calculate_image_srcset 1953 2114 */ 1954 2115 function test_wp_get_attachment_image_srcset_invalidsize() { 1955 2116 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 1966 2127 1967 2128 /** 1968 2129 * @ticket 33641 2130 * 2131 * @covers ::wp_calculate_image_src 1969 2132 */ 1970 2133 function test_wp_get_attachment_image_sizes() { 1971 2134 // Test sizes against the default WP sizes. … … 1986 2149 1987 2150 /** 1988 2151 * @ticket 33641 2152 * 2153 * @covers ::wp_calculate_image_sizes 1989 2154 */ 1990 2155 function test_wp_calculate_image_sizes() { 1991 2156 // Test sizes against the default WP sizes. … … 2009 2174 2010 2175 /** 2011 2176 * @ticket 33641 2177 * 2178 * @covers ::wp_filter_content_tags 2012 2179 */ 2013 2180 function test_wp_filter_content_tags_srcset_sizes() { 2014 2181 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2099 2266 * 2100 2267 * @ticket 34898 2101 2268 * @ticket 33641 2269 * 2270 * @covers ::wp_filter_content_tags 2102 2271 */ 2103 2272 function test_wp_filter_content_tags_srcset_sizes_wrong() { 2104 2273 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); … … 2112 2281 2113 2282 /** 2114 2283 * @ticket 33641 2284 * 2285 * @covers ::wp_filter_content_tags 2115 2286 */ 2116 2287 function test_wp_filter_content_tags_srcset_sizes_with_preexisting_srcset() { 2117 2288 // Generate HTML and add a dummy srcset attribute. … … 2126 2297 /** 2127 2298 * @ticket 33641 2128 2299 * @ticket 34528 2300 * 2301 * @covers ::wp_calculate_image_srcset 2129 2302 */ 2130 2303 function test_wp_calculate_image_srcset_animated_gifs() { 2131 2304 // Mock meta for an animated gif. … … 2170 2343 /** 2171 2344 * @ticket 35045 2172 2345 * @ticket 33641 2346 * 2347 * @covers ::wp_filter_content_tags 2173 2348 */ 2174 2349 function test_wp_filter_content_tags_schemes() { 2175 2350 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2221 2396 /** 2222 2397 * @ticket 34945 2223 2398 * @ticket 33641 2399 * 2400 * @covers ::wp_calculate_image_srcset 2224 2401 */ 2225 2402 function test_wp_get_attachment_image_with_https_on() { 2226 2403 // Mock meta for the image. … … 2266 2443 2267 2444 /** 2268 2445 * @ticket 36084 2446 * 2447 * @covers :get_image_send_to_editor: 2269 2448 */ 2270 2449 function test_get_image_send_to_editor_defaults() { 2271 2450 $id = self::$large_id; … … 2286 2465 2287 2466 /** 2288 2467 * @ticket 36084 2468 * 2469 * @covers ::get_image_send_to_editor 2289 2470 */ 2290 2471 function test_get_image_send_to_editor_defaults_with_optional_params() { 2291 2472 $id = self::$large_id; … … 2310 2491 2311 2492 /** 2312 2493 * @ticket 36084 2494 * 2495 * @covers ::get_image_send_to_editor 2313 2496 */ 2314 2497 function test_get_image_send_to_editor_defaults_no_caption_no_rel() { 2315 2498 $id = self::$large_id; … … 2341 2524 * used in the output of `wp_get_attachment_image()`. 2342 2525 * 2343 2526 * @ticket 36246 2527 * 2528 * @covers ::wp_get_attachment_image 2344 2529 */ 2345 2530 function test_wp_get_attachment_image_should_use_wp_get_attachment_metadata() { 2346 2531 add_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ), 10, 2 ); … … 2376 2561 2377 2562 /** 2378 2563 * @ticket 37813 2564 * 2565 * @covers ::wp_insert_attachment 2379 2566 */ 2380 2567 public function test_return_type_when_inserting_attachment_with_error_in_data() { 2381 2568 $data = array( … … 2395 2582 2396 2583 /** 2397 2584 * @ticket 35218 2585 * 2586 * @covers ::wp_get_media_creation_timestamp 2398 2587 */ 2399 2588 function test_wp_get_media_creation_timestamp_video_asf() { 2400 2589 $metadata = array( … … 2411 2600 2412 2601 /** 2413 2602 * @ticket 35218 2603 * 2604 * @covers ::wp_get_media_creation_timestamp 2414 2605 */ 2415 2606 function test_wp_get_media_creation_timestamp_video_matroska() { 2416 2607 $metadata = array( … … 2429 2620 2430 2621 /** 2431 2622 * @ticket 35218 2623 * 2624 * @covers ::wp_get_media_creation_timestamp 2432 2625 */ 2433 2626 function test_wp_get_media_creation_timestamp_video_quicktime() { 2434 2627 $metadata = array( … … 2449 2642 2450 2643 /** 2451 2644 * @ticket 35218 2645 * 2646 * @covers ::wp_get_media_creation_timestamp 2452 2647 */ 2453 2648 function test_wp_get_media_creation_timestamp_video_webm() { 2454 2649 $metadata = array( … … 2472 2667 *`wp_read_audio_metadata()`. 2473 2668 * 2474 2669 * @ticket 42017 2670 * 2671 * @covers ::wp_read_audio_metadata 2475 2672 */ 2476 2673 function test_wp_read_audio_metadata_adds_creation_date_with_mp4() { 2477 2674 $video = DIR_TESTDATA . '/uploads/small-video.mp4'; … … 2482 2679 2483 2680 /** 2484 2681 * @ticket 35218 2682 * 2683 * @covers ::wp_read_video_metadata 2485 2684 */ 2486 2685 function test_wp_read_video_metadata_adds_creation_date_with_quicktime() { 2487 2686 $video = DIR_TESTDATA . '/uploads/small-video.mov'; … … 2492 2691 2493 2692 /** 2494 2693 * @ticket 35218 2694 * 2695 * @covers ::wp_read_video_metadata 2495 2696 */ 2496 2697 function test_wp_read_video_metadata_adds_creation_date_with_mp4() { 2497 2698 $video = DIR_TESTDATA . '/uploads/small-video.mp4'; … … 2502 2703 2503 2704 /** 2504 2705 * @ticket 35218 2706 * 2707 * @covers ::wp_read_video_metadata 2505 2708 */ 2506 2709 function test_wp_read_video_metadata_adds_creation_date_with_mkv() { 2507 2710 $video = DIR_TESTDATA . '/uploads/small-video.mkv'; … … 2512 2715 2513 2716 /** 2514 2717 * @ticket 35218 2718 * 2719 * @covers ::wp_read_video_metadata 2515 2720 */ 2516 2721 function test_wp_read_video_metadata_adds_creation_date_with_webm() { 2517 2722 $video = DIR_TESTDATA . '/uploads/small-video.webm'; … … 2522 2727 2523 2728 /** 2524 2729 * @ticket 10752 2730 * 2731 * @covers ::media_handle_upload 2525 2732 */ 2526 2733 public function test_media_handle_upload_uses_post_parent_for_directory_date() { 2527 2734 $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg'; … … 2568 2775 2569 2776 /** 2570 2777 * @ticket 10752 2778 * 2779 * @covers ::media_handle_upload 2571 2780 */ 2572 2781 public function test_media_handle_upload_ignores_page_parent_for_directory_date() { 2573 2782 $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg'; … … 2620 2829 2621 2830 /** 2622 2831 * @ticket 50367 2832 * 2833 * @covers ::wp_filter_content_tags 2623 2834 */ 2624 2835 function test_wp_filter_content_tags_width_height() { 2625 2836 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2665 2876 /** 2666 2877 * @ticket 44427 2667 2878 * @ticket 50367 2879 * 2880 * @covers ::wp_filter_content_tags 2668 2881 */ 2669 2882 function test_wp_filter_content_tags_loading_lazy() { 2670 2883 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2713 2926 2714 2927 /** 2715 2928 * @ticket 44427 2929 * 2930 * @covers ::wp_filter_content_tags 2716 2931 */ 2717 2932 function test_wp_filter_content_tags_loading_lazy_opted_in() { 2718 2933 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); … … 2738 2953 2739 2954 /** 2740 2955 * @ticket 44427 2956 * 2957 * @covers ::wp_filter_content_tags 2741 2958 */ 2742 2959 function test_wp_filter_content_tags_loading_lazy_opted_out() { 2743 2960 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); … … 2761 2978 /** 2762 2979 * @ticket 44427 2763 2980 * @ticket 50367 2981 * 2982 * @covers ::wp_img_tag_add_loading_attr 2764 2983 */ 2765 2984 function test_wp_img_tag_add_loading_attr() { 2766 2985 $img = '<img src="example.png" alt=" width="300" height="225" />'; … … 2772 2991 /** 2773 2992 * @ticket 44427 2774 2993 * @ticket 50367 2994 * 2995 * @covers ::wp_img_tag_add_loading_attr 2775 2996 */ 2776 2997 function test_wp_img_tag_add_loading_attr_without_src() { 2777 2998 $img = '<img alt=" width="300" height="225" />'; … … 2783 3004 /** 2784 3005 * @ticket 44427 2785 3006 * @ticket 50367 3007 * 3008 * @covers ::wp_img_tag_add_loading_attr 2786 3009 */ 2787 3010 function test_wp_img_tag_add_loading_attr_with_single_quotes() { 2788 3011 $img = "<img src='example.png' alt=' width='300' height='225' />"; … … 2798 3021 /** 2799 3022 * @ticket 44427 2800 3023 * @ticket 50425 3024 * 3025 * @covers ::wp_img_tag_add_loading_attr 2801 3026 */ 2802 3027 function test_wp_img_tag_add_loading_attr_opt_out() { 2803 3028 $img = '<img src="example.png" alt=" width="300" height="225" />'; … … 2809 3034 /** 2810 3035 * @ticket 44427 2811 3036 * @ticket 50425 3037 * 3038 * @covers ::wp_get_attachment_image 2812 3039 */ 2813 3040 function test_wp_get_attachment_image_loading() { 2814 3041 $img = wp_get_attachment_image( self::$large_id ); … … 2819 3046 /** 2820 3047 * @ticket 44427 2821 3048 * @ticket 50425 3049 * 3050 * @covers ::wp_get_attachment_image 2822 3051 */ 2823 3052 function test_wp_get_attachment_image_loading_opt_out() { 2824 3053 add_filter( 'wp_lazy_loading_enabled', '__return_false' ); … … 2831 3060 /** 2832 3061 * @ticket 44427 2833 3062 * @ticket 50425 3063 * 3064 * @covers ::wp_get_attachment_image 2834 3065 */ 2835 3066 function test_wp_get_attachment_image_loading_opt_out_individual() { 2836 3067 // The default is already tested above, the filter below ensures that … … 2850 3081 * 2851 3082 * @param string $tag_name Tag name. 2852 3083 * @param bool $expected Expected return value. 3084 * 3085 * @covers ::wp_lazy_loading_enabled 2853 3086 */ 2854 3087 function test_wp_lazy_loading_enabled_tag_name_defaults( $tag_name, $expected ) { 2855 3088 if ( $expected ) { … … 2873 3106 * 2874 3107 * @param string $context Function context. 2875 3108 * @param bool $expected Expected return value. 3109 * 3110 * @covers ::wp_lazy_loading_enabled 2876 3111 */ 2877 3112 function test_wp_lazy_loading_enabled_context_defaults( $context, $expected ) { 2878 3113 if ( $expected ) { … … 2895 3130 2896 3131 /** 2897 3132 * @ticket 50543 3133 * 3134 * @covers ::wp_image_file_matches_image_meta 2898 3135 */ 2899 3136 function test_wp_image_file_matches_image_meta() { 2900 3137 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2907 3144 2908 3145 /** 2909 3146 * @ticket 50543 3147 * 3148 * @covers ::wp_image_file_matches_image_meta 2910 3149 */ 2911 3150 function test_wp_image_file_matches_image_meta_no_subsizes() { 2912 3151 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2919 3158 2920 3159 /** 2921 3160 * @ticket 50543 3161 * 3162 * @covers ::wp_image_file_matches_image_meta 2922 3163 */ 2923 3164 function test_wp_image_file_matches_image_meta_invalid_meta() { 2924 3165 $image_meta = ''; // Attachment is not an image. … … 2929 3170 2930 3171 /** 2931 3172 * @ticket 50543 3173 * 3174 * @covers ::wp_image_file_matches_image_meta 2932 3175 */ 2933 3176 function test_wp_image_file_matches_image_meta_different_meta() { 2934 3177 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2939 3182 2940 3183 /** 2941 3184 * @ticket 50543 3185 * 3186 * @covers ::wp_image_file_matches_image_meta 2942 3187 */ 2943 3188 function test_wp_image_file_matches_image_meta_original_image() { 2944 3189 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2949 3194 2950 3195 /** 2951 3196 * @ticket 22101 3197 * 3198 * @covers ::gallery_shortcode 2952 3199 */ 2953 3200 function test_gallery_shortcode_when_is_feed_true() { 2954 3201 -
tests/phpunit/tests/meta.php
17 17 return 'sanitized'; 18 18 } 19 19 20 /** 21 * 22 * @covers ::sanitize_meta 23 */ 20 24 function test_sanitize_meta() { 21 25 $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' ); 22 26 $this->assertEquals( 'unsanitized', $meta ); … … 26 30 $this->assertEquals( 'sanitized', $meta ); 27 31 } 28 32 33 /** 34 * 35 * @covers ::delete_metadata_by_mid 36 */ 29 37 function test_delete_metadata_by_mid() { 30 38 // Let's try and delete a non-existing ID, non existing meta. 31 39 $this->assertFalse( delete_metadata_by_mid( 'user', 0 ) ); … … 41 49 $this->assertFalse( (bool) get_user_meta( $this->author->ID, 'delete_meta_key' ) ); 42 50 } 43 51 52 /** 53 * 54 * @covers ::delete_metadata_by_mid 55 */ 44 56 function test_update_metadata_by_mid() { 45 57 // Setup. 46 58 $meta = get_metadata_by_mid( 'user', $this->meta_id ); … … 80 92 81 93 /** 82 94 * @ticket 11683 95 * 96 * @covers ::add_metadata 83 97 */ 84 98 public function test_update_metadata_hooks_for_multiple_updated_rows() { 85 99 add_metadata( 'post', 1, 'test_key', 'value_1' ); … … 104 118 } 105 119 } 106 120 121 /** 122 * 123 * @covers ::metadata_exists 124 */ 107 125 function test_metadata_exists() { 108 126 $this->assertFalse( metadata_exists( 'user', $this->author->ID, 'foobarbaz' ) ); 109 127 $this->assertTrue( metadata_exists( 'user', $this->author->ID, 'meta_key' ) ); … … 113 131 114 132 /** 115 133 * @ticket 22746 134 * 135 * @covers ::metadata_exists 116 136 */ 117 137 function test_metadata_exists_with_filter() { 118 138 // Let's see if it returns the correct value when adding a filter. … … 124 144 125 145 /** 126 146 * @ticket 18158 147 * 148 * @covers ::get_users 127 149 */ 128 150 function test_user_metadata_not_exists() { 129 151 $u = get_users( … … 198 220 ); 199 221 } 200 222 223 /** 224 * 225 * @covers ::get_metadata 226 */ 201 227 function test_metadata_slashes() { 202 228 $key = __FUNCTION__; 203 229 $value = 'Test\\singleslash'; … … 230 256 231 257 /** 232 258 * @ticket 16814 259 * 260 * @covers ::add_post_meta 233 261 */ 234 262 function test_meta_type_cast() { 235 263 $post_id1 = self::factory()->post->create(); … … 320 348 321 349 /** 322 350 * @ticket 28315 351 * 352 * @covers ::add_post_meta 353 * @covers ::update_metadata 354 * @covers ::delete_metadata 355 * @covers ::get_metadata 356 * @covers ::metadata_exists 323 357 */ 324 358 function test_non_numeric_object_id() { 325 359 $this->assertFalse( add_metadata( 'user', array( 1 ), 'meta_key', 'meta_value' ) ); … … 331 365 332 366 /** 333 367 * @ticket 28315 368 * 369 * @covers ::add_post_meta 370 * @covers ::update_metadata 371 * @covers ::delete_metadata 334 372 */ 335 373 function test_non_numeric_meta_id() { 336 374 $this->assertFalse( get_metadata_by_mid( 'user', array( 1 ) ) ); … … 340 378 341 379 /** 342 380 * @ticket 37746 381 * 382 * @covers ::add_post_meta 383 * @covers ::update_metadata 384 * @covers ::delete_metadata 343 385 */ 344 386 function test_negative_meta_id() { 345 387 $negative_mid = $this->meta_id * -1; … … 352 394 353 395 /** 354 396 * @ticket 37746 397 * 398 * @covers ::add_post_meta 399 * @covers ::update_metadata 400 * @covers ::delete_metadata 355 401 */ 356 402 function test_floating_meta_id() { 357 403 $floating_mid = $this->meta_id + 0.1337; … … 364 410 365 411 /** 366 412 * @ticket 37746 413 * 414 * @covers ::add_post_meta 415 * @covers ::update_metadata 416 * @covers ::delete_metadata 367 417 */ 368 418 function test_string_point_zero_meta_id() { 369 419 $meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value_2' ); … … 379 429 380 430 /** 381 431 * @ticket 15030 432 * 433 * @covers ::get_metadata 382 434 */ 383 435 public function test_get_metadata_with_empty_key_array_value() { 384 436 $data = array( 1, 2 ); … … 391 443 392 444 /** 393 445 * @ticket 15030 446 * 447 * @covers ::get_metadata 394 448 */ 395 449 public function test_get_metadata_with_empty_key_object_value() { 396 450 $data = new stdClass; … … 404 458 405 459 /** 406 460 * @ticket 15030 461 * 462 * @covers ::get_metadata 407 463 */ 408 464 public function test_get_metadata_with_empty_key_nested_array_value() { 409 465 $data = array( -
tests/phpunit/tests/multisite.php
22 22 $wpdb->suppress_errors( $this->suppress ); 23 23 } 24 24 25 /** 26 * 27 * @covers ::wpmu_log_new_registrations 28 */ 25 29 function test_wpmu_log_new_registrations() { 26 30 global $wpdb; 27 31 … … 37 41 38 42 /** 39 43 * @ticket 37392 44 * 45 * @covers ::wp_count_sites 40 46 */ 41 47 function test_wp_count_sites() { 42 48 // Create a random number of sites with each status. -
tests/phpunit/tests/pluggable.php
12 12 * @ticket 33867 13 13 * 14 14 * @dataProvider get_defined_pluggable_functions 15 * 16 * @coversNothing 15 17 */ 16 18 public function test_pluggable_function_signatures_match( $function ) { 17 19 … … 53 55 * 54 56 * @ticket 33654 55 57 * @ticket 33867 58 * 59 * @coversNothing 56 60 */ 57 61 public function test_all_pluggable_functions_exist() { 58 62 -
tests/phpunit/tests/post.php
58 58 59 59 /** 60 60 * Test simple valid behavior: insert and get a post. 61 * 62 * @covers ::wp_insert_post 63 * @covers ::wp_delete_post 61 64 */ 62 65 function test_vb_insert_get_delete() { 63 66 register_post_type( 'cpt', array( 'taxonomies' => array( 'post_tag', 'ctax' ) ) ); … … 119 122 120 123 /** 121 124 * Insert a post with a future date, and make sure the status and cron schedule are correct. 125 * 126 * @covers ::wp_insert_post 122 127 */ 123 128 function test_vb_insert_future() { 124 129 $future_date = strtotime( '+1 day' ); … … 153 158 154 159 /** 155 160 * Insert a post with a future date, and make sure the status and cron schedule are correct. 161 * 162 * @covers ::wp_insert_post 156 163 */ 157 164 function test_vb_insert_future_over_dst() { 158 165 // Some magic days - one DST one not. … … 199 206 * Future post bug: posts get published at the wrong time if you edit the timestamp. 200 207 * 201 208 * @ticket 4710 209 * 210 * @covers ::wp_insert_post 202 211 */ 203 212 function test_vb_insert_future_edit_bug() { 204 213 $future_date_1 = strtotime( '+1 day' ); … … 242 251 243 252 /** 244 253 * Insert a draft post with a future date, and make sure no cron schedule is set. 254 * 255 * @covers ::wp_insert_post 245 256 */ 246 257 function test_vb_insert_future_draft() { 247 258 $future_date = strtotime( '+1 day' ); … … 277 288 278 289 /** 279 290 * Insert a future post, then edit and change it to draft, and make sure cron gets it right. 291 * 292 * @covers ::wp_insert_post 280 293 */ 281 294 function test_vb_insert_future_change_to_draft() { 282 295 $future_date_1 = strtotime( '+1 day' ); … … 318 331 319 332 /** 320 333 * Insert a future post, then edit and change the status, and make sure cron gets it right. 334 * 335 * @covers ::wp_insert_post 321 336 */ 322 337 function test_vb_insert_future_change_status() { 323 338 $future_date_1 = strtotime( '+1 day' ); … … 363 378 364 379 /** 365 380 * Insert a draft post with a future date, and make sure no cron schedule is set. 381 * 382 * @covers ::wp_insert_post 366 383 */ 367 384 function test_vb_insert_future_private() { 368 385 $future_date = strtotime( '+1 day' ); … … 399 416 * Insert a post with an invalid date, make sure it fails. 400 417 * 401 418 * @ticket 17180 419 * 420 * @covers ::wp_insert_post 402 421 */ 403 422 function test_vb_insert_invalid_date() { 404 423 $post = array( … … 420 439 421 440 /** 422 441 * Insert a future post, then edit and change it to private, and make sure cron gets it right. 442 * 443 * @covers ::wp_insert_post 423 444 */ 424 445 function test_vb_insert_future_change_to_private() { 425 446 $future_date_1 = strtotime( '+1 day' ); … … 461 482 462 483 /** 463 484 * @ticket 5305 485 * 486 * @covers ::wp_insert_post 464 487 */ 465 488 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() { 466 489 $this->set_permalink_structure( '/%postname%/' ); … … 484 507 /** 485 508 * @ticket 5305 486 509 * @ticket 33392 510 * 511 * @covers ::wp_insert_post 487 512 */ 488 513 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() { 489 514 register_post_type( 'wptests_pt' ); … … 503 528 504 529 /** 505 530 * @ticket 20451 531 * 532 * @covers ::wp_insert_post 506 533 */ 507 534 public function test_wp_insert_post_with_meta_input() { 508 535 $post_id = wp_insert_post( … … 526 553 * "When I delete a future post using wp_delete_post( $post->ID ) it does not update the cron correctly." 527 554 * 528 555 * @ticket 5364 556 * 557 * @covers ::wp_insert_post 529 558 */ 530 559 function test_delete_future_post_cron() { 531 560 $future_date = strtotime( '+1 day' ); … … 557 586 * Might only fail if the post ID is greater than four characters. 558 587 * 559 588 * @ticket 5305 589 * 590 * @covers ::wp_insert_post 560 591 */ 561 592 function test_permalink_without_title() { 562 593 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); … … 593 624 594 625 /** 595 626 * @ticket 22944 627 * 628 * @covers ::wp_insert_post 596 629 */ 597 630 function test_wp_insert_post_and_wp_publish_post_with_future_date() { 598 631 $future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 ); … … 616 649 617 650 /** 618 651 * @ticket 48145 652 * 653 * @covers ::wp_insert_post 619 654 */ 620 655 function test_wp_insert_post_should_default_to_publish_if_post_date_is_within_59_seconds_from_current_time() { 621 656 $future_date = gmdate( 'Y-m-d H:i:s', time() + 59 ); … … 632 667 633 668 /** 634 669 * @ticket 22944 670 * 671 * @covers ::wp_insert_post 672 * @covers ::wp_update_post 635 673 */ 636 674 function test_publish_post_with_content_filtering() { 637 675 kses_remove_filters(); … … 657 695 658 696 /** 659 697 * @ticket 22944 698 * 699 * @covers ::wp_insert_post 700 * @covers ::wp_update_post 660 701 */ 661 702 function test_wp_publish_post_and_avoid_content_filtering() { 662 703 kses_remove_filters(); … … 677 718 678 719 /** 679 720 * @ticket 23708 721 * 722 * @covers ::get_post_ancestors 680 723 */ 681 724 function test_get_post_ancestors_within_loop() { 682 725 global $post; … … 687 730 688 731 /** 689 732 * @ticket 23474 733 * 734 * @covers ::wp_insert_post 735 * @covers ::wp_update_post 690 736 */ 691 737 function test_update_invalid_post_id() { 692 738 $post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); … … 702 748 703 749 } 704 750 751 /** 752 * 753 * @covers ::setup_postdata 754 */ 705 755 function test_parse_post_content_single_page() { 706 756 global $multipage, $pages, $numpages; 707 757 $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) ); … … 713 763 $this->assertEquals( array( 'Page 0' ), $pages ); 714 764 } 715 765 766 /** 767 * 768 * @covers ::setup_postdata 769 */ 716 770 function test_parse_post_content_multi_page() { 717 771 global $multipage, $pages, $numpages; 718 772 $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); … … 724 778 $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); 725 779 } 726 780 781 /** 782 * 783 * @covers ::setup_postdata 784 */ 727 785 function test_parse_post_content_remaining_single_page() { 728 786 global $multipage, $pages, $numpages; 729 787 $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) ); … … 735 793 $this->assertEquals( array( 'Page 0' ), $pages ); 736 794 } 737 795 796 /** 797 * 798 * @covers ::setup_postdata 799 */ 738 800 function test_parse_post_content_remaining_multi_page() { 739 801 global $multipage, $pages, $numpages; 740 802 $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); … … 748 810 749 811 /** 750 812 * @ticket 16746 813 * 814 * @covers ::setup_postdata 751 815 */ 752 816 function test_parse_post_content_starting_with_nextpage() { 753 817 global $multipage, $pages, $numpages; … … 762 826 763 827 /** 764 828 * @ticket 16746 829 * 830 * @covers ::setup_postdata 765 831 */ 766 832 function test_parse_post_content_starting_with_nextpage_multi() { 767 833 global $multipage, $pages, $numpages; … … 776 842 777 843 /** 778 844 * @ticket 19373 845 * 846 * @covers ::wp_insert_post 779 847 */ 780 848 function test_insert_programmatic_sanitized() { 781 849 $this->_unset_current_user(); … … 802 870 803 871 /** 804 872 * @ticket 24803 873 * 874 * @covers ::wp_count_posts 805 875 */ 806 876 function test_wp_count_posts() { 807 877 $post_type = rand_str( 20 ); … … 818 888 $this->assertEquals( new stdClass, wp_count_posts( $post_type, 'readable' ) ); 819 889 } 820 890 891 /** 892 * 893 * @covers ::wp_count_posts 894 */ 821 895 function test_wp_count_posts_filtered() { 822 896 $post_type = rand_str( 20 ); 823 897 register_post_type( $post_type ); … … 843 917 return $counts; 844 918 } 845 919 920 /** 921 * 922 * @covers ::wp_count_posts 923 */ 846 924 function test_wp_count_posts_insert_invalidation() { 847 925 $post_ids = self::factory()->post->create_many( 3 ); 848 926 $initial_counts = wp_count_posts(); … … 861 939 $this->assertNotEquals( $initial_counts->publish, $after_draft_counts->publish ); 862 940 } 863 941 942 /** 943 * 944 * @covers ::wp_count_posts 945 */ 864 946 function test_wp_count_posts_trash_invalidation() { 865 947 $post_ids = self::factory()->post->create_many( 3 ); 866 948 $initial_counts = wp_count_posts(); … … 881 963 882 964 /** 883 965 * @ticket 49685 966 * 967 * @covers ::wp_count_posts 884 968 */ 885 969 function test_wp_count_posts_status_changes_visible() { 886 970 self::factory()->post->create_many( 3 ); … … 897 981 898 982 /** 899 983 * @ticket 13771 984 * 985 * @covers ::get_the_date 900 986 */ 901 987 function test_get_the_date_with_id_returns_correct_time() { 902 988 $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); … … 905 991 906 992 /** 907 993 * @ticket 28310 994 * 995 * @covers ::get_the_date 908 996 */ 909 997 function test_get_the_date_returns_false_with_null_or_non_existing_post() { 910 998 $this->assertFalse( get_the_date() ); … … 915 1003 916 1004 /** 917 1005 * @ticket 28310 1006 * 1007 * @covers ::get_the_time 918 1008 */ 919 1009 function test_get_the_time_with_id_returns_correct_time() { 920 1010 $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); … … 923 1013 924 1014 /** 925 1015 * @ticket 28310 1016 * 1017 * @covers ::get_the_time 926 1018 */ 927 1019 function test_get_the_time_returns_false_with_null_or_non_existing_post() { 928 1020 $this->assertFalse( get_the_time() ); … … 933 1025 934 1026 /** 935 1027 * @ticket 28310 1028 * 1029 * @covers ::get_post_time 936 1030 */ 937 1031 function test_get_post_time_with_id_returns_correct_time() { 938 1032 $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); … … 941 1035 942 1036 /** 943 1037 * @ticket 28310 1038 * 1039 * @covers ::get_post_time 944 1040 */ 945 1041 function test_get_post_time_returns_false_with_null_or_non_existing_post() { 946 1042 $this->assertFalse( get_post_time() ); … … 951 1047 952 1048 /** 953 1049 * @ticket 28310 1050 * 1051 * @covers ::get_post_modified_time 954 1052 */ 955 1053 function test_get_post_modified_time_with_id_returns_correct_time() { 956 1054 $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); … … 959 1057 960 1058 /** 961 1059 * @ticket 28310 1060 * 1061 * @covers ::get_post_modified_time 962 1062 */ 963 1063 function test_get_post_modified_time_returns_false_with_null_or_non_existing_post() { 964 1064 $this->assertFalse( get_post_modified_time() ); … … 969 1069 970 1070 /** 971 1071 * @ticket 28310 1072 * 1073 * @covers ::mysql2date 972 1074 */ 973 1075 function test_mysql2date_returns_false_with_no_date() { 974 1076 $this->assertFalse( mysql2date( 'F j, Y H:i:s', '' ) ); … … 976 1078 977 1079 /** 978 1080 * @ticket 28310 1081 * 1082 * @covers ::mysql2date 979 1083 */ 980 1084 function test_mysql2date_returns_gmt_or_unix_timestamp() { 981 1085 $this->assertEquals( '441013392', mysql2date( 'G', '1983-12-23 07:43:12' ) ); … … 984 1088 985 1089 /** 986 1090 * @ticket 25566 1091 * 1092 * @covers ::wp_tag_cloud 987 1093 */ 988 1094 function test_wp_tag_cloud_link_with_post_type() { 989 1095 $post_type = 'new_post_type'; … … 1017 1123 1018 1124 /** 1019 1125 * @ticket 21212 1126 * 1127 * @covers ::edit_post 1020 1128 */ 1021 1129 function test_utf8mb3_post_saves_with_emoji() { 1022 1130 global $wpdb; … … 1053 1161 1054 1162 /** 1055 1163 * @ticket 31168 1164 * 1165 * @covers ::wp_insert_post 1056 1166 */ 1057 1167 function test_wp_insert_post_default_comment_ping_status_open() { 1058 1168 $post_id = self::factory()->post->create( … … 1071 1181 1072 1182 /** 1073 1183 * @ticket 31168 1184 * 1185 * @covers ::wp_insert_post 1074 1186 */ 1075 1187 function test_wp_insert_post_page_default_comment_ping_status_closed() { 1076 1188 $post_id = self::factory()->post->create( … … 1090 1202 1091 1203 /** 1092 1204 * @ticket 31168 1205 * 1206 * @covers ::wp_insert_post 1093 1207 */ 1094 1208 function test_wp_insert_post_cpt_default_comment_ping_status_open() { 1095 1209 $post_type = rand_str( 20 ); … … 1112 1226 1113 1227 /** 1114 1228 * @ticket 31168 1229 * 1230 * @covers ::wp_insert_post 1115 1231 */ 1116 1232 function test_wp_insert_post_cpt_default_comment_ping_status_closed() { 1117 1233 $post_type = rand_str( 20 ); … … 1137 1253 * it should _stay_ sticky. 1138 1254 * 1139 1255 * @ticket 24153 1256 * 1257 * @covers ::stick_post 1140 1258 */ 1141 1259 function test_user_without_publish_cannot_affect_sticky() { 1142 1260 wp_set_current_user( self::$grammarian_id ); … … 1175 1293 * the sticky status of the post should not be changed. 1176 1294 * 1177 1295 * @ticket 24153 1296 * 1297 * @covers ::stick_post 1178 1298 */ 1179 1299 function test_user_without_publish_cannot_affect_sticky_with_edit_post() { 1180 1300 // Create a sticky post. … … 1215 1335 * Test that hooks are fired when post gets stuck and unstuck. 1216 1336 * 1217 1337 * @ticket 35600 1338 * 1339 * @covers ::stick_post 1218 1340 */ 1219 1341 function test_hooks_fire_when_post_gets_stuck_and_unstuck() { 1220 1342 $post_id = self::factory()->post->create(); … … 1243 1365 * a new slug should not be generated. 1244 1366 * 1245 1367 * @ticket 34865 1368 * 1369 * @covers ::wp_insert_post 1246 1370 */ 1247 1371 function test_post_updates_without_slug_provided() { 1248 1372 $post_id = self::factory()->post->create( … … 1266 1390 1267 1391 /** 1268 1392 * @ticket 32585 1393 * 1394 * @covers ::wp_insert_post 1269 1395 */ 1270 1396 public function test_wp_insert_post_author_zero() { 1271 1397 $post_id = self::factory()->post->create( array( 'post_author' => 0 ) ); … … 1275 1401 1276 1402 /** 1277 1403 * @ticket 32585 1404 * 1405 * @covers ::wp_insert_post 1278 1406 */ 1279 1407 public function test_wp_insert_post_author_null() { 1280 1408 $post_id = self::factory()->post->create( array( 'post_author' => null ) ); … … 1284 1412 1285 1413 /** 1286 1414 * @ticket 15946 1415 * 1416 * @covers ::wp_insert_post 1287 1417 */ 1288 1418 function test_wp_insert_post_should_respect_post_date_gmt() { 1289 1419 $post = array( … … 1306 1436 $this->assertEquals( $post['post_date_gmt'], $out->post_date_gmt ); 1307 1437 } 1308 1438 1439 /** 1440 * 1441 * @covers ::wp_delete_post 1442 */ 1309 1443 function test_wp_delete_post_reassign_hierarchical_post_type() { 1310 1444 $grandparent_page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 1311 1445 $parent_page_id = self::factory()->post->create( … … 1332 1466 * 1333 1467 * @see _wp_customize_changeset_filter_insert_post_data() 1334 1468 * @ticket 30937 1469 * 1470 * @covers ::wp_insert_post 1335 1471 */ 1336 1472 function test_wp_insert_post_for_customize_changeset_should_not_drop_post_name() { 1337 1473 … … 1385 1521 * 1386 1522 * @see wp_unique_post_slug() 1387 1523 * @ticket 21112 1524 * 1525 * @covers ::wp_insert_post 1388 1526 */ 1389 1527 function test_pre_wp_unique_post_slug_filter() { 1390 1528 add_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 ); … … 1408 1546 1409 1547 /** 1410 1548 * @ticket 48113 1549 * 1550 * @covers ::wp_insert_post 1411 1551 */ 1412 1552 public function test_insert_post_should_respect_date_floating_post_status_arg() { 1413 1553 register_post_status( 'floating', array( 'date_floating' => true ) ); … … 1426 1566 1427 1567 /** 1428 1568 * @ticket 48113 1569 * 1570 * @covers ::wp_insert_post 1429 1571 */ 1430 1572 public function test_insert_post_should_respect_date_floating_post_status_arg_not_set() { 1431 1573 register_post_status( 'not-floating', array( 'date_floating' => false ) ); … … 1450 1592 * and is different from the existing tags. 1451 1593 * 1452 1594 * @ticket 45121 1595 * 1596 * @covers ::wp_update_post 1453 1597 */ 1454 1598 public function test_update_post_should_only_modify_post_tags_if_different_tags_input_was_provided() { 1455 1599 $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
679 679 /** 680 680 * Test _wp_delete_customize_changeset_dependent_auto_drafts. 681 681 * 682 * @covers ::_wp_delete_customize_changeset_dependent_auto_drafts ()682 * @covers ::_wp_delete_customize_changeset_dependent_auto_drafts 683 683 */ 684 684 function test_wp_delete_customize_changeset_dependent_auto_drafts() { 685 685 $auto_draft_post_id = $this->factory()->post->create( -
tests/phpunit/tests/post/types.php
68 68 69 69 /** 70 70 * @ticket 35985 71 * @covers ::register_post_type ()71 * @covers ::register_post_type 72 72 */ 73 73 function test_register_post_type_exclude_from_search_should_default_to_opposite_value_of_public() { 74 74 /* … … 82 82 83 83 /** 84 84 * @ticket 35985 85 * @covers ::register_post_type ()85 * @covers ::register_post_type 86 86 */ 87 87 function test_register_post_type_publicly_queryable_should_default_to_value_of_public() { 88 88 /* … … 96 96 97 97 /** 98 98 * @ticket 35985 99 * @covers ::register_post_type ()99 * @covers ::register_post_type 100 100 */ 101 101 function test_register_post_type_show_ui_should_default_to_value_of_public() { 102 102 /* … … 110 110 111 111 /** 112 112 * @ticket 35985 113 * @covers ::register_post_type ()113 * @covers ::register_post_type 114 114 */ 115 115 function test_register_post_type_show_in_menu_should_default_to_value_of_show_ui() { 116 116 /* … … 129 129 130 130 /** 131 131 * @ticket 35985 132 * @covers ::register_post_type ()132 * @covers ::register_post_type 133 133 */ 134 134 function test_register_post_type_show_in_nav_menus_should_default_to_value_of_public() { 135 135 /* … … 143 143 144 144 /** 145 145 * @ticket 35985 146 * @covers ::register_post_type ()146 * @covers ::register_post_type 147 147 */ 148 148 function test_register_post_type_show_in_admin_bar_should_default_to_value_of_show_in_menu() { 149 149 /* -
tests/phpunit/tests/query.php
11 11 12 12 /** 13 13 * @ticket 24785 14 * 15 * @covers WP_Query::reset_postdata 14 16 */ 15 17 function test_nested_loop_reset_postdata() { 16 18 $post_id = self::factory()->post->create(); … … 31 33 32 34 /** 33 35 * @ticket 16471 36 * 37 * @covers WP_Query::get 34 38 */ 35 39 function test_default_query_var() { 36 40 $query = new WP_Query; … … 41 45 42 46 /** 43 47 * @ticket 25380 48 * 49 * @covers WP_Query::get_posts 44 50 */ 45 51 function test_pre_posts_per_page() { 46 52 self::factory()->post->create_many( 10 ); … … 58 64 59 65 /** 60 66 * @ticket 26627 67 * 68 * @covers ::get_term_by 69 * @covers ::get_query_var 70 * @covers ::get_queried_object 61 71 */ 62 72 function test_tag_queried_object() { 63 73 $slug = 'tag-slug-26627'; … … 89 99 90 100 /** 91 101 * @ticket 31246 102 * 103 * @covers WP_Query::get_queried_object 92 104 */ 93 105 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() { 94 106 // Don't override the args provided below. … … 125 137 126 138 /** 127 139 * @ticket 37962 140 * 141 * @covers WP_Query::get_queried_object 128 142 */ 129 143 public function test_get_queried_object_should_return_null_for_not_exists_tax_query() { 130 144 register_taxonomy( 'wptests_tax', 'post' ); … … 144 158 $this->assertNull( $queried_object ); 145 159 } 146 160 161 /** 162 * 163 * @covers WP_Query::__construct 164 */ 147 165 public function test_orderby_space_separated() { 148 166 global $wpdb; 149 167 … … 157 175 $this->assertContains( "ORDER BY $wpdb->posts.post_title DESC, $wpdb->posts.post_date DESC", $q->request ); 158 176 } 159 177 178 /** 179 * 180 * @covers ::wp_set_object_terms 181 */ 160 182 public function test_cat_querystring_single_term() { 161 183 $c1 = self::factory()->category->create( 162 184 array( … … 193 215 $this->assertEqualSets( array( $p1, $p2 ), $matching_posts ); 194 216 } 195 217 218 /** 219 * 220 * @covers ::wp_set_object_terms 221 */ 196 222 public function test_category_querystring_multiple_terms_comma_separated() { 197 223 $c1 = self::factory()->category->create( 198 224 array( … … 239 265 240 266 /** 241 267 * @ticket 33532 268 * 269 * @covers ::wp_set_object_terms 242 270 */ 243 271 public function test_category_querystring_multiple_terms_formatted_as_array() { 244 272 $c1 = self::factory()->category->create( … … 284 312 $this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts ); 285 313 } 286 314 287 315 /** 316 * 317 * @covers ::wp_set_object_terms 318 */ 288 319 public function test_tag_querystring_single_term() { 289 320 $t1 = self::factory()->tag->create_and_get( 290 321 array( … … 321 352 $this->assertEqualSets( array( $p1, $p2 ), $matching_posts ); 322 353 } 323 354 355 /** 356 * 357 * @covers ::wp_set_object_terms 358 */ 324 359 public function test_tag_querystring_multiple_terms_comma_separated() { 325 360 $c1 = self::factory()->tag->create_and_get( 326 361 array( … … 367 402 368 403 /** 369 404 * @ticket 33532 405 * 406 * @covers WP_Query::get_posts 370 407 */ 371 408 public function test_tag_querystring_multiple_terms_formatted_as_array() { 372 409 $c1 = self::factory()->tag->create_and_get( … … 412 449 $this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts ); 413 450 } 414 451 452 /** 453 * 454 * @covers WP_Query::get_posts 455 */ 415 456 public function test_custom_taxonomy_querystring_single_term() { 416 457 register_taxonomy( 'test_tax_cat', 'post' ); 417 458 … … 439 480 $this->assertEqualSets( array( $p1, $p2 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) ); 440 481 } 441 482 483 /** 484 * 485 * @covers WP_Query::get_posts 486 */ 442 487 public function test_custom_taxonomy_querystring_multiple_terms_comma_separated() { 443 488 register_taxonomy( 'test_tax_cat', 'post' ); 444 489 … … 470 515 471 516 /** 472 517 * @ticket 32454 518 * 519 * @covers WP_Query::get_posts 473 520 */ 474 521 public function test_custom_taxonomy_querystring_multiple_terms_formatted_as_array() { 475 522 register_taxonomy( 'test_tax_cat', 'post' ); … … 502 549 503 550 /** 504 551 * @ticket 31355 552 * 553 * @covers WP_Query::is_404 505 554 */ 506 555 public function test_pages_dont_404_when_queried_post_id_is_modified() { 507 556 $post_id = self::factory()->post->create( … … 524 573 525 574 /** 526 575 * @ticket 31355 576 * 577 * @covers WP_Query::is_404 527 578 */ 528 579 public function test_custom_hierarchical_post_types_404_when_queried_post_id_is_modified() { 529 580 global $wp_rewrite; … … 561 612 562 613 /** 563 614 * @ticket 34060 615 * 616 * @covers WP_Query::__construct 564 617 */ 565 618 public function test_offset_0_should_override_page() { 566 619 $q = new WP_Query( … … 576 629 577 630 /** 578 631 * @ticket 34060 632 * 633 * @covers WP_Query::__construct 579 634 */ 580 635 public function test_offset_should_be_ignored_when_not_set() { 581 636 $q = new WP_Query( … … 590 645 591 646 /** 592 647 * @ticket 34060 648 * 649 * @covers WP_Query::__construct 593 650 */ 594 651 public function test_offset_should_be_ignored_when_passed_a_non_numeric_value() { 595 652 $q = new WP_Query( … … 605 662 606 663 /** 607 664 * @ticket 35601 665 * 666 * @covers WP_Query::__construct 608 667 */ 609 668 public function test_comment_status() { 610 669 $p1 = self::factory()->post->create( array( 'comment_status' => 'open' ) ); … … 622 681 623 682 /** 624 683 * @ticket 35601 684 * 685 * @covers WP_Query::__construct 625 686 */ 626 687 public function test_ping_status() { 627 688 $p1 = self::factory()->post->create( array( 'ping_status' => 'open' ) ); … … 639 700 640 701 /** 641 702 * @ticket 35619 703 * 704 * @covers ::get_queried_object 642 705 */ 643 706 public function test_get_queried_object_should_return_first_of_multiple_terms() { 644 707 register_taxonomy( 'tax1', 'post' ); … … 669 732 670 733 /** 671 734 * @ticket 35619 735 * 736 * @covers ::get_queried_object 672 737 */ 673 738 public function test_query_vars_should_match_first_of_multiple_terms() { 674 739 register_taxonomy( 'tax1', 'post' ); -
tests/phpunit/tests/rest-api.php
29 29 30 30 /** 31 31 * 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 32 37 */ 33 38 function test_rest_api_active() { 34 39 $this->assertTrue( class_exists( 'WP_REST_Server' ) ); … … 40 45 /** 41 46 * The rest_api_init hook should have been registered with init, and should 42 47 * have a default priority of 10. 48 * 49 * @covers ::rest_api_init 43 50 */ 44 51 function test_init_action_added() { 45 52 $this->assertEquals( 10, has_action( 'init', 'rest_api_init' ) ); 46 53 } 47 54 55 /** 56 * @covers ::create_initial_taxonomies 57 */ 48 58 public function test_add_extra_api_taxonomy_arguments() { 49 59 $taxonomy = get_taxonomy( 'category' ); 50 60 $this->assertTrue( $taxonomy->show_in_rest ); … … 57 67 $this->assertEquals( 'WP_REST_Terms_Controller', $taxonomy->rest_controller_class ); 58 68 } 59 69 70 /** 71 * @covers ::create_initial_post_types 72 */ 60 73 public function test_add_extra_api_post_type_arguments() { 61 74 $post_type = get_post_type_object( 'post' ); 62 75 $this->assertTrue( $post_type->show_in_rest ); … … 78 91 * Check that a single route is canonicalized. 79 92 * 80 93 * Ensures that single and multiple routes are handled correctly. 94 * 95 * @covers ::register_rest_route 81 96 */ 82 97 public function test_route_canonicalized() { 83 98 register_rest_route( … … 114 129 * Check that a single route is canonicalized. 115 130 * 116 131 * Ensures that single and multiple routes are handled correctly. 132 * 133 * @covers ::register_rest_route 117 134 */ 118 135 public function test_route_canonicalized_multiple() { 119 136 register_rest_route( … … 157 174 158 175 /** 159 176 * Check that routes are merged by default. 177 * 178 * @covers ::register_rest_route 160 179 */ 161 180 public function test_route_merge() { 162 181 register_rest_route( … … 186 205 187 206 /** 188 207 * Check that we can override routes. 208 * 209 * @covers ::register_rest_route 189 210 */ 190 211 public function test_route_override() { 191 212 register_rest_route( … … 224 245 * Test that we reject routes without namespaces 225 246 * 226 247 * @expectedIncorrectUsage register_rest_route 248 * 249 * @covers ::register_rest_route 227 250 */ 228 251 public function test_route_reject_empty_namespace() { 229 252 register_rest_route( … … 244 267 * Test that we reject empty routes 245 268 * 246 269 * @expectedIncorrectUsage register_rest_route 270 * 271 * @covers ::register_rest_route 247 272 */ 248 273 public function test_route_reject_empty_route() { 249 274 register_rest_route( … … 262 287 263 288 /** 264 289 * The rest_route query variable should be registered. 290 * 291 * @covers ::rest_api_init 265 292 */ 266 293 function test_rest_route_query_var() { 267 294 rest_api_init(); … … 268 295 $this->assertTrue( in_array( 'rest_route', $GLOBALS['wp']->public_query_vars, true ) ); 269 296 } 270 297 298 /** 299 * @covers ::register_rest_route 300 */ 271 301 public function test_route_method() { 272 302 register_rest_route( 273 303 'test-ns', … … 286 316 287 317 /** 288 318 * The 'methods' arg should accept a single value as well as array. 319 * 320 * @covers ::register_rest_route 289 321 */ 290 322 public function test_route_method_string() { 291 323 register_rest_route( … … 305 337 306 338 /** 307 339 * The 'methods' arg should accept a single value as well as array. 340 * 341 * @covers ::register_rest_route 308 342 */ 309 343 public function test_route_method_array() { 310 344 register_rest_route( … … 330 364 331 365 /** 332 366 * The 'methods' arg should a comma-separated string. 367 * 368 * @covers ::register_rest_route 333 369 */ 334 370 public function test_route_method_comma_separated() { 335 371 register_rest_route( … … 353 389 ); 354 390 } 355 391 392 /** 393 * @covers ::register_rest_route 394 */ 356 395 public function test_options_request() { 357 396 register_rest_route( 358 397 'test-ns', … … 375 414 376 415 /** 377 416 * Ensure that the OPTIONS handler doesn't kick in for non-OPTIONS requests. 417 * 418 * @covers ::rest_handle_options_request 378 419 */ 379 420 public function test_options_request_not_options() { 380 421 register_rest_route( … … 395 436 396 437 /** 397 438 * Ensure that result fields are not allowed if no request['_fields'] is present. 439 * 440 * @covers ::rest_filter_response_fields 398 441 */ 399 442 public function test_rest_filter_response_fields_no_request_filter() { 400 443 $response = new WP_REST_Response(); … … 407 450 408 451 /** 409 452 * Ensure that result fields are allowed if request['_fields'] is present. 453 * 454 * @covers ::rest_filter_response_fields 410 455 */ 411 456 public function test_rest_filter_response_fields_single_field_filter() { 412 457 $response = new WP_REST_Response(); … … 427 472 428 473 /** 429 474 * Ensure that multiple comma-separated fields may be allowed with request['_fields']. 475 * 476 * @covers ::rest_filter_response_fields 430 477 */ 431 478 public function test_rest_filter_response_fields_multi_field_filter() { 432 479 $response = new WP_REST_Response(); … … 458 505 /** 459 506 * Ensure that multiple comma-separated fields may be allowed 460 507 * with request['_fields'] using query parameter array syntax. 508 * 509 * @covers ::rest_filter_response_fields 461 510 */ 462 511 public function test_rest_filter_response_fields_multi_field_filter_array() { 463 512 $response = new WP_REST_Response(); … … 489 538 490 539 /** 491 540 * Ensure that request['_fields'] allowed list apply to items in response collections. 541 * 542 * @covers ::rest_filter_response_fields 492 543 */ 493 544 public function test_rest_filter_response_fields_numeric_array() { 494 545 $response = new WP_REST_Response(); … … 539 590 * Ensure that nested fields may be allowed with request['_fields']. 540 591 * 541 592 * @ticket 42094 593 * 594 * @covers ::rest_filter_response_fields 542 595 */ 543 596 public function test_rest_filter_response_fields_nested_field_filter() { 544 597 $response = new WP_REST_Response(); … … 580 633 * Ensure inclusion of deeply nested fields may be controlled with request['_fields']. 581 634 * 582 635 * @ticket 49648 636 * 637 * @covers ::rest_filter_response_fields 583 638 */ 584 639 public function test_rest_filter_response_fields_deeply_nested_field_filter() { 585 640 $response = new WP_REST_Response(); … … 622 677 * Ensure that specifying a single top-level key in _fields includes that field and all children. 623 678 * 624 679 * @ticket 48266 680 * 681 * @covers ::rest_filter_response_fields 625 682 */ 626 683 public function test_rest_filter_response_fields_top_level_key() { 627 684 $response = new WP_REST_Response(); … … 654 711 * Ensure that a top-level key in _fields supersedes any specified children of that field. 655 712 * 656 713 * @ticket 48266 714 * 715 * @covers ::rest_filter_response_fields 657 716 */ 658 717 public function test_rest_filter_response_fields_child_after_parent() { 659 718 $response = new WP_REST_Response(); … … 686 745 * Ensure that specifying two sibling properties in _fields causes both to be included. 687 746 * 688 747 * @ticket 48266 748 * 749 * @covers ::rest_filter_response_fields 689 750 */ 690 751 public function test_rest_filter_response_fields_include_all_specified_siblings() { 691 752 $response = new WP_REST_Response(); … … 716 777 717 778 /** 718 779 * @ticket 42094 780 * 781 * @covers ::rest_is_field_included 719 782 */ 720 783 public function test_rest_is_field_included() { 721 784 $fields = array( … … 741 804 /** 742 805 * The get_rest_url function should return a URL consistently terminated with a "/", 743 806 * whether the blog is configured with pretty permalink support or not. 807 * 808 * @covers ::get_rest_url 744 809 */ 745 810 public function test_rest_url_generation() { 746 811 // In pretty permalinks case, we expect a path of wp-json/ with no query. … … 758 823 759 824 /** 760 825 * @ticket 34299 826 * 827 * @covers ::get_rest_url 761 828 */ 762 829 public function test_rest_url_scheme() { 763 830 $_SERVER['SERVER_NAME'] = parse_url( home_url(), PHP_URL_HOST ); … … 799 866 800 867 /** 801 868 * @ticket 42452 869 * 870 * @covers ::get_rest_url 802 871 */ 803 872 public function test_always_prepend_path_with_slash_in_rest_url_filter() { 804 873 $filter = new MockAction(); … … 844 913 845 914 /** 846 915 * @dataProvider jsonp_callback_provider 916 * 917 * @covers ::wp_check_jsonp_callback 847 918 */ 848 919 public function test_jsonp_callback_check( $callback, $valid ) { 849 920 $this->assertEquals( $valid, wp_check_jsonp_callback( $callback ) ); … … 876 947 877 948 /** 878 949 * @dataProvider rest_date_provider 950 * 951 * @covers ::rest_parse_date 879 952 */ 880 953 public function test_rest_parse_date( $string, $value ) { 881 954 $this->assertEquals( $value, rest_parse_date( $string ) ); … … 908 981 909 982 /** 910 983 * @dataProvider rest_date_force_utc_provider 984 * 985 * @covers ::rest_parse_date 911 986 */ 912 987 public function test_rest_parse_date_force_utc( $string, $value ) { 913 988 $this->assertEquals( $value, rest_parse_date( $string, true ) ); … … 917 992 return 'Spy_REST_Server'; 918 993 } 919 994 995 /** 996 * @covers ::register_rest_route 997 */ 920 998 public function test_register_rest_route_without_server() { 921 999 $GLOBALS['wp_rest_server'] = null; 922 1000 add_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) ); … … 935 1013 $this->assertEquals( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); 936 1014 } 937 1015 1016 /** 1017 * 1018 */ 938 1019 function test_rest_preload_api_request_with_method() { 939 1020 $rest_server = $GLOBALS['wp_rest_server']; 940 1021 $GLOBALS['wp_rest_server'] = null; … … 958 1039 959 1040 /** 960 1041 * @ticket 40614 1042 * 1043 * @covers ::rest_ensure_request 961 1044 */ 962 1045 function test_rest_ensure_request_accepts_path_string() { 963 1046 $request = rest_ensure_request( '/wp/v2/posts' ); … … 968 1051 969 1052 /** 970 1053 * @dataProvider _dp_rest_parse_embed_param 1054 * 1055 * @covers ::rest_parse_embed_param 971 1056 */ 972 1057 public function test_rest_parse_embed_param( $expected, $embed ) { 973 1058 $this->assertEquals( $expected, rest_parse_embed_param( $embed ) ); … … 997 1082 * @ticket 48819 998 1083 * 999 1084 * @dataProvider _dp_rest_filter_response_by_context 1085 * 1086 * @covers ::rest_filter_response_by_context 1000 1087 */ 1001 1088 public function test_rest_filter_response_by_context( $schema, $data, $expected ) { 1002 1089 $this->assertEquals( $expected, rest_filter_response_by_context( $data, $schema, 'view' ) ); … … 1004 1091 1005 1092 /** 1006 1093 * @ticket 49749 1094 * 1095 * @covers ::register_rest_route 1007 1096 */ 1008 1097 public function test_register_route_with_invalid_namespace() { 1009 1098 $this->setExpectedIncorrectUsage( 'register_rest_route' ); … … 1025 1114 1026 1115 /** 1027 1116 * @ticket 50075 1117 * 1118 * @covers ::register_rest_route 1028 1119 */ 1029 1120 public function test_register_route_with_missing_permission_callback_top_level_route() { 1030 1121 $this->setExpectedIncorrectUsage( 'register_rest_route' ); … … 1042 1133 1043 1134 /** 1044 1135 * @ticket 50075 1136 * 1137 * @covers ::register_rest_route 1045 1138 */ 1046 1139 public function test_register_route_with_missing_permission_callback_single_wrapped_route() { 1047 1140 $this->setExpectedIncorrectUsage( 'register_rest_route' ); … … 1062 1155 1063 1156 /** 1064 1157 * @ticket 50075 1158 * 1159 * @covers ::register_rest_route 1065 1160 */ 1066 1161 public function test_register_route_with_missing_permission_callback_multiple_wrapped_route() { 1067 1162 $this->setExpectedIncorrectUsage( 'register_rest_route' ); … … 1514 1609 ); 1515 1610 } 1516 1611 1612 /** 1613 * @covers ::rest_ensure_response 1614 */ 1517 1615 function test_rest_ensure_response_accepts_wp_error_and_returns_wp_error() { 1518 1616 $response = rest_ensure_response( new WP_Error() ); 1519 1617 $this->assertInstanceOf( 'WP_Error', $response ); … … 1524 1622 * 1525 1623 * @param mixed $response The response passed to rest_ensure_response(). 1526 1624 * @param mixed $expected_data The expected data a response should include. 1625 * 1626 * @covers ::rest_ensure_response 1527 1627 */ 1528 1628 function test_rest_ensure_response_returns_instance_of_wp_rest_response( $response, $expected_data ) { 1529 1629 $response_object = rest_ensure_response( $response ); … … 1550 1650 1551 1651 /** 1552 1652 * @ticket 49116 1653 * 1654 * @covers ::rest_get_route_for_post 1553 1655 */ 1554 1656 public function test_rest_get_route_for_post_non_post() { 1555 1657 $this->assertEquals( '', rest_get_route_for_post( 'garbage' ) ); … … 1557 1659 1558 1660 /** 1559 1661 * @ticket 49116 1662 * 1663 * @covers ::rest_get_route_for_post 1560 1664 */ 1561 1665 public function test_rest_get_route_for_post_invalid_post_type() { 1562 1666 register_post_type( 'invalid' ); … … 1568 1672 1569 1673 /** 1570 1674 * @ticket 49116 1675 * 1676 * @covers ::rest_get_route_for_post 1571 1677 */ 1572 1678 public function test_rest_get_route_for_post_non_rest() { 1573 1679 $post = self::factory()->post->create_and_get( array( 'post_type' => 'custom_css' ) ); … … 1576 1682 1577 1683 /** 1578 1684 * @ticket 49116 1685 * 1686 * @covers ::rest_get_route_for_post 1579 1687 */ 1580 1688 public function test_rest_get_route_for_post_custom_controller() { 1581 1689 $post = self::factory()->post->create_and_get( array( 'post_type' => 'wp_block' ) ); … … 1584 1692 1585 1693 /** 1586 1694 * @ticket 49116 1695 * 1696 * @covers ::rest_get_route_for_post 1587 1697 */ 1588 1698 public function test_rest_get_route_for_post() { 1589 1699 $post = self::factory()->post->create_and_get(); … … 1592 1702 1593 1703 /** 1594 1704 * @ticket 49116 1705 * 1706 * @covers ::rest_get_route_for_post 1595 1707 */ 1596 1708 public function test_rest_get_route_for_media() { 1597 1709 $post = self::factory()->attachment->create_and_get(); … … 1600 1712 1601 1713 /** 1602 1714 * @ticket 49116 1715 * 1716 * @covers ::rest_get_route_for_post 1603 1717 */ 1604 1718 public function test_rest_get_route_for_post_id() { 1605 1719 $post = self::factory()->post->create_and_get(); … … 1608 1722 1609 1723 /** 1610 1724 * @ticket 49116 1725 * 1726 * @covers ::rest_get_route_for_term 1611 1727 */ 1612 1728 public function test_rest_get_route_for_term_non_term() { 1613 1729 $this->assertEquals( '', rest_get_route_for_term( 'garbage' ) ); … … 1615 1731 1616 1732 /** 1617 1733 * @ticket 49116 1734 * 1735 * @covers ::rest_get_route_for_term 1618 1736 */ 1619 1737 public function test_rest_get_route_for_term_invalid_term_type() { 1620 1738 register_taxonomy( 'invalid', 'post' ); … … 1626 1744 1627 1745 /** 1628 1746 * @ticket 49116 1747 * 1748 * @covers ::rest_get_route_for_term 1629 1749 */ 1630 1750 public function test_rest_get_route_for_term_non_rest() { 1631 1751 $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'post_format' ) ); … … 1634 1754 1635 1755 /** 1636 1756 * @ticket 49116 1757 * 1758 * @covers ::rest_get_route_for_term 1637 1759 */ 1638 1760 public function test_rest_get_route_for_term() { 1639 1761 $term = self::factory()->term->create_and_get(); … … 1642 1764 1643 1765 /** 1644 1766 * @ticket 49116 1767 * 1768 * @covers ::rest_get_route_for_term 1645 1769 */ 1646 1770 public function test_rest_get_route_for_category() { 1647 1771 $term = self::factory()->category->create_and_get(); … … 1650 1774 1651 1775 /** 1652 1776 * @ticket 49116 1777 * 1778 * @covers ::rest_get_route_for_term 1653 1779 */ 1654 1780 public function test_rest_get_route_for_term_id() { 1655 1781 $term = self::factory()->term->create_and_get(); … … 1663 1789 * 1664 1790 * @param bool $expected Expected result of the check. 1665 1791 * @param mixed $value The value to check. 1792 * 1793 * @covers ::rest_is_object 1666 1794 */ 1667 1795 public function test_rest_is_object( $expected, $value ) { 1668 1796 $is_object = rest_is_object( $value ); … … 1726 1854 * 1727 1855 * @param array $expected Expected sanitized version. 1728 1856 * @param mixed $value The value to sanitize. 1857 * 1858 * @covers ::rest_sanitize_object 1729 1859 */ 1730 1860 public function test_rest_sanitize_object( $expected, $value ) { 1731 1861 $sanitized = rest_sanitize_object( $value ); … … 1784 1914 * 1785 1915 * @param bool $expected Expected result of the check. 1786 1916 * @param mixed $value The value to check. 1917 * 1918 * @covers ::rest_is_array 1787 1919 */ 1788 1920 public function test_rest_is_array( $expected, $value ) { 1789 1921 $is_array = rest_is_array( $value ); … … 1855 1987 * 1856 1988 * @param array $expected Expected sanitized version. 1857 1989 * @param mixed $value The value to sanitize. 1990 * 1991 * @covers ::rest_sanitize_array 1858 1992 */ 1859 1993 public function test_rest_sanitize_array( $expected, $value ) { 1860 1994 $sanitized = rest_sanitize_array( $value ); … … 1926 2060 * @param string $expected The expected best type. 1927 2061 * @param mixed $value The value to test. 1928 2062 * @param array $types The list of available types. 2063 * 2064 * @covers ::rest_get_best_type_for_value 1929 2065 */ 1930 2066 public function test_get_best_type_for_value( $expected, $value, $types ) { 1931 2067 $this->assertEquals( $expected, rest_get_best_type_for_value( $value, $types ) ); -
tests/phpunit/tests/rewrite.php
27 27 28 28 /** 29 29 * @ticket 16840 30 * 31 * @covers ::add_rule 30 32 */ 31 33 public function test_add_rule() { 32 34 global $wp_rewrite; … … 45 47 46 48 /** 47 49 * @ticket 16840 50 * 51 * @covers ::add_rule 48 52 */ 49 53 public function test_add_rule_redirect_array() { 50 54 global $wp_rewrite; … … 69 73 70 74 /** 71 75 * @ticket 16840 76 * 77 * @covers ::add_rule 72 78 */ 73 79 public function test_add_rule_top() { 74 80 global $wp_rewrite; … … 85 91 $this->assertContains( $redirect, $extra_rules_top[ $pattern ] ); 86 92 } 87 93 94 /** 95 * 96 * @covers ::url_to_postid 97 */ 88 98 function test_url_to_postid() { 89 99 90 100 $id = self::factory()->post->create(); … … 94 104 $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); 95 105 } 96 106 107 /** 108 * 109 * @covers ::url_to_postid 110 * @covers ::set_url_scheme 111 */ 97 112 function test_url_to_postid_set_url_scheme_https_to_http() { 98 113 $post_id = self::factory()->post->create(); 99 114 $permalink = get_permalink( $post_id ); … … 104 119 $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); 105 120 } 106 121 122 /** 123 * 124 * @covers ::url_to_postid 125 * @covers ::set_url_scheme 126 */ 107 127 function test_url_to_postid_set_url_scheme_http_to_https() { 108 128 $_SERVER['HTTPS'] = 'on'; 109 129 … … 123 143 * @ticket 35531 124 144 * @group multisite 125 145 * @group ms-required 146 * 147 * @covers ::url_to_postid 126 148 */ 127 149 function test_url_to_postid_of_http_site_when_current_site_uses_https() { 128 150 $_SERVER['HTTPS'] = 'on'; … … 170 192 return $url; 171 193 } 172 194 195 /** 196 * 197 * @covers ::url_to_postid 198 */ 173 199 function test_url_to_postid_custom_post_type() { 174 200 delete_option( 'rewrite_rules' ); 175 201 … … 182 208 _unregister_post_type( $post_type ); 183 209 } 184 210 211 /** 212 * 213 * @covers ::url_to_postid 214 */ 185 215 function test_url_to_postid_hierarchical() { 186 216 187 217 $parent_id = self::factory()->post->create( … … 202 232 $this->assertEquals( $child_id, url_to_postid( get_permalink( $child_id ) ) ); 203 233 } 204 234 235 /** 236 * 237 * @covers ::url_to_postid 238 */ 205 239 function test_url_to_postid_hierarchical_with_matching_leaves() { 206 240 207 241 $parent_id = self::factory()->post->create( … … 245 279 $this->assertEquals( $grandchild_id_2, url_to_postid( get_permalink( $grandchild_id_2 ) ) ); 246 280 } 247 281 282 /** 283 * 284 * @covers ::url_to_postid 285 */ 248 286 function test_url_to_postid_home_has_path() { 249 287 250 288 update_option( 'home', home_url( '/example/' ) ); … … 270 308 271 309 /** 272 310 * @ticket 30438 311 * 312 * @covers ::home_url 273 313 */ 274 314 function test_parse_request_home_path() { 275 315 $home_url = home_url( '/path/' ); … … 290 330 291 331 /** 292 332 * @ticket 30438 333 * 334 * @covers ::home_url 293 335 */ 294 336 function test_parse_request_home_path_with_regex_character() { 295 337 $home_url = home_url( '/ma.ch/' ); … … 327 369 328 370 /** 329 371 * @ticket 30018 372 * 373 * @covers ::home_url 330 374 */ 331 375 function test_parse_request_home_path_non_public_type() { 332 376 register_post_type( 'foo', array( 'public' => false ) ); … … 340 384 $this->assertEquals( array(), $GLOBALS['wp']->query_vars ); 341 385 } 342 386 387 /** 388 * 389 * @covers ::url_to_postid 390 */ 343 391 function test_url_to_postid_dupe_path() { 344 392 update_option( 'home', home_url( '/example/' ) ); 345 393 … … 359 407 360 408 /** 361 409 * Reveals bug introduced in WP 3.0 410 * 411 * @covers ::url_to_postid 362 412 */ 363 413 function test_url_to_postid_home_url_collision() { 364 414 update_option( 'home', home_url( '/example' ) ); … … 380 430 * Reveals bug introduced in WP 3.0 381 431 * 382 432 * @group ms-required 433 * 434 * @covers ::network_home_url 383 435 */ 384 436 function test_url_to_postid_ms_home_url_collision() { 385 437 $blog_id = self::factory()->blog->create( array( 'path' => '/example' ) ); … … 401 453 402 454 /** 403 455 * @ticket 21970 456 * 457 * @covers ::url_to_postid 404 458 */ 405 459 function test_url_to_postid_with_post_slug_that_clashes_with_a_trashed_page() { 406 460 $this->set_permalink_structure( '/%postname%/' ); … … 418 472 419 473 /** 420 474 * @ticket 34971 475 * 476 * @covers ::url_to_postid 421 477 */ 422 478 function test_url_to_postid_static_front_page() { 423 479 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); … … 438 494 439 495 /** 440 496 * @ticket 39373 497 * 498 * @covers ::url_to_postid 441 499 */ 442 500 public function test_url_to_postid_should_bail_when_host_does_not_match() { 443 501 $this->set_permalink_structure( '/%postname%/' ); … … 452 510 453 511 /** 454 512 * @ticket 21970 513 * 514 * @covers ::get_permalink 455 515 */ 456 516 function test_parse_request_with_post_slug_that_clashes_with_a_trashed_page() { 457 517 $this->set_permalink_structure( '/%postname%/' ); … … 472 532 473 533 /** 474 534 * @ticket 29107 535 * 536 * @covers ::flush_rules 475 537 */ 476 538 public function test_flush_rules_does_not_delete_option() { 477 539 $this->set_permalink_structure( '' ); -
tests/phpunit/tests/shortcode.php
95 95 return $out; 96 96 } 97 97 98 /** 99 * 100 * @covers ::do_shortcode 101 */ 98 102 function test_noatts() { 99 103 do_shortcode( '[test-shortcode-tag /]' ); 100 104 $this->assertEquals( '', $this->atts ); … … 101 105 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 102 106 } 103 107 108 /** 109 * 110 * @covers ::do_shortcode 111 */ 104 112 function test_one_att() { 105 113 do_shortcode( '[test-shortcode-tag foo="asdf" /]' ); 106 114 $this->assertEquals( array( 'foo' => 'asdf' ), $this->atts ); … … 107 115 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 108 116 } 109 117 118 /** 119 * 120 * @covers ::do_shortcode 121 */ 110 122 function test_not_a_tag() { 111 123 $out = do_shortcode( '[not-a-shortcode-tag]' ); 112 124 $this->assertEquals( '[not-a-shortcode-tag]', $out ); … … 114 126 115 127 /** 116 128 * @ticket 17657 129 * 130 * @covers ::do_shortcode 117 131 */ 118 132 function test_tag_hyphen_not_tag() { 119 133 $out = do_shortcode( '[dumptag-notreal]' ); … … 120 134 $this->assertEquals( '[dumptag-notreal]', $out ); 121 135 } 122 136 137 /** 138 * 139 * @covers ::do_shortcode 140 */ 123 141 function test_tag_underscore_not_tag() { 124 142 $out = do_shortcode( '[dumptag_notreal]' ); 125 143 $this->assertEquals( '[dumptag_notreal]', $out ); 126 144 } 127 145 146 /** 147 * 148 * @covers ::do_shortcode 149 */ 128 150 function test_tag_not_tag() { 129 151 $out = do_shortcode( '[dumptagnotreal]' ); 130 152 $this->assertEquals( '[dumptagnotreal]', $out ); … … 132 154 133 155 /** 134 156 * @ticket 17657 157 * 158 * @covers ::do_shortcode 135 159 */ 136 160 function test_tag_hyphen() { 137 161 $this->assertEquals( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) ); … … 143 167 144 168 /** 145 169 * @ticket 9405 170 * 171 * @covers ::do_shortcode 146 172 */ 147 173 function test_attr_hyphen() { 148 174 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" /]' ); … … 159 185 $this->assertEquals( $expected_attrs, $this->atts ); 160 186 } 161 187 188 /** 189 * 190 * @covers ::do_shortcode 191 */ 162 192 function test_two_atts() { 163 193 do_shortcode( '[test-shortcode-tag foo="asdf" bar="bing" /]' ); 164 194 $this->assertEquals( … … 171 201 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 172 202 } 173 203 204 /** 205 * 206 * @covers ::do_shortcode 207 */ 174 208 function test_noatts_enclosing() { 175 209 do_shortcode( '[test-shortcode-tag]content[/test-shortcode-tag]' ); 176 210 $this->assertEquals( '', $this->atts ); … … 178 212 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 179 213 } 180 214 215 /** 216 * 217 * @covers ::do_shortcode 218 */ 181 219 function test_one_att_enclosing() { 182 220 do_shortcode( '[test-shortcode-tag foo="bar"]content[/test-shortcode-tag]' ); 183 221 $this->assertEquals( array( 'foo' => 'bar' ), $this->atts ); … … 185 223 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 186 224 } 187 225 226 /** 227 * 228 * @covers ::do_shortcode 229 */ 188 230 function test_two_atts_enclosing() { 189 231 do_shortcode( '[test-shortcode-tag foo="bar" baz="bing"]content[/test-shortcode-tag]' ); 190 232 $this->assertEquals( … … 198 240 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 199 241 } 200 242 243 /** 244 * 245 * @covers ::do_shortcode 246 */ 201 247 function test_unclosed() { 202 248 $out = do_shortcode( '[test-shortcode-tag]' ); 203 249 $this->assertEquals( '', $out ); … … 205 251 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 206 252 } 207 253 254 /** 255 * 256 * @covers ::do_shortcode 257 */ 208 258 function test_positional_atts_num() { 209 259 $out = do_shortcode( '[test-shortcode-tag 123]' ); 210 260 $this->assertEquals( '', $out ); … … 212 262 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 213 263 } 214 264 265 /** 266 * 267 * @covers ::do_shortcode 268 */ 215 269 function test_positional_atts_url() { 216 270 $out = do_shortcode( '[test-shortcode-tag http://www.youtube.com/watch?v=eBGIQ7ZuuiU]' ); 217 271 $this->assertEquals( '', $out ); … … 219 273 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 220 274 } 221 275 276 /** 277 * 278 * @covers ::do_shortcode 279 */ 222 280 function test_positional_atts_quotes() { 223 281 $out = do_shortcode( '[test-shortcode-tag "something in quotes" "something else"]' ); 224 282 $this->assertEquals( '', $out ); … … 232 290 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 233 291 } 234 292 293 /** 294 * 295 * @covers ::do_shortcode 296 */ 235 297 function test_positional_atts_mixed() { 236 298 $out = do_shortcode( '[test-shortcode-tag 123 https://wordpress.org/ 0 "foo" bar]' ); 237 299 $this->assertEquals( '', $out ); … … 248 310 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 249 311 } 250 312 313 /** 314 * 315 * @covers ::do_shortcode 316 */ 251 317 function test_positional_and_named_atts() { 252 318 $out = do_shortcode( '[test-shortcode-tag 123 url=https://wordpress.org/ foo bar="baz"]' ); 253 319 $this->assertEquals( '', $out ); … … 263 329 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 264 330 } 265 331 332 /** 333 * 334 * @covers ::do_shortcode 335 */ 266 336 function test_footag_default() { 267 337 $out = do_shortcode( '[footag]' ); 268 338 $this->assertEquals( 'foo = ', $out ); 269 339 } 270 340 341 /** 342 * 343 * @covers ::do_shortcode 344 */ 271 345 function test_footag_val() { 272 346 $val = rand_str(); 273 347 $out = do_shortcode( '[footag foo="' . $val . '"]' ); … … 274 348 $this->assertEquals( 'foo = ' . $val, $out ); 275 349 } 276 350 351 /** 352 * 353 * @covers ::do_shortcode 354 */ 277 355 function test_nested_tags() { 278 356 $out = do_shortcode( '[baztag][dumptag abc="foo" def=123 https://wordpress.org/][/baztag]' ); 279 357 $expected = "content = abc = foo\ndef = 123\n0 = https://wordpress.org\n"; … … 282 360 283 361 /** 284 362 * @ticket 6518 363 * 364 * @covers ::do_shortcode 285 365 */ 286 366 function test_tag_escaped() { 287 367 $out = do_shortcode( '[[footag]] [[bartag foo="bar"]]' ); … … 298 378 $this->assertEquals( '[[footag]] [[bartag foo="bar"]]', $out ); 299 379 } 300 380 381 /** 382 * 383 * @covers ::do_shortcode 384 */ 301 385 function test_tag_not_escaped() { 302 386 // These have square brackets on either end but aren't actually escaped. 303 387 $out = do_shortcode( '[[footag] [bartag foo="bar"]]' ); … … 316 400 $this->assertEquals( '[[foo = foo = bar]]', $out ); 317 401 } 318 402 403 /** 404 * 405 * @covers ::do_shortcode 406 */ 319 407 function test_mixed_tags() { 320 408 $in = <<<EOF 321 409 So this is a post with [footag foo="some stuff"] and a bunch of tags. … … 355 443 356 444 /** 357 445 * @ticket 6562 446 * 447 * @covers ::do_shortcode 358 448 */ 359 449 function test_utf8_whitespace_1() { 360 450 // NO-BREAK SPACE: U+00A0. … … 371 461 372 462 /** 373 463 * @ticket 6562 464 * 465 * @covers ::do_shortcode 374 466 */ 375 467 function test_utf8_whitespace_2() { 376 468 // ZERO WIDTH SPACE: U+200B. … … 387 479 388 480 /** 389 481 * @ticket 14050 482 * 483 * @covers ::shortcode_unautop 390 484 */ 391 485 function test_shortcode_unautop() { 392 486 // A blank line is added at the end, so test with it already there. … … 416 510 * 417 511 * @param string $expected Expected output. 418 512 * @param string $content Content to run strip_shortcodes() on. 513 * 514 * @covers ::strip_shortcodes 419 515 */ 420 516 function test_strip_shortcodes( $expected, $content ) { 421 517 $this->assertEquals( $expected, strip_shortcodes( $content ) ); … … 458 554 return $out; 459 555 } 460 556 557 /** 558 * 559 * @covers ::do_shortcode 560 */ 461 561 function test_shortcode_atts_filter_passes_original_arguments() { 462 562 add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 ); 463 563 … … 481 581 remove_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 ); 482 582 } 483 583 584 /** 585 * 586 * @covers ::do_shortcode 587 */ 484 588 function test_shortcode_atts_filtering() { 485 589 add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts2' ), 10, 3 ); 486 590 … … 498 602 * Check that shortcode_unautop() will always recognize spaces around shortcodes. 499 603 * 500 604 * @ticket 22692 605 * 606 * @covers ::shortcode_unautop 501 607 */ 502 608 function test_spaces_around_shortcodes() { 503 609 $nbsp = "\xC2\xA0"; … … 520 626 * Check for bugginess using normal input with latest patches. 521 627 * 522 628 * @dataProvider data_escaping 629 * 630 * @covers ::do_shortcode 523 631 */ 524 632 function test_escaping( $input, $output ) { 525 633 return $this->assertEquals( $output, do_shortcode( $input ) ); … … 598 706 * Check for bugginess using normal input with latest patches. 599 707 * 600 708 * @dataProvider data_escaping2 709 * 710 * @covers ::strip_shortcodes 601 711 */ 602 712 function test_escaping2( $input, $output ) { 603 713 return $this->assertEquals( $output, strip_shortcodes( $input ) ); … … 638 748 639 749 /** 640 750 * @ticket 26343 751 * 752 * @covers ::has_shortcode 641 753 */ 642 754 function test_has_shortcode() { 643 755 $content = 'This is a blob with [gallery] in it'; … … 654 766 * 655 767 * @dataProvider data_registration_bad 656 768 * @expectedIncorrectUsage add_shortcode 769 * 770 * @covers ::shortcode_exists 657 771 */ 658 772 function test_registration_bad( $input, $expected ) { 659 773 return $this->sub_registration( $input, $expected ); … … 663 777 * Make sure valid shortcode names are allowed. 664 778 * 665 779 * @dataProvider data_registration_good 780 * 781 * @covers ::shortcode_exists 666 782 */ 667 783 function test_registration_good( $input, $expected ) { 668 784 return $this->sub_registration( $input, $expected ); … … 732 848 * Automated performance testing of the main regex. 733 849 * 734 850 * @dataProvider data_whole_posts 851 * 852 * @covers ::get_shortcode_regex 735 853 */ 736 854 function test_pcre_performance( $input ) { 737 855 $regex = '/' . get_shortcode_regex() . '/'; … … 744 862 return data_whole_posts(); 745 863 } 746 864 865 /** 866 * 867 * @covers ::get_shortcode_regex 868 */ 747 869 function test_php_and_js_shortcode_attribute_regexes_match() { 748 870 749 871 $file = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' ); … … 761 883 * @ticket 34939 762 884 * 763 885 * Test the (not recommended) [shortcode=XXX] format 886 * 887 * @covers ::do_shortcode 764 888 */ 765 889 function test_unnamed_attribute() { 766 890 $out = do_shortcode( '[dumptag=https://wordpress.org/]' ); … … 770 894 771 895 /** 772 896 * @ticket 36306 897 * 898 * @covers ::the_content 773 899 */ 774 900 function test_smilies_arent_converted() { 775 901 $out = apply_filters( 'the_content', '[img alt="Hello :-) World"]' ); … … 779 905 780 906 /** 781 907 * @ticket 37906 908 * 909 * @covers ::do_shortcode 782 910 */ 783 911 public function test_pre_do_shortcode_tag() { 784 912 // Does nothing if no filters are set up. … … 849 977 850 978 /** 851 979 * @ticket 32790 980 * 981 * @covers ::do_shortcode 852 982 */ 853 983 public function test_do_shortcode_tag_filter() { 854 984 // Does nothing if no filters are set up. … … 921 1051 * @ticket 37304 922 1052 * 923 1053 * Test 'value' syntax for empty attributes 1054 * 1055 * @covers ::do_shortcode 924 1056 */ 925 1057 function test_empty_single_quote_attribute() { 926 1058 $out = do_shortcode( '[test-shortcode-tag a="foo" b=\'bar\' c=baz foo \'bar\' "baz" ]test empty atts[/test-shortcode-tag]' ); … … 939 1071 940 1072 /** 941 1073 * @ticket 37304 1074 * 1075 * @covers ::do_shortcode 942 1076 */ 943 1077 function test_positional_atts_single_quotes() { 944 1078 $out = do_shortcode( "[test-shortcode-tag 'something in quotes' 'something else']" ); … … 955 1089 956 1090 /** 957 1091 * @ticket 37304 1092 * 1093 * @covers ::do_shortcode 958 1094 */ 959 1095 function test_positional_atts_mixed_quotes() { 960 1096 $out = do_shortcode( "[test-shortcode-tag 'something in quotes' \"something else\" 123 foo bar='baz' example=\"test\" ]" ); -
tests/phpunit/tests/site-health.php
13 13 * Ensure Site Health reports correctly cron job reports. 14 14 * 15 15 * @ticket 47223 16 * 17 * @covers WP_Site_Health::get_test_scheduled_events 16 18 */ 17 19 function test_cron_health_checks_critical() { 18 20 $wp_site_health = new WP_Site_Health(); … … 33 35 * 34 36 * @dataProvider data_cron_health_checks 35 37 * @ticket 47223 38 * 39 * @covers WP_Site_Health::get_test_scheduled_events 36 40 */ 37 41 function test_cron_health_checks( $times, $expected_status, $expected_label, $expected_late, $expected_missed ) { 38 42 $wp_site_health = new WP_Site_Health(); -
tests/phpunit/tests/taxonomy.php
4 4 * @group taxonomy 5 5 */ 6 6 class Tests_Taxonomy extends WP_UnitTestCase { 7 8 /** 9 * 10 * @covers ::get_object_taxonomies 11 */ 7 12 function test_get_post_taxonomies() { 8 13 $this->assertEquals( array( 'category', 'post_tag', 'post_format' ), get_object_taxonomies( 'post' ) ); 9 14 } 10 15 16 /** 17 * 18 * @covers ::get_object_taxonomies 19 */ 11 20 function test_get_link_taxonomies() { 12 21 $this->assertEquals( array( 'link_category' ), get_object_taxonomies( 'link' ) ); 13 22 } … … 14 23 15 24 /** 16 25 * @ticket 5417 26 * 27 * @covers ::get_object_taxonomies 17 28 */ 18 29 function test_get_unknown_taxonomies() { 19 30 // Taxonomies for an unknown object type. … … 23 34 $this->assertEquals( array(), get_object_taxonomies( null ) ); 24 35 } 25 36 37 /** 38 * 39 * @covers ::get_object_taxonomies 40 */ 26 41 function test_get_post_taxonomy() { 27 42 foreach ( get_object_taxonomies( 'post' ) as $taxonomy ) { 28 43 $tax = get_taxonomy( $taxonomy ); … … 33 48 } 34 49 } 35 50 51 /** 52 * 53 * @covers ::get_the_taxonomies 54 */ 36 55 function test_get_the_taxonomies() { 37 56 $post_id = self::factory()->post->create(); 38 57 … … 51 70 52 71 /** 53 72 * @ticket 27238 73 * 74 * @covers ::get_the_taxonomies 54 75 */ 55 76 public function test_get_the_taxonomies_term_template() { 56 77 $post_id = self::factory()->post->create(); … … 63 84 $this->assertEquals( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $taxes['category'] ); 64 85 } 65 86 87 /** 88 * 89 * @covers ::the_taxonomies 90 */ 66 91 function test_the_taxonomies() { 67 92 $post_id = self::factory()->post->create(); 68 93 … … 77 102 78 103 /** 79 104 * @ticket 27238 105 * 106 * @covers ::get_category_link 80 107 */ 81 108 function test_the_taxonomies_term_template() { 82 109 $post_id = self::factory()->post->create(); … … 105 132 $this->assertEquals( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $output ); 106 133 } 107 134 135 /** 136 * 137 * @covers ::create_initial_taxonomies 138 */ 108 139 function test_get_link_taxonomy() { 109 140 foreach ( get_object_taxonomies( 'link' ) as $taxonomy ) { 110 141 $tax = get_taxonomy( $taxonomy ); … … 115 146 } 116 147 } 117 148 149 /** 150 * 151 * @covers ::create_initial_taxonomies 152 * @covers ::taxonomy_exists 153 */ 118 154 function test_taxonomy_exists_known() { 119 155 $this->assertTrue( taxonomy_exists( 'category' ) ); 120 156 $this->assertTrue( taxonomy_exists( 'post_tag' ) ); … … 121 157 $this->assertTrue( taxonomy_exists( 'link_category' ) ); 122 158 } 123 159 160 /** 161 * 162 * @covers ::create_initial_taxonomies 163 * @covers ::taxonomy_exists 164 */ 124 165 function test_taxonomy_exists_unknown() { 125 166 $this->assertFalse( taxonomy_exists( rand_str() ) ); 126 167 $this->assertFalse( taxonomy_exists( '' ) ); … … 128 169 $this->assertFalse( taxonomy_exists( null ) ); 129 170 } 130 171 172 /** 173 * 174 * @covers ::create_initial_taxonomies 175 * @covers ::is_taxonomy_hierarchical 176 */ 131 177 function test_is_taxonomy_hierarchical() { 132 178 $this->assertTrue( is_taxonomy_hierarchical( 'category' ) ); 133 179 $this->assertFalse( is_taxonomy_hierarchical( 'post_tag' ) ); … … 134 180 $this->assertFalse( is_taxonomy_hierarchical( 'link_category' ) ); 135 181 } 136 182 183 /** 184 * 185 * @covers ::create_initial_taxonomies 186 * @covers ::is_taxonomy_hierarchical 187 */ 137 188 function test_is_taxonomy_hierarchical_unknown() { 138 189 $this->assertFalse( is_taxonomy_hierarchical( rand_str() ) ); 139 190 $this->assertFalse( is_taxonomy_hierarchical( '' ) ); … … 141 192 $this->assertFalse( is_taxonomy_hierarchical( null ) ); 142 193 } 143 194 195 /** 196 * 197 * @covers ::register_taxonomy 198 */ 144 199 function test_register_taxonomy() { 145 200 146 201 // Make up a new taxonomy name, and ensure it's unused. … … 155 210 unset( $GLOBALS['wp_taxonomies'][ $tax ] ); 156 211 } 157 212 213 /** 214 * 215 * @covers ::register_taxonomy 216 */ 158 217 function test_register_hierarchical_taxonomy() { 159 218 160 219 // Make up a new taxonomy name, and ensure it's unused. … … 171 230 172 231 /** 173 232 * @ticket 48558 233 * 234 * @covers ::register_taxonomy 174 235 */ 175 236 function test_register_taxonomy_return_value() { 176 237 $this->assertInstanceOf( 'WP_Taxonomy', register_taxonomy( 'foo', 'post' ) ); … … 180 241 * @ticket 21593 181 242 * 182 243 * @expectedIncorrectUsage register_taxonomy 244 * 245 * @covers ::register_taxonomy 183 246 */ 184 247 function test_register_taxonomy_with_too_long_name() { 185 248 $this->assertInstanceOf( 'WP_Error', register_taxonomy( 'abcdefghijklmnopqrstuvwxyz0123456789', 'post', array() ) ); … … 189 252 * @ticket 31135 190 253 * 191 254 * @expectedIncorrectUsage register_taxonomy 255 * 256 * @covers ::register_taxonomy 192 257 */ 193 258 function test_register_taxonomy_with_empty_name() { 194 259 $this->assertInstanceOf( 'WP_Error', register_taxonomy( '', 'post', array() ) ); … … 196 261 197 262 /** 198 263 * @ticket 26948 264 * 265 * @covers ::register_taxonomy 199 266 */ 200 267 public function test_register_taxonomy_show_in_quick_edit_should_default_to_value_of_show_ui() { 201 268 register_taxonomy( … … 223 290 224 291 /** 225 292 * @ticket 11058 293 * 294 * @covers ::register_taxonomy 226 295 */ 227 296 function test_registering_taxonomies_to_object_types() { 228 297 // Create a taxonomy to test with. … … 272 341 273 342 /** 274 343 * @ticket 32590 344 * 345 * @covers ::register_taxonomy 275 346 */ 276 347 public function test_register_taxonomy_for_post_type_for_taxonomy_with_no_object_type_should_filter_out_empty_object_types() { 277 348 register_taxonomy( 'wptests_tax', '' ); … … 282 353 $this->assertEqualSets( $expected, $tax->object_type ); 283 354 } 284 355 356 /** 357 * 358 * @covers ::get_objects_in_term 359 */ 285 360 public function test_get_objects_in_term_should_return_invalid_taxonomy_error() { 286 361 $terms = get_objects_in_term( 1, 'invalid_taxonomy' ); 287 362 $this->assertInstanceOf( 'WP_Error', $terms ); … … 288 363 $this->assertEquals( 'invalid_taxonomy', $terms->get_error_code() ); 289 364 } 290 365 366 /** 367 * 368 * @covers ::get_objects_in_term 369 */ 291 370 public function test_get_objects_in_term_should_return_empty_array() { 292 371 $this->assertEquals( array(), get_objects_in_term( 1, 'post_tag' ) ); 293 372 } 294 373 374 /** 375 * 376 * @covers ::get_objects_in_term 377 */ 295 378 public function test_get_objects_in_term_should_return_objects_ids() { 296 379 $tag_id = self::factory()->tag->create(); 297 380 $cat_id = self::factory()->category->create(); … … 324 407 325 408 /** 326 409 * @ticket 37094 410 * 411 * @covers ::wp_set_object_terms 327 412 */ 328 413 public function test_term_assignment_should_invalidate_get_objects_in_term_cache() { 329 414 register_taxonomy( 'wptests_tax', 'post' ); … … 349 434 350 435 /** 351 436 * @ticket 37094 437 * 438 * @covers ::wp_delete_term 352 439 */ 353 440 public function test_term_deletion_should_invalidate_get_objects_in_term_cache() { 354 441 register_taxonomy( 'wptests_tax', 'post' ); … … 374 461 375 462 /** 376 463 * @ticket 37094 464 * 465 * @covers ::wp_delete_term 377 466 */ 378 467 public function test_post_deletion_should_invalidate_get_objects_in_term_cache() { 379 468 register_taxonomy( 'wptests_tax', 'post' ); … … 399 488 400 489 /** 401 490 * @ticket 25706 491 * 492 * @covers ::in_category 402 493 */ 403 494 function test_in_category() { 404 495 $post = self::factory()->post->create_and_get(); … … 414 505 $this->assertTrue( in_category( $term['term_id'], $post ) ); 415 506 } 416 507 508 /** 509 * 510 * @covers ::wp_insert_category 511 */ 417 512 function test_insert_category_create() { 418 513 $cat = array( 419 514 'cat_ID' => 0, … … 423 518 $this->assertTrue( is_numeric( wp_insert_category( $cat, true ) ) ); 424 519 } 425 520 521 /** 522 * 523 * @covers ::wp_insert_category 524 */ 426 525 function test_insert_category_update() { 427 526 $cat = array( 428 527 'cat_ID' => 1, … … 432 531 $this->assertEquals( 1, wp_insert_category( $cat ) ); 433 532 } 434 533 534 /** 535 * 536 * @covers ::wp_insert_category 537 */ 435 538 function test_insert_category_force_error_handle() { 436 539 $cat = array( 437 540 'cat_ID' => 0, … … 441 544 $this->assertTrue( is_a( wp_insert_category( $cat, true ), 'WP_Error' ) ); 442 545 } 443 546 547 /** 548 * 549 * @covers ::wp_insert_category 550 */ 444 551 function test_insert_category_force_error_no_handle() { 445 552 $cat = array( 446 553 'cat_ID' => 0, … … 450 557 $this->assertEquals( 0, wp_insert_category( $cat, false ) ); 451 558 } 452 559 560 /** 561 * 562 * @covers ::get_ancestors 563 */ 453 564 public function test_get_ancestors_taxonomy_non_hierarchical() { 454 565 register_taxonomy( 'wptests_tax', 'post' ); 455 566 $t = self::factory()->term->create( … … 462 573 _unregister_taxonomy( 'wptests_tax' ); 463 574 } 464 575 576 /** 577 * 578 * @covers ::get_ancestors 579 */ 465 580 public function test_get_ancestors_taxonomy() { 466 581 register_taxonomy( 467 582 'wptests_tax', … … 509 624 $this->assertEqualSets( array(), get_ancestors( $p, 'wptests_tax' ) ); 510 625 } 511 626 627 /** 628 * 629 * @covers ::get_ancestors 630 */ 512 631 public function test_get_ancestors_post_type() { 513 632 register_post_type( 514 633 'wptests_pt', … … 546 665 547 666 /** 548 667 * @ticket 15029 668 * 669 * @covers ::get_ancestors 549 670 */ 550 671 public function test_get_ancestors_taxonomy_post_type_conflict_resource_type_taxonomy() { 551 672 register_post_type( … … 593 714 594 715 /** 595 716 * @ticket 21949 717 * 718 * @covers ::is_tax 596 719 */ 597 720 public function test_nonpublicly_queryable_taxonomy_should_not_be_queryable_using_taxname_query_var() { 598 721 register_taxonomy( … … 619 742 620 743 /** 621 744 * @ticket 21949 745 * 746 * @covers ::register_taxonomy 622 747 */ 623 748 public function test_it_should_be_possible_to_register_a_query_var_that_matches_the_name_of_a_nonpublicly_queryable_taxonomy() { 624 749 global $wp; … … 660 785 661 786 /** 662 787 * @ticket 21949 788 * 789 * @covers ::register_taxonomy 663 790 */ 664 791 public function test_nonpublicly_queryable_taxonomy_should_not_be_queryable_using_taxonomy_and_term_vars() { 665 792 register_taxonomy( … … 686 813 687 814 /** 688 815 * @ticket 34491 816 * 817 * @covers ::register_taxonomy 689 818 */ 690 819 public function test_public_taxonomy_should_be_publicly_queryable() { 691 820 register_taxonomy( … … 714 843 715 844 /** 716 845 * @ticket 34491 846 * 847 * @covers ::register_taxonomy 717 848 */ 718 849 public function test_private_taxonomy_should_not_be_publicly_queryable() { 719 850 register_taxonomy( … … 742 873 743 874 /** 744 875 * @ticket 34491 876 * 877 * @covers ::register_taxonomy 745 878 */ 746 879 public function test_private_taxonomy_should_be_overridden_by_publicly_queryable() { 747 880 register_taxonomy( … … 771 904 772 905 /** 773 906 * @ticket 35089 907 * 908 * @covers ::register_taxonomy 774 909 */ 775 910 public function test_query_var_should_be_forced_to_false_for_non_public_taxonomy() { 776 911 register_taxonomy( … … 788 923 789 924 /** 790 925 * @ticket 35227 926 * 927 * @covers ::unregister_taxonomy 791 928 */ 792 929 public function test_unregister_taxonomy_unknown_taxonomy() { 793 930 $this->assertWPError( unregister_taxonomy( 'foo' ) ); … … 795 932 796 933 /** 797 934 * @ticket 35227 935 * 936 * @covers ::unregister_taxonomy 798 937 */ 799 938 public function test_unregister_taxonomy_twice() { 800 939 register_taxonomy( 'foo', 'post' ); … … 804 943 805 944 /** 806 945 * @ticket 35227 946 * 947 * @covers ::unregister_taxonomy 807 948 */ 808 949 public function test_unregister_taxonomy_disallow_builtin_taxonomy() { 809 950 $this->assertWPError( unregister_taxonomy( 'post_tag' ) ); … … 812 953 813 954 /** 814 955 * @ticket 35227 956 * 957 * @covers ::unregister_taxonomy 815 958 */ 816 959 public function test_unregister_taxonomy_removes_query_vars() { 817 960 global $wp; … … 825 968 826 969 /** 827 970 * @ticket 35227 971 * 972 * @covers ::unregister_taxonomy 828 973 */ 829 974 public function test_unregister_taxonomy_removes_permastruct() { 830 975 $this->set_permalink_structure( '/%postname%' ); … … 847 992 848 993 /** 849 994 * @ticket 35227 995 * 996 * @covers ::unregister_taxonomy 850 997 */ 851 998 public function test_unregister_taxonomy_removes_rewrite_rules() { 852 999 $this->set_permalink_structure( '/%postname%' ); … … 867 1014 868 1015 /** 869 1016 * @ticket 35227 1017 * 1018 * @covers ::unregister_taxonomy 870 1019 */ 871 1020 public function test_unregister_taxonomy_removes_taxonomy_from_global() { 872 1021 global $wp_taxonomies; … … 884 1033 885 1034 /** 886 1035 * @ticket 35227 1036 * 1037 * @covers ::unregister_taxonomy 887 1038 */ 888 1039 public function test_unregister_taxonomy_removes_meta_box_callback() { 889 1040 global $wp_filter; … … 898 1049 899 1050 /** 900 1051 * @ticket 35227 1052 * 1053 * @covers ::unregister_taxonomy 901 1054 */ 902 1055 public function test_taxonomy_does_not_exist_after_unregister_taxonomy() { 903 1056 register_taxonomy( 'foo', 'post' ); … … 908 1061 909 1062 /** 910 1063 * @ticket 39308 1064 * 1065 * @covers ::unregister_taxonomy 911 1066 */ 912 1067 public function test_taxonomy_name_property_should_not_get_overridden_by_passed_args() { 913 1068 register_taxonomy( 'foo', 'post', array( 'name' => 'bar' ) ); … … 920 1075 921 1076 /** 922 1077 * @ticket 36514 1078 * 1079 * @covers ::edit_post 923 1080 */ 924 1081 public function test_edit_post_hierarchical_taxonomy() { 925 1082 … … 970 1127 * Test default term for custom taxonomy. 971 1128 * 972 1129 * @ticket 43517 1130 * 1131 * @covers ::register_taxonomy 973 1132 */ 974 1133 function test_default_term_for_custom_taxonomy() { 975 1134 -
tests/phpunit/tests/template.php
89 89 parent::tearDown(); 90 90 } 91 91 92 92 /** 93 * 94 * @covers ::get_404_template 95 */ 93 96 public function test_404_template_hierarchy() { 94 97 $url = add_query_arg( 95 98 array( … … 106 109 ); 107 110 } 108 111 112 /** 113 * 114 * @covers ::get_author_template 115 */ 109 116 public function test_author_template_hierarchy() { 110 117 $author = self::factory()->user->create_and_get( 111 118 array( … … 124 131 ); 125 132 } 126 133 134 /** 135 * 136 * @covers ::get_category_template 137 */ 127 138 public function test_category_template_hierarchy() { 128 139 $term = self::factory()->term->create_and_get( 129 140 array( … … 144 155 ); 145 156 } 146 157 158 /** 159 * 160 * @covers ::get_tag_template 161 */ 147 162 public function test_tag_template_hierarchy() { 148 163 $term = self::factory()->term->create_and_get( 149 164 array( … … 164 179 ); 165 180 } 166 181 182 /** 183 * 184 * @covers ::get_taxonomy_template 185 */ 167 186 public function test_taxonomy_template_hierarchy() { 168 187 $term = self::factory()->term->create_and_get( 169 188 array( … … 184 203 ); 185 204 } 186 205 206 /** 207 * 208 * @covers ::get_date_template 209 */ 187 210 public function test_date_template_hierarchy_for_year() { 188 211 $this->assertTemplateHierarchy( 189 212 get_year_link( 1984 ), … … 194 217 ); 195 218 } 196 219 220 /** 221 * 222 * @covers ::get_date_template 223 */ 197 224 public function test_date_template_hierarchy_for_month() { 198 225 $this->assertTemplateHierarchy( 199 226 get_month_link( 1984, 2 ), … … 204 231 ); 205 232 } 206 233 234 /** 235 * 236 * @covers ::get_date_template 237 */ 207 238 public function test_date_template_hierarchy_for_day() { 208 239 $this->assertTemplateHierarchy( 209 240 get_day_link( 1984, 2, 25 ), … … 214 245 ); 215 246 } 216 247 248 /** 249 * 250 * @covers ::get_search_template 251 */ 217 252 public function test_search_template_hierarchy() { 218 253 $url = add_query_arg( 219 254 array( … … 230 265 ); 231 266 } 232 267 268 /** 269 * 270 * @covers ::get_front_page_template 271 */ 233 272 public function test_front_page_template_hierarchy_with_posts_on_front() { 234 273 $this->assertEquals( 'posts', get_option( 'show_on_front' ) ); 235 274 $this->assertTemplateHierarchy( … … 242 281 ); 243 282 } 244 283 284 /** 285 * 286 * @covers ::get_front_page_template 287 */ 245 288 public function test_front_page_template_hierarchy_with_page_on_front() { 246 289 update_option( 'show_on_front', 'page' ); 247 290 update_option( 'page_on_front', self::$page_on_front->ID ); … … 260 303 ); 261 304 } 262 305 306 /** 307 * 308 * @covers ::get_home_template 309 */ 263 310 public function test_home_template_hierarchy_with_page_on_front() { 264 311 update_option( 'show_on_front', 'page' ); 265 312 update_option( 'page_on_front', self::$page_on_front->ID ); … … 274 321 ); 275 322 } 276 323 324 /** 325 * 326 * @covers ::get_page_template 327 */ 277 328 public function test_page_template_hierarchy() { 278 329 $this->assertTemplateHierarchy( 279 330 get_permalink( self::$page ), … … 291 342 /** 292 343 * @ticket 44005 293 344 * @group privacy 345 * 346 * @covers ::get_privacy_policy_template 294 347 */ 295 348 public function test_privacy_template_hierarchy() { 296 349 update_option( 'wp_page_for_privacy_policy', self::$page_for_privacy_policy->ID ); … … 309 362 310 363 /** 311 364 * @ticket 18375 365 * 366 * @covers ::get_single_template 312 367 */ 313 368 public function test_single_template_hierarchy_for_post() { 314 369 $this->assertTemplateHierarchy( … … 324 379 ); 325 380 } 326 381 382 /** 383 * 384 * @covers ::get_single_template 385 */ 327 386 public function test_single_template_hierarchy_for_custom_post_type() { 328 387 $cpt = self::factory()->post->create_and_get( 329 388 array( … … 346 405 347 406 /** 348 407 * @ticket 18375 408 * 409 * @covers ::get_single_template 349 410 */ 350 411 public function test_single_template_hierarchy_for_custom_post_type_with_template() { 351 412 $cpt = self::factory()->post->create_and_get( … … 369 430 ); 370 431 } 371 432 433 /** 434 * 435 * @covers ::get_attachment_template 436 */ 372 437 public function test_attachment_template_hierarchy() { 373 438 $attachment = self::factory()->attachment->create_and_get( 374 439 array( … … 395 460 396 461 /** 397 462 * @ticket 18375 463 * 464 * @covers ::get_attachment_template 398 465 */ 399 466 public function test_attachment_template_hierarchy_with_template() { 400 467 $attachment = self::factory()->attachment->create_and_get( … … 423 490 ); 424 491 } 425 492 493 /** 494 * 495 * @covers ::get_embed_template 496 */ 426 497 public function test_embed_template_hierarchy_for_post() { 427 498 $this->assertTemplateHierarchy( 428 499 get_post_embed_url( self::$post ), … … 440 511 ); 441 512 } 442 513 514 /** 515 * 516 * @covers ::get_embed_template 517 */ 443 518 public function test_embed_template_hierarchy_for_page() { 444 519 $this->assertTemplateHierarchy( 445 520 get_post_embed_url( self::$page ), -
tests/phpunit/tests/term.php
13 13 14 14 /** 15 15 * @ticket 29911 16 * 17 * @covers ::wp_delete_term 16 18 */ 17 19 public function test_wp_delete_term_should_invalidate_cache_for_child_terms() { 18 20 register_taxonomy( … … 48 50 49 51 /** 50 52 * @ticket 5381 53 * 54 * @covers ::wp_insert_term 51 55 */ 52 56 function test_is_term_type() { 53 57 // Insert a term. … … 63 67 64 68 /** 65 69 * @ticket 15919 70 * 71 * @covers ::wp_count_terms 66 72 */ 67 73 function test_wp_count_terms() { 68 74 $count = wp_count_terms( 'category', array( 'hide_empty' => true ) ); … … 72 78 73 79 /** 74 80 * @ticket 15475 81 * 82 * @covers ::wp_add_object_terms 83 * @covers ::wp_remove_object_terms 75 84 */ 76 85 function test_wp_add_remove_object_terms() { 77 86 $posts = self::$post_ids; … … 103 112 104 113 /** 105 114 * @group category.php 115 * 116 * @covers ::wp_insert_term 106 117 */ 107 118 function test_term_is_ancestor_of() { 108 119 $term = rand_str(); … … 123 134 wp_delete_term( $t2['term_id'], 'category' ); 124 135 } 125 136 137 /** 138 * 139 * @covers ::wp_insert_category 140 * @covers ::wp_delete_category 141 */ 126 142 function test_wp_insert_delete_category() { 127 143 $term = rand_str(); 128 144 $this->assertNull( category_exists( $term ) ); … … 148 164 149 165 /** 150 166 * @ticket 16550 167 * 168 * @covers ::wp_set_post_categories 151 169 */ 152 170 function test_wp_set_post_categories() { 153 171 $post_id = self::$post_ids[0]; … … 187 205 188 206 /** 189 207 * @ticket 43516 208 * 209 * @covers ::wp_set_post_categories 190 210 */ 191 211 function test_wp_set_post_categories_sets_default_category_for_custom_post_types() { 192 212 add_filter( 'default_category_post_types', array( $this, 'filter_default_category_post_types' ) ); … … 216 236 217 237 /** 218 238 * @ticket 25852 239 * 240 * @covers ::sanitize_term_field 219 241 */ 220 242 function test_sanitize_term_field() { 221 243 $term = wp_insert_term( 'foo', $this->taxonomy ); … … 228 250 229 251 /** 230 252 * @ticket 19205 253 * 254 * @covers ::wp_insert_term 231 255 */ 232 256 function test_orphan_category() { 233 257 $cat_id1 = self::factory()->category->create(); -
tests/phpunit/tests/theme.php
46 46 parent::tearDown(); 47 47 } 48 48 49 /** 50 * 51 * @covers ::wp_get_themes 52 */ 49 53 function test_wp_get_themes_default() { 50 54 $themes = wp_get_themes(); 51 55 $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_slug ] ); … … 59 63 /** 60 64 * @expectedDeprecated get_theme 61 65 * @expectedDeprecated get_themes 66 * 67 * @covers ::get_themes 62 68 */ 63 69 function test_get_themes_default() { 64 70 $themes = get_themes(); … … 73 79 /** 74 80 * @expectedDeprecated get_theme 75 81 * @expectedDeprecated get_themes 82 * 83 * @covers ::get_themes 76 84 */ 77 85 function test_get_theme() { 78 86 $themes = get_themes(); … … 85 93 } 86 94 } 87 95 96 /** 97 * 98 * @covers ::wp_get_themes 99 */ 88 100 function test_wp_get_theme() { 89 101 $themes = wp_get_themes(); 90 102 foreach ( $themes as $theme ) { … … 99 111 100 112 /** 101 113 * @expectedDeprecated get_themes 114 * 115 * @covers ::get_themes 102 116 */ 103 117 function test_get_themes_contents() { 104 118 $themes = get_themes(); … … 169 183 } 170 184 } 171 185 186 /** 187 * 188 * @covers ::wp_get_themes 189 */ 172 190 function test_wp_get_theme_contents() { 173 191 $theme = wp_get_theme( $this->theme_slug ); 174 192 … … 193 211 * Make sure we update the default theme list to include the latest default theme. 194 212 * 195 213 * @ticket 29925 214 * 215 * @covers WP_Theme::get_core_default_theme 196 216 */ 197 217 function test_default_theme_in_default_theme_list() { 198 218 $latest_default_theme = WP_Theme::get_core_default_theme(); … … 202 222 $this->assertContains( $latest_default_theme->get_stylesheet(), $this->default_themes ); 203 223 } 204 224 225 /** 226 * 227 * @covers WP_Theme::wp_get_theme 228 */ 205 229 function test_default_themes_have_textdomain() { 206 230 foreach ( $this->default_themes as $theme ) { 207 231 if ( wp_get_theme( $theme )->exists() ) { … … 212 236 213 237 /** 214 238 * @ticket 48566 239 * 240 * @covers WP_Theme::wp_get_theme 215 241 */ 216 242 function test_year_in_readme() { 217 243 // This test is designed to only run on trunk/master. … … 240 266 /** 241 267 * @ticket 20897 242 268 * @expectedDeprecated get_theme_data 269 * 270 * @covers ::wp_get_theme 271 * @covers ::get_theme_data 243 272 */ 244 273 function test_extra_theme_headers() { 245 274 $wp_theme = wp_get_theme( $this->theme_slug ); … … 260 289 /** 261 290 * @expectedDeprecated get_themes 262 291 * @expectedDeprecated get_current_theme 292 * 293 * @covers ::get_themes 294 * @covers ::get_current_theme 263 295 */ 264 296 function test_switch_theme() { 265 297 $themes = get_themes(); … … 332 364 } 333 365 } 334 366 367 /** 368 * 369 * @covers WP_Theme::errors 370 * @covers WP_Theme::exists 371 * @covers ::get_template 372 * @covers ::get_stylesheet 373 */ 335 374 function test_switch_theme_bogus() { 336 375 // Try switching to a theme that doesn't exist. 337 376 $template = rand_str(); … … 352 391 /** 353 392 * Test _wp_keep_alive_customize_changeset_dependent_auto_drafts. 354 393 * 355 * @covers ::_wp_keep_alive_customize_changeset_dependent_auto_drafts ()394 * @covers ::_wp_keep_alive_customize_changeset_dependent_auto_drafts 356 395 */ 357 396 function test_wp_keep_alive_customize_changeset_dependent_auto_drafts() { 358 397 $nav_created_post_ids = $this->factory()->post->create_many( … … 418 457 419 458 /** 420 459 * @ticket 49406 460 * 461 * @covers ::register_theme_feature 421 462 */ 422 463 public function test_register_theme_support_defaults() { 423 464 $registered = register_theme_feature( 'test-feature' ); … … 434 475 435 476 /** 436 477 * @ticket 49406 478 * 479 * @covers ::register_theme_feature 437 480 */ 438 481 public function test_register_theme_support_explicit() { 439 482 $args = array( … … 460 503 461 504 /** 462 505 * @ticket 49406 506 * 507 * @covers ::register_theme_feature 463 508 */ 464 509 public function test_register_theme_support_upgrades_show_in_rest() { 465 510 register_theme_feature( 'test-feature', array( 'show_in_rest' => true ) ); … … 480 525 481 526 /** 482 527 * @ticket 49406 528 * 529 * @covers ::register_theme_feature 483 530 */ 484 531 public function test_register_theme_support_fills_schema() { 485 532 register_theme_feature( … … 514 561 515 562 /** 516 563 * @ticket 49406 564 * 565 * @covers ::register_theme_feature 517 566 */ 518 567 public function test_register_theme_support_does_not_add_boolean_type_if_non_bool_default() { 519 568 register_theme_feature( … … 537 586 538 587 /** 539 588 * @ticket 49406 589 * 590 * @covers ::register_theme_feature 540 591 */ 541 592 public function test_register_theme_support_defaults_additional_properties_to_false() { 542 593 register_theme_feature( … … 564 615 565 616 /** 566 617 * @ticket 49406 618 * 619 * @covers ::register_theme_feature 567 620 */ 568 621 public function test_register_theme_support_with_additional_properties() { 569 622 register_theme_feature( … … 592 645 593 646 /** 594 647 * @ticket 49406 648 * 649 * @covers ::register_theme_feature 595 650 */ 596 651 public function test_register_theme_support_defaults_additional_properties_to_false_in_array() { 597 652 register_theme_feature( … … 627 682 * 628 683 * @param string $error_code The error code expected. 629 684 * @param array $args The args to register. 685 * 686 * @covers ::register_theme_feature 630 687 */ 631 688 public function test_register_theme_support_validation( $error_code, $args ) { 632 689 $registered = register_theme_feature( 'test-feature', $args ); -
tests/phpunit/tests/upload.php
19 19 update_option( 'uploads_use_yearmonth_folders', 1 ); 20 20 } 21 21 22 /** 23 * 24 * @covers ::wp_upload_dir 25 */ 22 26 function test_upload_dir_default() { 23 27 // wp_upload_dir() with default parameters. 24 28 $info = wp_upload_dir(); … … 30 34 $this->assertEquals( false, $info['error'] ); 31 35 } 32 36 37 /** 38 * 39 * @covers ::wp_upload_dir 40 */ 33 41 function test_upload_dir_relative() { 34 42 // wp_upload_dir() with a relative upload path that is not 'wp-content/uploads'. 35 43 update_option( 'upload_path', 'foo/bar' ); … … 44 52 45 53 /** 46 54 * @ticket 5953 55 * 56 * @covers ::wp_upload_dir 47 57 */ 48 58 function test_upload_dir_absolute() { 49 59 $path = get_temp_dir() . 'wp-unit-test'; … … 65 75 $this->assertEquals( false, $info['error'] ); 66 76 } 67 77 78 /** 79 * 80 * @covers ::wp_upload_dir 81 */ 68 82 function test_upload_dir_no_yearnum() { 69 83 update_option( 'uploads_use_yearmonth_folders', 0 ); 70 84 … … 77 91 $this->assertEquals( false, $info['error'] ); 78 92 } 79 93 94 /** 95 * 96 * @covers ::wp_upload_dir 97 */ 80 98 function test_upload_path_absolute() { 81 99 update_option( 'upload_url_path', 'http://' . WP_TESTS_DOMAIN . '/asdf' ); 82 100 … … 91 109 $this->assertEquals( false, $info['error'] ); 92 110 } 93 111 112 /** 113 * 114 * @covers ::wp_upload_dir 115 */ 94 116 function test_upload_dir_empty() { 95 117 // Upload path setting is empty - it should default to 'wp-content/uploads'. 96 118 update_option( 'upload_path', '' ); -
tests/phpunit/tests/url.php
47 47 ); 48 48 } 49 49 50 /** 51 * 52 * @covers ::is_ssl 53 */ 50 54 function test_is_ssl_by_port() { 51 55 unset( $_SERVER['HTTPS'] ); 52 56 $_SERVER['SERVER_PORT'] = '443'; … … 55 59 $this->assertTrue( $is_ssl ); 56 60 } 57 61 62 /** 63 * 64 * @covers ::is_ssl 65 */ 58 66 function test_is_ssl_with_no_value() { 59 67 unset( $_SERVER['HTTPS'] ); 60 68 … … 67 75 * 68 76 * @param string $url Test URL. 69 77 * @param string $expected Expected result. 78 * 79 * @covers ::admin_url 70 80 */ 71 81 function test_admin_url( $url, $expected ) { 72 82 $siteurl_http = get_option( 'siteurl' ); … … 135 145 * 136 146 * @param string $url Test URL. 137 147 * @param string $expected Expected result. 148 * 149 * @covers ::home_url 138 150 */ 139 151 function test_home_url( $url, $expected ) { 140 152 $homeurl_http = get_option( 'home' ); … … 198 210 ); 199 211 } 200 212 213 /** 214 * 215 * @covers ::home_url 216 */ 201 217 function test_home_url_from_admin() { 202 218 $screen = get_current_screen(); 203 219 … … 246 262 $GLOBALS['current_screen'] = $screen; 247 263 } 248 264 265 /** 266 * 267 * @covers ::network_home_url 268 */ 249 269 function test_network_home_url_from_admin() { 250 270 $screen = get_current_screen(); 251 271 … … 271 291 $GLOBALS['current_screen'] = $screen; 272 292 } 273 293 294 /** 295 * 296 * @covers ::set_url_scheme 297 */ 274 298 function test_set_url_scheme() { 275 299 if ( ! function_exists( 'set_url_scheme' ) ) { 276 300 return; … … 335 359 force_ssl_admin( $forced_admin ); 336 360 } 337 361 362 /** 363 * 364 * @covers ::get_adjacent_post 365 */ 338 366 public function test_get_adjacent_post() { 339 367 $now = time(); 340 368 $post_id = self::factory()->post->create( array( 'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ) ) ); … … 369 397 * Test get_adjacent_post returns the next private post when the author is the currently logged in user. 370 398 * 371 399 * @ticket 30287 400 * 401 * @covers ::get_adjacent_post 372 402 */ 373 403 public function test_get_adjacent_post_should_return_private_posts_belonging_to_the_current_user() { 374 404 $u = self::factory()->user->create( array( 'role' => 'author' ) ); … … 406 436 407 437 /** 408 438 * @ticket 30287 439 * 440 * @covers ::get_adjacent_post 409 441 */ 410 442 public function test_get_adjacent_post_should_return_private_posts_belonging_to_other_users_if_the_current_user_can_read_private_posts() { 411 443 $u1 = self::factory()->user->create( array( 'role' => 'author' ) ); … … 444 476 445 477 /** 446 478 * @ticket 30287 479 * 480 * @covers ::get_adjacent_post 447 481 */ 448 482 public function test_get_adjacent_post_should_not_return_private_posts_belonging_to_other_users_if_the_current_user_cannot_read_private_posts() { 449 483 $u1 = self::factory()->user->create( array( 'role' => 'author' ) ); … … 490 524 * Test that *_url functions handle paths with ".." 491 525 * 492 526 * @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 493 538 */ 494 539 public function test_url_functions_for_dots_in_paths() { 495 540 $functions = array( -
tests/phpunit/tests/user.php
66 66 $this->author = clone self::$_author; 67 67 } 68 68 69 /** 70 * 71 * @covers ::get_users 72 */ 69 73 function test_get_users_of_blog() { 70 74 // Add one of each user role. 71 75 $nusers = array( … … 91 95 $this->assertEqualSets( $nusers, $found ); 92 96 } 93 97 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 */ 95 103 function test_user_option() { 96 104 $key = rand_str(); 97 105 $val = rand_str(); … … 111 119 112 120 /** 113 121 * Simple tests for usermeta functions. 122 * 123 * @covers ::get_user_meta 114 124 */ 115 125 function test_usermeta() { 116 126 $key = 'key'; … … 145 155 146 156 /** 147 157 * Test usermeta functions in array mode. 158 * 159 * @covers ::get_user_meta 148 160 */ 149 161 function test_usermeta_array() { 150 162 // Some values to set. … … 185 197 186 198 /** 187 199 * Test property magic functions for property get/set/isset. 200 * 201 * @covers WP_User::data 202 * @covers WP_User::$key 188 203 */ 189 204 function test_user_properties() { 190 205 $user = new WP_User( self::$author_id ); … … 209 224 * Test the magic __unset() method. 210 225 * 211 226 * @ticket 20043 227 * 228 * @covers WP_User::__unset 212 229 */ 213 230 public function test_user_unset() { 214 231 // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase … … 229 246 * @depends test_user_unset 230 247 * @expectedDeprecated WP_User->id 231 248 * @ticket 20043 249 * 250 * @covers WP_User::__unset 232 251 */ 233 252 function test_user_unset_lowercase_id( $user ) { 234 253 $id = $user->id; … … 242 261 * 243 262 * @depends test_user_unset_lowercase_id 244 263 * @ticket 20043 264 * 265 * @covers WP_User::__unset 245 266 */ 246 267 function test_user_unset_uppercase_id( $user ) { 247 268 $this->assertNotEmpty( $user->ID ); … … 251 272 252 273 /** 253 274 * 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 254 280 */ 255 281 function test_user_meta_properties() { 256 282 $user = new WP_User( self::$author_id ); … … 264 290 265 291 /** 266 292 * @expectedDeprecated WP_User->id 293 * 294 * @coversNothing 267 295 */ 268 296 function test_id_property_back_compat() { 269 297 $user = new WP_User( self::$author_id ); … … 276 304 277 305 /** 278 306 * ticket 19265 307 * 308 * @coversNothing 279 309 */ 280 310 function test_user_level_property_back_compat() { 281 311 $roles = array( … … 294 324 } 295 325 } 296 326 327 /** 328 * 329 * @covers WP_User::__construct 330 */ 297 331 function test_construction() { 298 332 $user = new WP_User( self::$author_id ); 299 333 $this->assertInstanceOf( 'WP_User', $user ); … … 333 367 $this->assertEquals( $user->user_login, $user7->user_login ); 334 368 } 335 369 370 /** 371 * 372 * @covers WP_User::get 373 */ 336 374 function test_get() { 337 375 $user = new WP_User( self::$author_id ); 338 376 $this->assertEquals( 'author_login', $user->get( 'user_login' ) ); … … 344 382 $this->assertEquals( 'abcdefg', $user->get( 'dashed-key' ) ); 345 383 } 346 384 385 /** 386 * 387 * @covers WP_User::has_prop 388 */ 347 389 function test_has_prop() { 348 390 $user = new WP_User( self::$author_id ); 349 391 $this->assertTrue( $user->has_prop( 'user_email' ) ); … … 354 396 $this->assertTrue( $user->has_prop( 'dashed-key' ) ); 355 397 } 356 398 399 /** 400 * 401 * @covers ::wp_update_user 402 */ 357 403 function test_update_user() { 358 404 $user = new WP_User( self::$author_id ); 359 405 … … 411 457 412 458 /** 413 459 * ticket 19595 460 * 461 * @covers WP_User::__construct 414 462 */ 415 463 function test_global_userdata() { 416 464 global $userdata, $wpdb; … … 427 475 428 476 /** 429 477 * ticket 19769 478 * 479 * @covers WP_User::__construct 430 480 */ 431 481 function test_global_userdata_is_null_when_logged_out() { 432 482 global $userdata; … … 448 498 $this->assertFalse( $user->exists() ); 449 499 } 450 500 501 /** 502 * 503 * @covers WP_User::__construct 504 */ 451 505 function test_global_authordata() { 452 506 global $authordata, $id; 453 507 … … 480 534 481 535 /** 482 536 * @ticket 13317 537 * 538 * @covers ::get_userdata 483 539 */ 484 540 function test_get_userdata() { 485 541 $this->assertFalse( get_userdata( 0 ) ); … … 490 546 491 547 /** 492 548 * @ticket 23480 549 * 550 * @covers WP_User::get_data_by 493 551 */ 494 552 function test_user_get_data_by_id() { 495 553 $user = WP_User::get_data_by( 'id', self::$author_id ); … … 521 579 522 580 /** 523 581 * @ticket 33869 582 * 583 * @covers WP_User::get_data_by 524 584 */ 525 585 public function test_user_get_data_by_ID_should_alias_to_id() { 526 586 $user = WP_User::get_data_by( 'ID', self::$author_id ); … … 529 589 530 590 /** 531 591 * @ticket 21431 592 * 593 * @covers ::count_many_users_posts 532 594 */ 533 595 function test_count_many_users_posts() { 534 596 $user_id_b = self::factory()->user->create( array( 'role' => 'author' ) ); … … 562 624 563 625 /** 564 626 * @ticket 22858 627 * 628 * @covers ::wp_update_user 565 629 */ 566 630 function test_wp_update_user_on_nonexistent_users() { 567 631 $user_id = 1; … … 576 640 577 641 /** 578 642 * @ticket 28435 643 * 644 * @covers ::wp_update_user 579 645 */ 580 646 function test_wp_update_user_should_not_change_password_when_passed_WP_User_instance() { 581 647 $testuserid = 1; … … 591 657 /** 592 658 * @ticket 45747 593 659 * @group ms-excluded 660 * 661 * @covers ::wp_update_user 594 662 */ 595 663 function test_wp_update_user_should_not_mark_user_as_spam_on_single_site() { 596 664 $u = wp_update_user( … … 615 683 616 684 /** 617 685 * @ticket 28315 686 * 687 * @covers ::update_user_meta 618 688 */ 619 689 function test_user_meta_error() { 620 690 $id1 = wp_insert_user( … … 646 716 647 717 /** 648 718 * @ticket 30647 719 * 720 * @covers ::update_user_meta 649 721 */ 650 722 function test_user_update_email_error() { 651 723 $id1 = wp_insert_user( … … 691 763 /** 692 764 * @ticket 27317 693 765 * @dataProvider _illegal_user_logins_data 766 * 767 * @covers ::wp_insert_user 694 768 */ 695 769 function test_illegal_user_logins_single( $user_login ) { 696 770 $user_data = array( … … 715 789 /** 716 790 * @ticket 27317 717 791 * @dataProvider _illegal_user_logins_data 792 * 793 * @covers ::register_new_user 718 794 */ 719 795 function test_illegal_user_logins_single_wp_create_user( $user_login ) { 720 796 $user_email = 'testuser-' . $user_login . '@example.com'; … … 735 811 /** 736 812 * @ticket 27317 737 813 * @group ms-required 814 * 815 * @covers ::wpmu_validate_user_signup 738 816 */ 739 817 function test_illegal_user_logins_multisite() { 740 818 $user_data = array( … … 773 851 774 852 /** 775 853 * @ticket 24618 854 * 855 * @covers ::validate_username 776 856 */ 777 857 public function test_validate_username_string() { 778 858 $this->assertTrue( validate_username( 'johndoe' ) ); … … 781 861 782 862 /** 783 863 * @ticket 24618 864 * 865 * @covers ::validate_username 784 866 */ 785 867 public function test_validate_username_contains_uppercase_letters() { 786 868 if ( is_multisite() ) { … … 792 874 793 875 /** 794 876 * @ticket 24618 877 * 878 * @covers ::validate_username 795 879 */ 796 880 public function test_validate_username_empty() { 797 881 $this->assertFalse( validate_username( '' ) ); … … 799 883 800 884 /** 801 885 * @ticket 24618 886 * 887 * @covers ::validate_username 802 888 */ 803 889 public function test_validate_username_invalid() { 804 890 $this->assertFalse( validate_username( '@#&99sd' ) ); … … 806 892 807 893 /** 808 894 * @ticket 29880 895 * 896 * @covers ::wp_insert_user 809 897 */ 810 898 public function test_wp_insert_user_should_not_wipe_existing_password() { 811 899 $user_details = array( … … 828 916 829 917 /** 830 918 * @ticket 29696 919 * 920 * @covers ::wp_insert_user 831 921 */ 832 922 public function test_wp_insert_user_should_sanitize_user_nicename_parameter() { 833 923 $user = $this->author; … … 843 933 844 934 /** 845 935 * @ticket 33793 936 * 937 * @covers ::wp_insert_user 846 938 */ 847 939 public function test_wp_insert_user_should_accept_user_login_with_60_characters() { 848 940 $user_login = str_repeat( 'a', 60 ); … … 864 956 865 957 /** 866 958 * @ticket 33793 959 * 960 * @covers ::wp_insert_user 867 961 */ 868 962 public function test_wp_insert_user_should_reject_user_login_over_60_characters() { 869 963 $user_login = str_repeat( 'a', 61 ); … … 882 976 883 977 /** 884 978 * @ticket 33793 979 * 980 * @covers ::wp_insert_user 885 981 */ 886 982 public function test_wp_insert_user_should_reject_user_nicename_over_50_characters() { 887 983 $user_nicename = str_repeat( 'a', 51 ); … … 900 996 901 997 /** 902 998 * @ticket 33793 999 * 1000 * @covers ::wp_insert_user 903 1001 */ 904 1002 public function test_wp_insert_user_should_not_generate_user_nicename_longer_than_50_chars() { 905 1003 $user_login = str_repeat( 'a', 55 ); … … 919 1017 920 1018 /** 921 1019 * @ticket 33793 1020 * 1021 * @covers ::wp_insert_user 922 1022 */ 923 1023 public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename() { 924 1024 $u1 = self::factory()->user->create( … … 949 1049 950 1050 /** 951 1051 * @ticket 33793 1052 * 1053 * @covers ::wp_insert_user 952 1054 */ 953 1055 public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() { 954 1056 $user_ids = self::factory()->user->create_many( … … 985 1087 986 1088 /** 987 1089 * @ticket 28004 1090 * 1091 * @covers ::wp_insert_user 988 1092 */ 989 1093 public function test_wp_insert_user_with_invalid_user_id() { 990 1094 global $wpdb; … … 1005 1109 1006 1110 /** 1007 1111 * @ticket 47902 1112 * 1113 * @covers ::wp_insert_user 1008 1114 */ 1009 1115 public function test_wp_insert_user_with_empty_data() { 1010 1116 add_filter( 'wp_pre_insert_user_data', '__return_empty_array' ); … … 1019 1125 1020 1126 /** 1021 1127 * @ticket 35750 1128 * 1129 * @covers ::wp_update_user 1022 1130 */ 1023 1131 public function test_wp_update_user_should_delete_userslugs_cache() { 1024 1132 $u = self::factory()->user->create(); … … 1036 1144 $this->assertEquals( $u, wp_cache_get( $updated_user->user_nicename, 'userslugs' ) ); 1037 1145 } 1038 1146 1147 /** 1148 * 1149 * @covers ::wp_update_user 1150 */ 1039 1151 public function test_changing_email_invalidates_password_reset_key() { 1040 1152 global $wpdb; 1041 1153 … … 1088 1200 $this->assertEmpty( $user->user_activation_key ); 1089 1201 } 1090 1202 1203 /** 1204 * 1205 * @covers ::get_users 1206 */ 1091 1207 public function test_search_users_login() { 1092 1208 $users = get_users( 1093 1209 array( … … 1099 1215 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1100 1216 } 1101 1217 1218 /** 1219 * 1220 * @covers ::get_users 1221 */ 1102 1222 public function test_search_users_url() { 1103 1223 $users = get_users( 1104 1224 array( … … 1110 1230 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1111 1231 } 1112 1232 1233 /** 1234 * 1235 * @covers ::get_users 1236 */ 1113 1237 public function test_search_users_email() { 1114 1238 $users = get_users( 1115 1239 array( … … 1121 1245 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1122 1246 } 1123 1247 1248 /** 1249 * 1250 * @covers ::get_users 1251 */ 1124 1252 public function test_search_users_nicename() { 1125 1253 $users = get_users( 1126 1254 array( … … 1132 1260 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1133 1261 } 1134 1262 1263 /** 1264 * 1265 * @covers ::get_users 1266 */ 1135 1267 public function test_search_users_display_name() { 1136 1268 $users = get_users( 1137 1269 array( … … 1145 1277 1146 1278 /** 1147 1279 * @ticket 32158 1280 * 1281 * @covers ::wp_update_user 1148 1282 */ 1149 1283 function test_email_case() { 1150 1284 // Alter the case of the email address (which stays the same). … … 1159 1293 1160 1294 /** 1161 1295 * @ticket 32158 1296 * 1297 * @covers ::wp_update_user 1162 1298 */ 1163 1299 function test_email_change() { 1164 1300 // Change the email address. … … 1182 1318 * @dataProvider data_wp_new_user_notifications 1183 1319 * @ticket 33654 1184 1320 * @ticket 36009 1321 * 1322 * @covers ::wp_new_user_notification 1185 1323 */ 1186 1324 function test_wp_new_user_notification( $notify, $admin_email_sent_expected, $user_email_sent_expected ) { 1187 1325 reset_phpmailer_instance(); … … 1262 1400 * 1263 1401 * @ticket 33654 1264 1402 * @expectedDeprecated wp_new_user_notification 1403 * 1404 * @covers ::wp_new_user_notification 1265 1405 */ 1266 1406 function test_wp_new_user_notification_old_signature_throws_deprecated_warning_but_sends() { 1267 1407 reset_phpmailer_instance(); … … 1287 1427 * Set up a user and try sending a notification using `wp_new_user_notification( $user );`. 1288 1428 * 1289 1429 * @ticket 34377 1430 * 1431 * @covers ::wp_new_user_notification 1290 1432 */ 1291 1433 function test_wp_new_user_notification_old_signature_no_password() { 1292 1434 reset_phpmailer_instance(); … … 1312 1454 * Ensure blog's admin email change notification emails do not contain encoded HTML entities 1313 1455 * 1314 1456 * @ticket 40015 1457 * 1458 * @covers ::update_option_new_admin_email 1315 1459 */ 1316 1460 function test_new_admin_email_notification_html_entities_decoded() { 1317 1461 reset_phpmailer_instance(); … … 1345 1489 * - is not a valid email 1346 1490 * 1347 1491 * @dataProvider data_user_admin_email_confirmation_emails 1492 * 1493 * @covers ::update_option_new_admin_email 1348 1494 */ 1349 1495 function test_new_admin_email_confirmation_not_sent_when_email_invalid( $email, $message ) { 1350 1496 reset_phpmailer_instance(); … … 1386 1532 * - Matches another user's email 1387 1533 * 1388 1534 * @dataProvider data_user_change_email_confirmation_emails 1535 * 1536 * @covers ::send_confirmation_on_profile_email 1389 1537 */ 1390 1538 function test_profile_email_confirmation_not_sent_invalid_email( $email, $message ) { 1391 1539 … … 1451 1599 * Checks that calling edit_user() with no password returns an error when adding, and doesn't when updating. 1452 1600 * 1453 1601 * @ticket 35715 1602 * 1603 * @covers ::edit_user 1454 1604 */ 1455 1605 function test_edit_user_blank_pw() { 1456 1606 $_POST = array(); … … 1520 1670 1521 1671 /** 1522 1672 * @ticket 16470 1673 * 1674 * @covers ::wp_set_current_user 1523 1675 */ 1524 1676 function test_send_confirmation_on_profile_email() { 1525 1677 reset_phpmailer_instance(); … … 1555 1707 1556 1708 /** 1557 1709 * @ticket 16470 1710 * 1711 * @covers ::wp_set_current_user 1558 1712 */ 1559 1713 function test_remove_send_confirmation_on_profile_email() { 1560 1714 remove_action( 'personal_options_update', 'send_confirmation_on_profile_email' ); … … 1595 1749 * 1596 1750 * @ticket 16470 1597 1751 * @ticket 40015 1752 * 1753 * @covers ::send_confirmation_on_profile_email 1598 1754 */ 1599 1755 function test_send_confirmation_on_profile_email_html_entities_decoded() { 1600 1756 $user_id = self::factory()->user->create( … … 1631 1787 1632 1788 /** 1633 1789 * @ticket 42564 1790 * 1791 * @covers ::edit_user 1634 1792 */ 1635 1793 function test_edit_user_role_update() { 1636 1794 $_POST = array(); … … 1674 1832 * Testing the `wp_user_personal_data_exporter()` function when no user exists. 1675 1833 * 1676 1834 * @ticket 43547 1835 * 1836 * @covers ::wp_user_personal_data_exporter 1677 1837 */ 1678 1838 function test_wp_user_personal_data_exporter_no_user() { 1679 1839 $actual = wp_user_personal_data_exporter( 'not-a-user-email@test.com' ); … … 1691 1851 * user exists. 1692 1852 * 1693 1853 * @ticket 43547 1854 * 1855 * @covers ::wp_user_personal_data_exporter 1694 1856 */ 1695 1857 function test_wp_user_personal_data_exporter() { 1696 1858 $test_user = new WP_User( self::$contrib_id ); … … 1711 1873 * with Community Events Location IP data. 1712 1874 * 1713 1875 * @ticket 43921 1876 * 1877 * @covers ::wp_user_personal_data_exporter 1714 1878 */ 1715 1879 function test_wp_community_events_location_ip_personal_data_exporter() { 1716 1880 $test_user = new WP_User( self::$contrib_id ); … … 1735 1899 * with Community Events Location city data. 1736 1900 * 1737 1901 * @ticket 43921 1902 * 1903 * @covers ::wp_user_personal_data_exporter 1738 1904 */ 1739 1905 function test_wp_community_events_location_city_personal_data_exporter() { 1740 1906 $test_user = new WP_User( self::$contrib_id ); … … 1777 1943 * with Session Tokens data. 1778 1944 * 1779 1945 * @ticket 45889 1946 * 1947 * @covers ::wp_user_personal_data_exporter 1780 1948 */ 1781 1949 function test_wp_session_tokens_personal_data_exporter() { 1782 1950 $test_user = new WP_User( self::$contrib_id ); … … 1821 1989 * @since 5.4.0 1822 1990 * 1823 1991 * @ticket 47509 1992 * 1993 * @covers ::wp_user_personal_data_exporter 1824 1994 */ 1825 1995 function test_filter_wp_privacy_additional_user_profile_data() { 1826 1996 $test_user = new WP_User( self::$contrib_id ); -
tests/phpunit/tests/walker.php
16 16 17 17 } 18 18 19 /** 20 * 21 * @covers Walker::walk 22 */ 19 23 function test_single_item() { 20 24 21 25 $items = array( … … 31 35 32 36 } 33 37 38 /** 39 * 40 * @covers Walker::walk 41 */ 34 42 function test_single_item_flat() { 35 43 36 44 $items = array( … … 46 54 47 55 } 48 56 57 /** 58 * 59 * @covers Walker::walk 60 */ 49 61 function test_single_item_depth_1() { 50 62 51 63 $items = array( … … 61 73 62 74 } 63 75 76 /** 77 * 78 * @covers Walker::walk 79 */ 64 80 function test_multiple_items_single_level() { 65 81 66 82 $items = array( … … 81 97 82 98 } 83 99 100 /** 101 * 102 * @covers Walker::walk 103 */ 84 104 function test_multiple_items_multiple_levels() { 85 105 86 106 $items = array( … … 101 121 102 122 } 103 123 124 /** 125 * 126 * @covers Walker::walk 127 */ 104 128 function test_multiple_items_multiple_levels_flat() { 105 129 106 130 $items = array( … … 121 145 122 146 } 123 147 148 /** 149 * 150 * @covers Walker::walk 151 */ 124 152 function test_multiple_items_multiple_levels_depth_1() { 125 153 126 154 $items = array( … … 141 169 142 170 } 143 171 172 /** 173 * 174 * @covers Walker::walk 175 */ 144 176 function test_multiple_items_multiple_levels_depth_2() { 145 177 146 178 $items = array( … … 165 197 166 198 } 167 199 200 /** 201 * 202 * @covers Walker::walk 203 */ 168 204 function test_multiple_items_recursive() { 169 205 170 206 $items = array( … … 185 221 186 222 } 187 223 224 /** 225 * 226 * @covers Walker::walk 227 */ 188 228 function test_single_item_child() { 189 229 190 230 $items = array( … … 201 241 202 242 } 203 243 244 /** 245 * 246 * @covers Walker::walk 247 */ 204 248 function test_single_item_missing_parent_depth_1() { 205 249 206 250 $items = array( … … 224 268 225 269 } 226 270 271 /** 272 * 273 * @covers Walker::walk 274 */ 227 275 function test_multiple_items_missing_parents() { 228 276 229 277 $items = array( … … 248 296 249 297 } 250 298 299 /** 300 * 301 * @covers Walker::walk 302 */ 251 303 function test_multiple_items_missing_parents_depth_1() { 252 304 253 305 $items = array( -
tests/phpunit/tests/widgets.php
31 31 /** 32 32 * @see register_widget() 33 33 * @see unregister_widget() 34 * 35 * @covers ::register_widget 36 * @covers ::unregister_widget 34 37 */ 35 38 function test_register_and_unregister_widget_core_widget() { 36 39 global $wp_widget_factory; … … 49 52 * @see register_widget() 50 53 * @see unregister_widget() 51 54 * @ticket 28216 55 * 56 * @covers ::register_widget 57 * @covers ::unregister_widget 52 58 */ 53 59 function test_register_and_unregister_widget_instance() { 54 60 global $wp_widget_factory, $wp_registered_widgets; … … 125 131 126 132 /** 127 133 * @group sidebar 134 * 135 * @covers ::register_sidebars 128 136 */ 129 137 function test_register_sidebars_single() { 130 138 … … 138 146 139 147 /** 140 148 * @group sidebar 149 * 150 * @covers ::register_sidebars 141 151 */ 142 152 function test_register_sidebars_multiple() { 143 153 … … 161 171 162 172 /** 163 173 * @group sidebar 174 * 175 * @covers ::register_sidebars 164 176 */ 165 177 function test_register_sidebar_with_no_id() { 166 178 global $wp_registered_sidebars; … … 178 190 179 191 /** 180 192 * @group sidebar 193 * 194 * @covers ::register_sidebars 181 195 */ 182 196 function test_unregister_sidebar_registered_with_no_id() { 183 197 global $wp_registered_sidebars; … … 197 211 198 212 /** 199 213 * @group sidebar 214 * 215 * @covers ::register_sidebars 200 216 */ 201 217 function test_register_sidebar_with_string_id() { 202 218 … … 210 226 211 227 /** 212 228 * @group sidebar 229 * 230 * @covers ::unregister_sidebar 213 231 */ 214 232 function test_unregister_sidebar_with_string_id() { 215 233 global $wp_registered_sidebars; … … 223 241 224 242 /** 225 243 * @group sidebar 244 * 245 * @covers ::register_sidebars 226 246 */ 227 247 function test_register_sidebar_with_numeric_id() { 228 248 global $wp_registered_sidebars; … … 235 255 236 256 /** 237 257 * @group sidebar 258 * 259 * @covers ::unregister_sidebar 238 260 */ 239 261 function test_unregister_sidebar_with_numeric_id() { 240 262 global $wp_registered_sidebars; … … 256 278 257 279 /** 258 280 * @group sidebar 281 * 282 * @covers ::dynamic_sidebar 259 283 */ 260 284 function test_dynamic_sidebar_using_sidebar_registered_with_no_id() { 261 285 $this->setExpectedIncorrectUsage( 'register_sidebar' ); … … 275 299 276 300 /** 277 301 * @group sidebar 302 * 303 * @covers ::dynamic_sidebar 278 304 */ 279 305 function test_dynamic_sidebar_using_invalid_sidebar_id() { 280 306 register_sidebar( array( 'id' => 'wp-unit-text' ) ); … … 293 319 294 320 /** 295 321 * @group sidebar 322 * 323 * @covers ::dynamic_sidebar 296 324 */ 297 325 function test_dynamic_sidebar_numeric_id() { 298 326 $sidebar_id = 2; … … 307 335 308 336 /** 309 337 * @group sidebar 338 * 339 * @covers ::dynamic_sidebar 310 340 */ 311 341 function test_dynamic_sidebar_string_id() { 312 342 $sidebar_id = 'wp-unit-tests'; … … 321 351 322 352 /** 323 353 * @see WP_Widget_Search::form() 354 * 355 * @covers WP_Widget_Search::form 324 356 */ 325 357 function test_wp_widget_search_form() { 326 358 $widget = new WP_Widget_Search( 'foo', 'Foo' ); … … 343 375 344 376 /** 345 377 * @see WP_Widget::form() 378 * 379 * @covers WP_Widget_Search::form 346 380 */ 347 381 function test_wp_widget_form() { 348 382 $widget = new WP_Widget( 'foo', 'Foo' ); … … 355 389 356 390 /** 357 391 * @see WP_Widget::__construct() 392 * 393 * @covers WP_Widget::__construct 358 394 */ 359 395 function test_wp_widget_constructor() { 360 396 $id_base = 'foo'; … … 385 421 /** 386 422 * @see WP_Widget::get_field_name() 387 423 * @dataProvider data_wp_widget_get_field_name 424 * 425 * @covers WP_Widget::get_field_name 388 426 */ 389 427 function test_wp_widget_get_field_name( $expected, $value_to_test ) { 390 428 $widget = new WP_Widget( 'foo', 'Foo' ); … … 435 473 /** 436 474 * @see WP_Widget::get_field_id() 437 475 * @dataProvider data_wp_widget_get_field_id 476 * 477 * @covers WP_Widget::get_field_id 438 478 */ 439 479 function test_wp_widget_get_field_id( $expected, $value_to_test ) { 440 480 $widget = new WP_Widget( 'foo', 'Foo' ); … … 484 524 485 525 /** 486 526 * @see WP_Widget::_register() 527 * 528 * @covers WP_Widget::_register 529 * @covers ::wp_widgets_init 487 530 */ 488 531 function test_wp_widget__register() { 489 532 global $wp_registered_widgets; … … 506 549 507 550 /** 508 551 * @see WP_Widget::is_preview() 552 * 553 * @covers WP_Widget::is_preview 509 554 */ 510 555 function test_wp_widget_is_preview() { 511 556 global $wp_customize; … … 529 574 530 575 /** 531 576 * @see WP_Widget::get_settings() 577 * 578 * @covers WP_Widget::get_settings 532 579 */ 533 580 function test_wp_widget_get_settings() { 534 581 global $wp_registered_widgets; … … 566 613 567 614 /** 568 615 * @see WP_Widget::save_settings() 616 * 617 * @covers WP_Widget::save_settings 569 618 */ 570 619 function test_wp_widget_save_settings() { 571 620 global $wp_registered_widgets; … … 597 646 598 647 /** 599 648 * @see WP_Widget::save_settings() 649 * 650 * @covers WP_Widget::save_settings 600 651 */ 601 652 function test_wp_widget_save_settings_delete() { 602 653 global $wp_registered_widgets; … … 614 665 615 666 /** 616 667 * @see wp_widget_control() 668 * 669 * @covers ::wp_widget_control 617 670 */ 618 671 function test_wp_widget_control() { 619 672 global $wp_registered_widgets; … … 676 729 } 677 730 } 678 731 732 /** 733 * 734 * @covers ::the_widget 735 */ 679 736 function test_the_widget_custom_before_title_arg() { 680 737 register_widget( 'WP_Widget_Text' ); 681 738 … … 704 761 * display an unregistered widget. 705 762 * 706 763 * @see \the_widget() 764 * 765 * @covers ::the_widget 707 766 */ 708 767 function test_the_widget_with_unregistered_widget() { 709 768 $this->setExpectedIncorrectUsage( 'the_widget' ); … … 712 771 713 772 /** 714 773 * @ticket 34226 774 * 775 * @covers ::the_widget 715 776 */ 716 777 public function test_the_widget_should_short_circuit_with_widget_display_callback() { 717 778 add_filter( 'widget_display_callback', '__return_false' ); … … 740 801 /** 741 802 * Tests for when 'sidebars_widgets' theme mod is populated. 742 803 * 743 * @covers ::retrieve_widgets ()804 * @covers ::retrieve_widgets 744 805 */ 745 806 function test_retrieve_widgets_with_theme_mod() { 746 807 global $sidebars_widgets, $_wp_sidebars_widgets; … … 804 865 /** 805 866 * Tests for when sidebars widgets matches registered sidebars. 806 867 * 807 * @covers ::retrieve_widgets ()868 * @covers ::retrieve_widgets 808 869 */ 809 870 function test_retrieve_widgets_with_sidebars_widgets_matching_registered_sidebars() { 810 871 global $sidebars_widgets; … … 842 903 /** 843 904 * Tests for when sidebars widgets doesn't match registered sidebars. 844 905 * 845 * @covers ::retrieve_widgets ()906 * @covers ::retrieve_widgets 846 907 */ 847 908 function test_retrieve_widgets_with_sidebars_widgets_not_matching_registered_sidebars() { 848 909 global $sidebars_widgets, $_wp_sidebars_widgets; … … 936 997 /** 937 998 * Tests for Customizer mode. 938 999 * 939 * @covers ::retrieve_widgets ()1000 * @covers ::retrieve_widgets 940 1001 */ 941 1002 function test_retrieve_widgets_for_customizer() { 942 1003 global $sidebars_widgets, $_wp_sidebars_widgets; … … 983 1044 $this->assertNotEquals( $sidebars_widgets, wp_get_sidebars_widgets() ); 984 1045 } 985 1046 1047 /** 1048 * 1049 * @covers ::retrieve_widgets 1050 */ 986 1051 function test_retreive_widgets_with_single_widget() { 987 1052 global $sidebars_widgets; 988 1053 … … 1008 1073 /** 1009 1074 * Tests for orphaned widgets being moved into inactive widgets. 1010 1075 * 1011 * @covers ::retrieve_widgets ()1076 * @covers ::retrieve_widgets 1012 1077 */ 1013 1078 function test_retrieve_widgets_move_orphaned_widgets_to_inactive() { 1014 1079 global $sidebars_widgets; … … 1043 1108 /** 1044 1109 * Test _wp_remove_unregistered_widgets. 1045 1110 * 1046 * @covers ::_wp_remove_unregistered_widgets ()1111 * @covers ::_wp_remove_unregistered_widgets 1047 1112 */ 1048 1113 public function test__wp_remove_unregistered_widgets() { 1049 1114 $widgets = array( … … 1073 1138 /** 1074 1139 * Two themes with one sidebar each should just map, switching to a theme not previously-active. 1075 1140 * 1076 * @covers ::wp_map_sidebars_widgets ()1141 * @covers ::wp_map_sidebars_widgets 1077 1142 */ 1078 1143 public function test_one_sidebar_each() { 1079 1144 $this->register_sidebars( array( 'primary' ) ); … … 1093 1158 /** 1094 1159 * Sidebars with the same name should map, switching to a theme not previously-active. 1095 1160 * 1096 * @covers ::wp_map_sidebars_widgets ()1161 * @covers ::wp_map_sidebars_widgets 1097 1162 */ 1098 1163 public function test_sidebars_with_same_slug() { 1099 1164 $this->register_sidebars( array( 'primary', 'secondary' ) ); … … 1111 1176 /** 1112 1177 * Make educated guesses on theme sidebars. 1113 1178 * 1114 * @covers ::wp_map_sidebars_widgets ()1179 * @covers ::wp_map_sidebars_widgets 1115 1180 */ 1116 1181 public function test_sidebar_guessing() { 1117 1182 $this->register_sidebars( array( 'primary', 'secondary' ) ); … … 1134 1199 /** 1135 1200 * Make sure two sidebars that fall in the same group don't get the same menu assigned. 1136 1201 * 1137 * @covers ::wp_map_sidebars_widgets ()1202 * @covers ::wp_map_sidebars_widgets 1138 1203 */ 1139 1204 public function test_sidebar_guessing_one_menu_per_group() { 1140 1205 $this->register_sidebars( array( 'primary' ) ); … … 1155 1220 /** 1156 1221 * Make sure two sidebars that fall in the same group get menus assigned from the same group. 1157 1222 * 1158 * @covers ::wp_map_sidebars_widgets ()1223 * @covers ::wp_map_sidebars_widgets 1159 1224 */ 1160 1225 public function test_sidebar_guessing_one_menu_per_sidebar() { 1161 1226 $this->register_sidebars( array( 'primary', 'main' ) ); -
tests/phpunit/tests/wp.php
14 14 $this->wp = new WP(); 15 15 } 16 16 17 /** 18 * 19 * @covers WP::add_query_var 20 */ 17 21 public function test_add_query_var() { 18 22 $public_qv_count = count( $this->wp->public_query_vars ); 19 23 … … 26 30 $this->assertTrue( in_array( 'test2', $this->wp->public_query_vars, true ) ); 27 31 } 28 32 33 /** 34 * 35 * @covers WP::remove_query_var 36 */ 29 37 public function test_remove_query_var() { 30 38 $public_qv_count = count( $this->wp->public_query_vars ); 31 39