Ticket #39265: root.patch
File root.patch, 264.7 KB (added by , 5 years ago) |
---|
-
package-lock.json
5961 5961 }, 5962 5962 "bl": { 5963 5963 "version": "1.2.2", 5964 "resolved": "http s://registry.npmjs.org/bl/-/bl-1.2.2.tgz",5964 "resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz", 5965 5965 "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", 5966 5966 "dev": true, 5967 5967 "optional": true, … … 6152 6152 }, 6153 6153 "browserify-aes": { 6154 6154 "version": "1.2.0", 6155 "resolved": "http s://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",6155 "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", 6156 6156 "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", 6157 6157 "dev": true, 6158 6158 "requires": { … … 7508 7508 }, 7509 7509 "create-hash": { 7510 7510 "version": "1.2.0", 7511 "resolved": "http s://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",7511 "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", 7512 7512 "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", 7513 7513 "dev": true, 7514 7514 "requires": { … … 7521 7521 }, 7522 7522 "create-hmac": { 7523 7523 "version": "1.1.7", 7524 "resolved": "http s://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",7524 "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", 7525 7525 "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", 7526 7526 "dev": true, 7527 7527 "requires": { … … 7587 7587 }, 7588 7588 "css-color-names": { 7589 7589 "version": "0.0.4", 7590 "resolved": "http s://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz",7590 "resolved": "http://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", 7591 7591 "integrity": "sha1-gIrcLnnPhHOAabZGyyDsJ762KeA=", 7592 7592 "dev": true 7593 7593 }, … … 8572 8572 }, 8573 8573 "diffie-hellman": { 8574 8574 "version": "5.0.3", 8575 "resolved": "http s://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",8575 "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", 8576 8576 "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", 8577 8577 "dev": true, 8578 8578 "requires": { … … 8801 8801 }, 8802 8802 "duplexer": { 8803 8803 "version": "0.1.1", 8804 "resolved": "http s://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",8804 "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", 8805 8805 "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", 8806 8806 "dev": true 8807 8807 }, … … 20400 20400 }, 20401 20401 "react-autosize-textarea": { 20402 20402 "version": "3.0.3", 20403 "resolved": "http s://registry.npmjs.org/react-autosize-textarea/-/react-autosize-textarea-3.0.3.tgz",20403 "resolved": "http://registry.npmjs.org/react-autosize-textarea/-/react-autosize-textarea-3.0.3.tgz", 20404 20404 "integrity": "sha512-iOSZK7RUuJ+iEwkJ9rqYciqtjQgrG1CCRFL6h8Bk61kODnRyEq4tS74IgXpI1t4S6jBBZVm+6ugaU+tWTlVxXg==", 20405 20405 "requires": { 20406 20406 "autosize": "^4.0.0", … … 22124 22124 }, 22125 22125 "sha.js": { 22126 22126 "version": "2.4.11", 22127 "resolved": "http s://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",22127 "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", 22128 22128 "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", 22129 22129 "dev": true, 22130 22130 "requires": { -
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 * 33 * @covers ::remove_action 34 */ 27 35 function test_remove_action() { 28 36 $a = new MockAction(); 29 37 $tag = __FUNCTION__; … … 43 51 44 52 } 45 53 54 /** 55 * 56 * @covers ::has_action 57 */ 46 58 function test_has_action() { 47 59 $tag = __FUNCTION__; 48 60 $func = __FUNCTION__ . '_func'; … … 57 69 $this->assertFalse( has_action( $tag ) ); 58 70 } 59 71 60 // One tag with multiple actions. 72 /** 73 * One tag with multiple actions. 74 * 75 * @covers ::add_action 76 */ 61 77 function test_multiple_actions() { 62 78 $a1 = new MockAction(); 63 79 $a2 = new MockAction(); … … 74 90 $this->assertEquals( 1, $a2->get_call_count() ); 75 91 } 76 92 93 /** 94 * One tag with multiple actions. 95 * 96 * @covers ::do_action 97 */ 77 98 function test_action_args_1() { 78 99 $a = new MockAction(); 79 100 $tag = __FUNCTION__; … … 89 110 $this->assertEquals( array( $val ), array_pop( $argsvar ) ); 90 111 } 91 112 113 /** 114 * One tag with multiple actions. 115 * 116 * @covers ::do_action 117 */ 92 118 function test_action_args_2() { 93 119 $a1 = new MockAction(); 94 120 $a2 = new MockAction(); … … 120 146 * 121 147 * @see https://core.trac.wordpress.org/ticket/17817#comment:72 122 148 * @ticket 17817 149 * 150 * @covers ::do_action 123 151 */ 124 152 function test_action_args_3() { 125 153 $a1 = new MockAction(); … … 157 185 * Tests PHP 4 notation for calling actions while passing in an object by reference. 158 186 * 159 187 * @ticket 48312 188 * 189 * @covers ::do_action 160 190 */ 161 191 function test_action_args_with_php4_syntax() { 162 192 $a = new MockAction(); … … 201 231 $this->assertEquals( $expected, $a->get_events() ); 202 232 } 203 233 234 /** 235 * 236 * @covers ::did_action 237 */ 204 238 function test_did_action() { 205 239 $tag1 = 'action1'; 206 240 $tag2 = 'action2'; … … 222 256 223 257 } 224 258 259 /** 260 * 261 * @covers ::add_action 262 */ 225 263 function test_all_action() { 226 264 $a = new MockAction(); 227 265 $tag1 = __FUNCTION__ . '_1'; … … 246 284 247 285 } 248 286 287 /** 288 * 289 * @covers ::remove_action 290 */ 249 291 function test_remove_all_action() { 250 292 $a = new MockAction(); 251 293 $tag = __FUNCTION__; … … 266 308 $this->assertEquals( array( $tag ), $a->get_tags() ); 267 309 } 268 310 311 /** 312 * 313 * @covers ::do_action_ref_array 314 */ 269 315 function test_action_ref_array() { 270 316 $obj = new stdClass(); 271 317 $a = new MockAction(); … … 284 330 285 331 /** 286 332 * @ticket 11241 333 * 334 * @covers ::add_action 287 335 */ 288 336 function test_action_keyed_array() { 289 337 $a = new MockAction(); … … 309 357 310 358 } 311 359 360 /** 361 * 362 * @covers ::do_action 363 */ 312 364 function test_action_self_removal() { 313 365 add_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) ); 314 366 do_action( 'test_action_self_removal' ); … … 321 373 322 374 /** 323 375 * @ticket 17817 376 * 377 * @covers ::do_action 324 378 */ 325 379 function test_action_recursion() { 326 380 $tag = __FUNCTION__; … … 336 390 $this->assertEquals( 2, $b->get_call_count(), 'recursive actions should call callbacks with later priority' ); 337 391 } 338 392 393 /** 394 * 395 * @covers ::do_action 396 */ 339 397 function action_that_causes_recursion( $tag ) { 340 398 static $recursing = false; 341 399 if ( ! $recursing ) { … … 348 406 /** 349 407 * @ticket 9968 350 408 * @ticket 17817 409 * 410 * @covers ::add_action 351 411 */ 352 412 function test_action_callback_manipulation_while_running() { 353 413 $tag = __FUNCTION__; … … 383 443 * 384 444 * This specificaly addresses the concern raised at 385 445 * https://core.trac.wordpress.org/ticket/17817#comment:52 446 * 447 * @covers ::remove_filter 386 448 */ 387 449 function test_remove_anonymous_callback() { 388 450 $tag = __FUNCTION__; … … 416 478 * Test the ArrayAccess methods of WP_Hook 417 479 * 418 480 * @ticket 17817 481 * 482 * @covers ::has_action 419 483 */ 420 484 function test_array_access_of_wp_filter_global() { 421 485 global $wp_filter; … … 442 506 * Make sure current_action() behaves as current_filter() 443 507 * 444 508 * @ticket 14994 509 * 510 * @covers ::current_action 445 511 */ 446 512 function test_current_action() { 447 513 global $wp_current_filter; … … 453 519 454 520 /** 455 521 * @ticket 14994 522 * 523 * @covers ::doing_filter 456 524 */ 457 525 function test_doing_filter() { 458 526 global $wp_current_filter; … … 472 540 473 541 /** 474 542 * @ticket 14994 543 * 544 * @covers ::doing_filter 475 545 */ 476 546 function test_doing_action() { 477 547 global $wp_current_filter; … … 491 561 492 562 /** 493 563 * @ticket 14994 564 * 565 * @covers ::doing_filter 494 566 */ 495 567 function test_doing_filter_real() { 496 568 $this->assertFalse( doing_filter() ); // No filter is passed in, and no filter is being processed. … … 509 581 $this->assertFalse( doing_filter( 'testing' ) ); // No longer doing this filter. 510 582 } 511 583 584 /** 585 * 586 * @covers ::doing_filter 587 */ 512 588 function apply_testing_filter() { 513 589 $this->apply_testing_filter = true; 514 590 … … 530 606 $this->assertFalse( doing_filter( 'testing_nested' ) ); 531 607 } 532 608 609 /** 610 * 611 * @covers ::doing_filter 612 */ 533 613 function apply_testing_nested_filter() { 534 614 $this->apply_testing_nested_filter = true; 535 615 $this->assertTrue( doing_filter() ); … … 541 621 /** 542 622 * @ticket 10441 543 623 * @expectedDeprecated tests_do_action_deprecated 624 * 625 * @covers ::do_action_deprecated 544 626 */ 545 627 public function test_do_action_deprecated() { 546 628 $p = new WP_Post( (object) array( 'post_title' => 'Foo' ) ); … … 559 641 /** 560 642 * @ticket 10441 561 643 * @expectedDeprecated tests_do_action_deprecated 644 * 645 * @covers ::do_action_deprecated 562 646 */ 563 647 public function test_do_action_deprecated_with_multiple_params() { 564 648 $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 * 256 * 257 * @return mixed 258 * 259 * @covers ::is_admin_bar_showing 260 */ 242 261 protected function get_standard_admin_bar() { 243 262 global $wp_admin_bar; 244 263 … … 259 278 * 260 279 * @param array $node_data The data for a node, passed to `WP_Admin_Bar::add_node()`. 261 280 * @param string $expected_html The expected HTML when admin menu is rendered. 281 * 282 * @covers WP_Admin_Bar::add_node 262 283 */ 263 284 public function test_admin_bar_with_tabindex_meta( $node_data, $expected_html ) { 264 285 $admin_bar = new WP_Admin_Bar(); … … 347 368 348 369 /** 349 370 * @ticket 22247 371 * 372 * @covers ::_wp_admin_bar_init 373 * 374 * @covers WP_Admin_Bar::get_node 350 375 */ 351 376 public function test_admin_bar_has_edit_link_for_existing_posts() { 352 377 wp_set_current_user( self::$editor_id ); … … 374 399 375 400 /** 376 401 * @ticket 22247 402 * 403 * @covers WP_Admin_Bar::get_node 377 404 */ 378 405 public function test_admin_bar_has_no_edit_link_for_non_existing_posts() { 379 406 wp_set_current_user( self::$editor_id ); … … 393 420 394 421 /** 395 422 * @ticket 34113 423 * 424 * @covers WP_Admin_Bar::get_node 396 425 */ 397 426 public function test_admin_bar_has_no_archives_link_if_no_static_front_page() { 398 427 set_current_screen( 'edit-post' ); … … 407 436 408 437 /** 409 438 * @ticket 34113 439 * 440 * @covers WP_Admin_Bar::get_node 410 441 */ 411 442 public function test_admin_bar_contains_view_archive_link_if_static_front_page() { 412 443 update_option( 'show_on_front', 'page' ); … … 422 453 423 454 /** 424 455 * @ticket 34113 456 * 457 * @covers WP_Admin_Bar::get_node 425 458 */ 426 459 public function test_admin_bar_has_no_archives_link_for_pages() { 427 460 set_current_screen( 'edit-page' ); … … 437 470 /** 438 471 * @ticket 37949 439 472 * @group ms-excluded 473 * 474 * @covers WP_Admin_Bar::get_node 440 475 */ 441 476 public function test_admin_bar_contains_correct_about_link_for_users_with_role() { 442 477 wp_set_current_user( self::$editor_id ); … … 454 489 /** 455 490 * @ticket 37949 456 491 * @group ms-excluded 492 * 493 * @covers WP_Admin_Bar::get_node 457 494 */ 458 495 public function test_admin_bar_contains_correct_about_link_for_users_with_no_role() { 459 496 wp_set_current_user( self::$no_role_id ); … … 473 510 * @ticket 37949 474 511 * @group multisite 475 512 * @group ms-required 513 * 514 * @covers WP_Admin_Bar::get_node 476 515 */ 477 516 public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite() { 478 517 // User is not a member of a site. … … 492 531 493 532 /** 494 533 * @ticket 34113 534 * 535 * @covers WP_Admin_Bar::get_node 495 536 */ 496 537 public function test_admin_bar_has_no_archives_link_for_non_public_cpt() { 497 538 register_post_type( … … 516 557 517 558 /** 518 559 * @ticket 34113 560 * 561 * @covers WP_Admin_Bar::get_node 519 562 */ 520 563 public function test_admin_bar_has_no_archives_link_for_cpt_without_archive() { 521 564 register_post_type( … … 540 583 541 584 /** 542 585 * @ticket 34113 586 * 587 * @covers WP_Admin_Bar::get_node 543 588 */ 544 589 public function test_admin_bar_has_no_archives_link_for_cpt_not_shown_in_admin_bar() { 545 590 register_post_type( … … 596 641 597 642 /** 598 643 * @ticket 39252 644 * 645 * @covers WP_Admin_Bar::get_node 599 646 */ 600 647 public function test_new_user_link_exists_for_user_with_create_users() { 601 648 wp_set_current_user( self::$admin_id ); … … 615 662 616 663 /** 617 664 * @ticket 39252 665 * 666 * @covers WP_Admin_Bar::get_node 618 667 */ 619 668 public function test_new_user_link_existence_for_user_with_promote_users() { 620 669 wp_set_current_user( self::$admin_id ); … … 638 687 639 688 /** 640 689 * @ticket 39252 690 * 691 * @covers WP_Admin_Bar::get_node 641 692 */ 642 693 public function test_new_user_link_does_not_exist_for_user_without_create_or_promote_users() { 643 694 wp_set_current_user( self::$admin_id ); … … 657 708 /** 658 709 * @ticket 30937 659 710 * @covers ::wp_admin_bar_customize_menu 711 * 712 * @covers WP_Admin_Bar::get_node 660 713 */ 661 714 public function test_customize_link() { 662 715 global $wp_customize; … … 694 747 /** 695 748 * @ticket 39082 696 749 * @group ms-required 750 * 751 * 752 * @covers WP_Admin_Bar::get_nodes 697 753 */ 698 754 public function test_my_sites_network_menu_for_regular_user() { 699 755 wp_set_current_user( self::$editor_id ); … … 709 765 /** 710 766 * @ticket 39082 711 767 * @group ms-required 768 * 769 * @covers WP_Admin_Bar::get_nodes 712 770 */ 713 771 public function test_my_sites_network_menu_for_super_admin() { 714 772 wp_set_current_user( self::$editor_id ); … … 726 784 /** 727 785 * @ticket 39082 728 786 * @group ms-required 787 * 788 * @covers WP_Admin_Bar::get_nodes 729 789 */ 730 790 public function test_my_sites_network_menu_for_regular_user_with_network_caps() { 731 791 global $current_user; -
tests/phpunit/tests/auth.php
35 35 wp_set_current_user( self::$user_id ); 36 36 } 37 37 38 /** 39 * 40 * @covers ::wp_validate_auth_cookie 41 */ 38 42 function test_auth_cookie_valid() { 39 43 $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'auth' ); 40 44 $this->assertEquals( self::$user_id, wp_validate_auth_cookie( $cookie, 'auth' ) ); 41 45 } 42 46 47 /** 48 * 49 * @covers ::wp_validate_auth_cookie 50 */ 43 51 function test_auth_cookie_invalid() { 44 52 // 3600 or less and +3600 may occur in wp_validate_auth_cookie(), 45 53 // as an ajax test may have defined DOING_AJAX, failing the test. … … 56 64 $this->assertEquals( false, wp_validate_auth_cookie( self::$user_id, 'auth' ), 'altered cookie' ); 57 65 } 58 66 67 /** 68 * 69 * @covers ::wp_validate_auth_cookie 70 */ 59 71 function test_auth_cookie_scheme() { 60 72 // Arbitrary scheme name. 61 73 $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' ); … … 68 80 69 81 /** 70 82 * @ticket 23494 83 * 84 * @covers ::wp_authenticate 71 85 */ 72 86 function test_password_trimming() { 73 87 $passwords_to_test = array( … … 93 107 * wp_hash_password function 94 108 * 95 109 * @ticket 24973 110 * 111 * @covers ::wp_hash_password 96 112 */ 97 113 function test_wp_hash_password_trimming() { 98 114 99 115 $password = ' pass with leading whitespace'; 100 $this->assertTrue( wp_check_password( 'pass with leading whitespace', wp_hash_password( $password ) ) );116 $this->assertTrue( wp_check_password( 'pass with leading whitespace', ( $password ) ) ); 101 117 102 118 $password = 'pass with trailing whitespace '; 103 119 $this->assertTrue( wp_check_password( 'pass with trailing whitespace', wp_hash_password( $password ) ) ); … … 114 130 115 131 /** 116 132 * @ticket 29217 133 * 134 * @covers ::wp_verify_nonce 117 135 */ 118 136 function test_wp_verify_nonce_with_empty_arg() { 119 137 $this->assertFalse( wp_verify_nonce( '' ) ); … … 122 140 123 141 /** 124 142 * @ticket 29542 143 * 144 * @covers ::wp_verify_nonce 145 * 146 * @covers ::wp_verify_nonce 125 147 */ 126 148 function test_wp_verify_nonce_with_integer_arg() { 127 149 $this->assertFalse( wp_verify_nonce( 1 ) ); … … 129 151 130 152 /** 131 153 * @ticket 24030 154 * 155 * @covers ::wp_verify_nonce 132 156 */ 133 157 function test_wp_nonce_verify_failed() { 134 158 $nonce = substr( md5( uniqid() ), 0, 10 ); … … 141 165 142 166 /** 143 167 * @ticket 24030 168 * 169 * @covers ::wp_verify_nonce 144 170 */ 145 171 function test_wp_nonce_verify_success() { 146 172 $nonce = wp_create_nonce( 'nonce_test_action' ); … … 153 179 154 180 /** 155 181 * @ticket 36361 182 * 183 * @covers ::check_admin_referer 156 184 */ 157 185 public function test_check_admin_referer_with_no_action_triggers_doing_it_wrong() { 158 186 $this->setExpectedIncorrectUsage( 'check_admin_referer' ); … … 165 193 unset( $_REQUEST['_wpnonce'] ); 166 194 } 167 195 196 /** 197 * 198 * @covers ::check_admin_referer 199 */ 168 200 public function test_check_admin_referer_with_default_action_as_string_not_doing_it_wrong() { 169 201 // A valid nonce needs to be set so the check doesn't die(). 170 202 $_REQUEST['_wpnonce'] = wp_create_nonce( '-1' ); … … 176 208 177 209 /** 178 210 * @ticket 36361 211 * 212 * @covers ::check_ajax_referer 179 213 */ 180 214 public function test_check_ajax_referer_with_no_action_triggers_doing_it_wrong() { 181 215 $this->setExpectedIncorrectUsage( 'check_ajax_referer' ); … … 188 222 unset( $_REQUEST['_wpnonce'] ); 189 223 } 190 224 225 /** 226 * 227 * @covers ::wp_authenticate 228 */ 191 229 function test_password_length_limit() { 192 230 $limit = str_repeat( 'a', 4096 ); 193 231 … … 237 275 238 276 /** 239 277 * @ticket 45746 278 * 279 * @covers ::check_password_reset_key 240 280 */ 241 281 function test_user_activation_key_is_saved() { 242 282 $user = get_userdata( $this->user->ID ); … … 251 291 252 292 /** 253 293 * @ticket 32429 294 * 295 * @covers ::check_password_reset_key 254 296 */ 255 297 function test_user_activation_key_is_checked() { 256 298 global $wpdb; … … 289 331 290 332 /** 291 333 * @ticket 32429 334 * 335 * @covers ::check_password_reset_key 292 336 */ 293 337 function test_expired_user_activation_key_is_rejected() { 294 338 global $wpdb; … … 312 356 313 357 /** 314 358 * @ticket 32429 359 * 360 * @covers ::check_password_reset_key 315 361 */ 316 362 function test_empty_user_activation_key_fails_key_check() { 317 363 // An empty user_activation_key should not allow any key to be accepted. … … 325 371 326 372 /** 327 373 * @ticket 32429 374 * 375 * @covers ::check_password_reset_key 328 376 */ 329 377 function test_legacy_user_activation_key_is_rejected() { 330 378 global $wpdb; … … 355 403 /** 356 404 * @ticket 32429 357 405 * @ticket 24783 406 * 407 * @covers ::check_password_reset_key 358 408 */ 359 409 function test_plaintext_user_activation_key_is_rejected() { 360 410 global $wpdb; … … 386 436 * Ensure users can log in using both their username and their email address. 387 437 * 388 438 * @ticket 9568 439 * 440 * @covers ::wp_authenticate 389 441 */ 390 442 public function test_log_in_using_email() { 391 443 $user_args = array( … … 401 453 402 454 /** 403 455 * @ticket 38744 456 * 457 * @covers ::wp_signon 404 458 */ 405 459 public function test_wp_signon_using_email_with_an_apostrophe() { 406 460 $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 * 191 * @covers ::get_avatar 192 */ 170 193 public function test_get_avatar() { 171 194 $img = get_avatar( 1 ); 172 195 $this->assertEquals( preg_match( "|^<img alt='[^']*' src='[^']*' srcset='[^']*' class='[^']*' height='[^']*' width='[^']*' loading='lazy'/>$|", $img ), 1 ); 173 196 } 174 197 198 /** 199 * 200 * @covers ::get_avatar 201 */ 175 202 public function test_get_avatar_size() { 176 203 $size = '100'; 177 204 $img = get_avatar( 1, $size ); … … 178 205 $this->assertEquals( preg_match( "|^<img .*height='$size'.*width='$size'|", $img ), 1 ); 179 206 } 180 207 208 /** 209 * 210 * @covers ::get_avatar 211 */ 181 212 public function test_get_avatar_alt() { 182 213 $alt = 'Mr Hyde'; 183 214 $img = get_avatar( 1, 96, '', $alt ); … … 184 215 $this->assertEquals( preg_match( "|^<img alt='$alt'|", $img ), 1 ); 185 216 } 186 217 218 /** 219 * 220 * @covers ::get_avatar 221 */ 187 222 public function test_get_avatar_class() { 188 223 $class = 'first'; 189 224 $img = get_avatar( 1, 96, '', '', array( 'class' => $class ) ); … … 190 225 $this->assertEquals( preg_match( "|^<img .*class='[^']*{$class}[^']*'|", $img ), 1 ); 191 226 } 192 227 228 /** 229 * 230 * @covers ::get_avatar 231 */ 193 232 public function test_get_avatar_default_class() { 194 233 $img = get_avatar( 1, 96, '', '', array( 'force_default' => true ) ); 195 234 $this->assertEquals( preg_match( "|^<img .*class='[^']*avatar-default[^']*'|", $img ), 1 ); 196 235 } 197 236 237 /** 238 * 239 * @covers ::get_avatar 240 */ 198 241 public function test_get_avatar_force_display() { 199 242 $old = get_option( 'show_avatars' ); 200 243 update_option( 'show_avatars', false ); … … 210 253 protected $fake_img; 211 254 /** 212 255 * @ticket 21195 256 * 257 * @covers ::get_avatar 213 258 */ 214 259 public function test_pre_get_avatar_filter() { 215 260 $this->fake_img = 'YOU TOO?!'; … … 226 271 227 272 /** 228 273 * @ticket 21195 274 * 275 * @covers ::get_avatar 229 276 */ 230 277 public function test_get_avatar_filter() { 231 278 $this->fake_url = 'YA RLY'; … … 244 291 * The `get_avatar_data()` function should return gravatar url when comment type allowed to retrieve avatars. 245 292 * 246 293 * @ticket 44033 294 * 295 * @covers ::is_avatar_comment_type 296 * @covers ::get_avatar 247 297 */ 248 298 public function test_get_avatar_data_should_return_gravatar_url_when_input_avatar_comment_type() { 249 299 $comment_type = 'comment'; … … 264 314 * The `get_avatar_data()` function should return invalid url when comment type not allowed to retrieve avatars. 265 315 * 266 316 * @ticket 44033 317 * 318 * @covers ::is_avatar_comment_type 319 * @covers ::get_avatar 267 320 */ 268 321 public function test_get_avatar_data_should_return_invalid_url_when_input_not_avatar_comment_type() { 269 322 $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 { -
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 * 44 * @covers ::wp_handle_comment_submission 45 */ 42 46 public function test_submitting_comment_to_invalid_post_returns_error() { 43 47 $error = 'comment_id_not_found'; 44 48 … … 55 59 56 60 } 57 61 62 /** 63 * 64 * @covers ::wp_handle_comment_submission 65 */ 58 66 public function test_submitting_comment_to_post_with_closed_comments_returns_error() { 59 67 60 68 $error = 'comment_closed'; … … 78 86 79 87 } 80 88 89 /** 90 * 91 * @covers ::wp_handle_comment_submission 92 */ 81 93 public function test_submitting_comment_to_trashed_post_returns_error() { 82 94 83 95 $error = 'comment_on_trash'; … … 99 111 100 112 } 101 113 114 /** 115 * 116 * @covers ::wp_handle_comment_submission 117 */ 102 118 public function test_submitting_comment_to_draft_post_returns_error() { 103 119 $error = 'comment_on_draft'; 104 120 … … 124 140 125 141 /** 126 142 * @ticket 39650 143 * 144 * @covers ::wp_handle_comment_submission 127 145 */ 128 146 public function test_submitting_comment_to_draft_post_returns_error_message_for_user_with_correct_caps() { 129 147 $error = 'comment_on_draft'; … … 150 168 $this->assertNotEmpty( $comment->get_error_message() ); 151 169 } 152 170 171 /** 172 * 173 * @covers ::wp_handle_comment_submission 174 */ 153 175 public function test_submitting_comment_to_scheduled_post_returns_error() { 154 176 155 177 // Same error as commenting on a draft. … … 176 198 177 199 } 178 200 201 /** 202 * 203 * @covers ::wp_handle_comment_submission 204 */ 179 205 public function test_submitting_comment_to_password_required_post_returns_error() { 180 206 181 207 $error = 'comment_on_password_protected'; … … 199 225 200 226 } 201 227 228 /** 229 * 230 * @covers ::wp_handle_comment_submission 231 */ 202 232 public function test_submitting_comment_to_password_protected_post_succeeds() { 203 233 204 234 $password = 'password'; … … 227 257 228 258 } 229 259 260 /** 261 * 262 * @covers ::wp_handle_comment_submission 263 */ 230 264 public function test_submitting_valid_comment_as_logged_in_user_succeeds() { 231 265 232 266 $user = self::factory()->user->create_and_get( … … 254 288 255 289 } 256 290 291 /** 292 * 293 * @covers ::wp_handle_comment_submission 294 */ 257 295 public function test_submitting_valid_comment_anonymously_succeeds() { 258 296 259 297 $data = array( … … 280 318 * wp_handle_comment_submission() expects un-slashed data. 281 319 * 282 320 * @group slashes 321 * 322 * @covers ::wp_handle_comment_submission 283 323 */ 284 324 public function test_submitting_comment_handles_slashes_correctly_handles_slashes() { 285 325 … … 300 340 301 341 } 302 342 343 /** 344 * 345 * @covers ::wp_handle_comment_submission 346 */ 303 347 public function test_submitting_comment_anonymously_to_private_post_returns_error() { 304 348 305 349 $error = 'comment_id_not_found'; … … 321 365 322 366 } 323 367 368 /** 369 * 370 * @covers ::wp_handle_comment_submission 371 */ 324 372 public function test_submitting_comment_as_logged_in_user_to_inaccessible_private_post_returns_error() { 325 373 326 374 $error = 'comment_id_not_found'; … … 351 399 352 400 } 353 401 402 /** 403 * 404 * @covers ::wp_handle_comment_submission 405 */ 354 406 public function test_submitting_comment_to_private_post_with_closed_comments_returns_correct_error() { 355 407 356 408 $error = 'comment_id_not_found'; … … 382 434 383 435 } 384 436 437 /** 438 * 439 * @covers ::wp_handle_comment_submission 440 */ 385 441 public function test_submitting_comment_to_own_private_post_succeeds() { 386 442 387 443 wp_set_current_user( self::$author_id ); … … 405 461 406 462 } 407 463 464 /** 465 * 466 * @covers ::wp_handle_comment_submission 467 */ 408 468 public function test_submitting_comment_to_accessible_private_post_succeeds() { 409 469 410 470 wp_set_current_user( self::$editor_id ); … … 428 488 429 489 } 430 490 491 /** 492 * 493 * @covers ::wp_handle_comment_submission 494 */ 431 495 public function test_anonymous_user_cannot_comment_unfiltered_html() { 432 496 433 497 $data = array( … … 444 508 445 509 } 446 510 511 /** 512 * 513 * @covers ::wp_handle_comment_submission 514 */ 447 515 public function test_unprivileged_user_cannot_comment_unfiltered_html() { 448 516 449 517 wp_set_current_user( self::$author_id ); … … 462 530 463 531 } 464 532 533 /** 534 * 535 * @covers ::wp_handle_comment_submission 536 */ 465 537 public function test_unprivileged_user_cannot_comment_unfiltered_html_even_with_valid_nonce() { 466 538 467 539 wp_set_current_user( self::$author_id ); … … 486 558 487 559 } 488 560 561 /** 562 * 563 * @covers ::wp_handle_comment_submission 564 */ 489 565 public function test_privileged_user_can_comment_unfiltered_html_with_valid_nonce() { 490 566 491 567 $this->assertFalse( defined( 'DISALLOW_UNFILTERED_HTML' ) ); … … 518 594 519 595 } 520 596 597 /** 598 * 599 * @covers ::wp_handle_comment_submission 600 */ 521 601 public function test_privileged_user_cannot_comment_unfiltered_html_without_valid_nonce() { 522 602 523 603 if ( is_multisite() ) { … … 542 622 543 623 } 544 624 625 /** 626 * 627 * @covers ::wp_handle_comment_submission 628 */ 545 629 public function test_submitting_comment_as_anonymous_user_when_registration_required_returns_error() { 546 630 547 631 $error = 'not_logged_in'; … … 561 645 562 646 } 563 647 648 /** 649 * 650 * @covers ::wp_handle_comment_submission 651 */ 564 652 public function test_submitting_comment_with_no_name_when_name_email_required_returns_error() { 565 653 566 654 $error = 'require_name_email'; … … 582 670 583 671 } 584 672 673 /** 674 * 675 * @covers ::wp_handle_comment_submission 676 */ 585 677 public function test_submitting_comment_with_no_email_when_name_email_required_returns_error() { 586 678 587 679 $error = 'require_name_email'; … … 603 695 604 696 } 605 697 698 /** 699 * 700 * @covers ::wp_handle_comment_submission 701 */ 606 702 public function test_submitting_comment_with_invalid_email_when_name_email_required_returns_error() { 607 703 608 704 $error = 'require_valid_email'; … … 625 721 626 722 } 627 723 724 /** 725 * 726 * @covers ::wp_handle_comment_submission 727 */ 628 728 public function test_submitting_comment_with_no_comment_content_returns_error() { 629 729 630 730 $error = 'require_valid_comment'; … … 644 744 645 745 /** 646 746 * @ticket 10377 747 * 748 * @covers ::wp_handle_comment_submission 647 749 */ 648 750 public function test_submitting_comment_with_content_too_long_returns_error() { 649 751 $error = 'comment_content_column_length'; … … 662 764 663 765 /** 664 766 * @ticket 10377 767 * 768 * @covers ::wp_handle_comment_submission 665 769 */ 666 770 public function test_submitting_comment_with_author_too_long_returns_error() { 667 771 $error = 'comment_author_column_length'; … … 680 784 681 785 /** 682 786 * @ticket 10377 787 * 788 * @covers ::wp_handle_comment_submission 683 789 */ 684 790 public function test_submitting_comment_with_email_too_long_returns_error() { 685 791 $error = 'comment_author_email_column_length'; … … 698 804 699 805 /** 700 806 * @ticket 10377 807 * 808 * @covers ::wp_handle_comment_submission 701 809 */ 702 810 public function test_submitting_comment_with_url_too_long_returns_error() { 703 811 $error = 'comment_author_url_column_length'; … … 717 825 718 826 /** 719 827 * @ticket 49236 828 * 829 * @covers ::wp_handle_comment_submission 720 830 */ 721 831 public function test_submitting_comment_with_empty_type_results_in_correct_type() { 722 832 $data = array( … … 736 846 737 847 /** 738 848 * @ticket 49236 849 * 850 * @covers ::wp_handle_comment_submission 739 851 */ 740 852 public function test_inserting_comment_with_empty_type_results_in_correct_type() { 741 853 $data = array( … … 756 868 757 869 /** 758 870 * @ticket 34997 871 * 872 * @covers ::wp_handle_comment_submission 759 873 */ 760 874 public function test_comment_submission_sends_all_expected_parameters_to_preprocess_comment_filter() { 761 875 … … 798 912 799 913 /** 800 914 * @ticket 36901 915 * 916 * @covers ::wp_handle_comment_submission 801 917 */ 802 918 public function test_submitting_duplicate_comments() { 803 919 $data = array( … … 814 930 815 931 /** 816 932 * @ticket 36901 933 * 934 * @covers ::wp_handle_comment_submission 817 935 */ 818 936 public function test_comments_flood() { 819 937 $data = array( … … 833 951 834 952 /** 835 953 * @ticket 36901 954 * 955 * @covers ::wp_handle_comment_submission 836 956 */ 837 957 public function test_comments_flood_user_is_admin() { 838 958 $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 * 443 * @covers ::wp_new_comment 444 */ 406 445 public function test_comment_field_lengths() { 407 446 $data = array( 408 447 'comment_post_ID' => self::$post_id, … … 424 463 425 464 /** 426 465 * @ticket 32566 466 * 467 * @covers ::wp_notify_moderator 427 468 */ 428 469 public function test_wp_notify_moderator_should_not_throw_notice_when_post_author_is_0() { 429 470 $p = self::factory()->post->create( … … 441 482 $this->assertTrue( wp_notify_moderator( $c ) ); 442 483 } 443 484 485 /** 486 * 487 * 488 * @covers ::wp_new_comment_notify_postauthor 489 */ 444 490 public function test_wp_new_comment_notify_postauthor_should_send_email_when_comment_is_approved() { 445 491 $c = self::factory()->comment->create( 446 492 array( … … 452 498 $this->assertTrue( $sent ); 453 499 } 454 500 501 /** 502 * 503 * 504 * @covers ::wp_new_comment_notify_postauthor 505 */ 455 506 public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_is_unapproved() { 456 507 $c = self::factory()->comment->create( 457 508 array( … … 466 517 467 518 /** 468 519 * @ticket 33587 520 * 521 * @covers ::wp_new_comment_notify_postauthor 469 522 */ 470 523 public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() { 471 524 $c = self::factory()->comment->create( … … 481 534 482 535 /** 483 536 * @ticket 35006 537 * 538 * @covers ::wp_new_comment_notify_postauthor 484 539 */ 485 540 public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_trashed() { 486 541 $c = self::factory()->comment->create( … … 496 551 497 552 /** 498 553 * @ticket 43805 554 * 555 * @covers ::wp_new_comment_notify_postauthor 499 556 */ 500 557 public function test_wp_new_comment_notify_postauthor_content_should_include_link_to_parent() { 501 558 $c1 = self::factory()->comment->create( … … 520 577 521 578 /** 522 579 * @ticket 43805 580 * 581 * @covers ::wp_new_comment_notify_moderator 523 582 */ 524 583 public function test_wp_new_comment_notify_moderator_content_should_include_link_to_parent() { 525 584 $c1 = self::factory()->comment->create( … … 556 615 557 616 /** 558 617 * @ticket 12431 618 * 619 * @covers ::get_comment_meta 559 620 */ 560 621 public function test_wp_new_comment_with_meta() { 561 622 $c = self::factory()->comment->create( … … 573 634 574 635 /** 575 636 * @ticket 8071 637 * 638 * @covers WP_Comment::get_children 576 639 */ 577 640 public function test_wp_comment_get_children_should_fill_children() { 578 641 $c1 = self::factory()->comment->create( … … 633 696 634 697 /** 635 698 * @ticket 27571 699 * 700 * @covers ::get_comment 636 701 */ 637 702 public function test_post_properties_should_be_lazyloaded() { 638 703 $c = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); … … 684 749 685 750 /** 686 751 * @ticket 761 752 * 753 * @covers ::wp_new_comment 687 754 */ 688 755 public function test_wp_notify_moderator_filter_moderation_notify_option_true_filter_false() { 689 756 $comment_data = $this->setup_notify_comment(); … … 705 772 706 773 /** 707 774 * @ticket 761 775 * 776 * @covers ::wp_new_comment 708 777 */ 709 778 public function test_wp_notify_moderator_filter_moderation_notify_option_false_filter_true() { 710 779 $comment_data = $this->setup_notify_comment(); … … 726 795 727 796 /** 728 797 * @ticket 761 798 * 799 * @covers ::wp_new_comment 729 800 */ 730 801 public function test_wp_notify_post_author_filter_comments_notify_option_true_filter_false() { 731 802 … … 748 819 749 820 /** 750 821 * @ticket 761 822 * 823 * @covers ::wp_new_comment 751 824 */ 752 825 public function test_wp_notify_post_author_filter_comments_notify_option_false_filter_true() { 753 826 $comment_data = $this->setup_notify_comment(); … … 852 925 return $email_sent_when_comment_approved || $email_sent_when_comment_added; 853 926 } 854 927 928 /** 929 * 930 * 931 * @covers ::_close_comments_for_old_post 932 */ 855 933 public function test_close_comments_for_old_post() { 856 934 update_option( 'close_comments_for_old_posts', true ); 857 935 // Close comments more than one day old. … … 867 945 $this->assertTrue( $new_post_comment_status ); 868 946 } 869 947 948 /** 949 * 950 * 951 * @covers ::_close_comments_for_old_post 952 */ 870 953 public function test_close_comments_for_old_post_undated_draft() { 871 954 $draft_id = self::factory()->post->create( 872 955 array( … … 881 964 882 965 /** 883 966 * @ticket 35276 967 * 968 * @covers ::wp_update_comment 884 969 */ 885 970 public function test_wp_update_comment_author_id_and_agent() { 886 971 … … 917 1002 $this->assertSame( 'SHIELD_AGENT', $updated->comment_agent ); 918 1003 } 919 1004 1005 /** 1006 * 1007 * @covers ::wp_get_comment_fields_max_lengths 1008 */ 920 1009 public function test_wp_get_comment_fields_max_lengths() { 921 1010 $expected = array( 922 1011 'comment_author' => 245, … … 937 1026 * 938 1027 * @group privacy 939 1028 * @ticket 43442 1029 * 1030 * @covers ::wp_comments_personal_data_eraser 940 1031 */ 941 1032 public function test_wp_comments_personal_data_eraser() { 942 1033 … … 994 1085 * 995 1086 * @group privacy 996 1087 * @ticket 43442 1088 * 1089 * @covers ::wp_comments_personal_data_eraser 997 1090 */ 998 1091 public function test_wp_comments_personal_data_eraser_empty_first_page_output() { 999 1092 … … 1013 1106 * 1014 1107 * @group privacy 1015 1108 * @ticket 43442 1109 * 1110 * @covers ::wp_comments_personal_data_eraser 1016 1111 */ 1017 1112 public function test_wp_comments_personal_data_eraser_non_empty_first_page_output() { 1018 1113 … … 1045 1140 * 1046 1141 * @group privacy 1047 1142 * @ticket 43442 1143 * 1144 * @covers ::wp_comments_personal_data_eraser 1048 1145 */ 1049 1146 public function test_wp_comments_personal_data_eraser_empty_second_page_output() { 1050 1147 … … 1077 1174 * 1078 1175 * @group privacy 1079 1176 * @ticket 43442 1177 * 1178 * @covers ::wp_comments_personal_data_eraser 1080 1179 */ 1081 1180 public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization() { 1082 1181 … … 1114 1213 * 1115 1214 * @group privacy 1116 1215 * @ticket 43442 1216 * 1217 * @covers ::wp_comments_personal_data_eraser 1117 1218 */ 1118 1219 public function test_wp_anonymize_comment_filter_to_prevent_comment_anonymization_with_custom_message() { 1119 1220 … … 1179 1280 $this->assertSame( 'Bar', $comment->comment_author ); 1180 1281 } 1181 1282 1283 /** 1284 * 1285 * 1286 * @covers ::wp_trash_comment 1287 */ 1182 1288 public function test_trash_should_invalidate_comment_cache() { 1183 1289 global $wpdb; 1184 1290 … … 1193 1299 $this->assertSame( 'trash', $comment->comment_approved ); 1194 1300 } 1195 1301 1302 /** 1303 * 1304 * 1305 * @covers ::wp_untrash_comment 1306 */ 1196 1307 public function test_untrash_should_invalidate_comment_cache() { 1197 1308 global $wpdb; 1198 1309 … … 1209 1320 $this->assertSame( '1', $comment->comment_approved ); 1210 1321 } 1211 1322 1323 /** 1324 * 1325 * 1326 * @covers ::wp_spam_comment 1327 */ 1212 1328 public function test_spam_should_invalidate_comment_cache() { 1213 1329 global $wpdb; 1214 1330 … … 1223 1339 $this->assertSame( 'spam', $comment->comment_approved ); 1224 1340 } 1225 1341 1342 /** 1343 * 1344 * 1345 * @covers ::wp_unspam_comment 1346 */ 1226 1347 public function test_unspam_should_invalidate_comment_cache() { 1227 1348 global $wpdb; 1228 1349 … … 1244 1365 * 1245 1366 * @group privacy 1246 1367 * @ticket 43440 1368 * 1369 * @covers ::wp_comments_personal_data_exporter 1247 1370 */ 1248 1371 public function test_wp_comments_personal_data_exporter() { 1249 1372 $args = array( … … 1290 1413 * 1291 1414 * @group privacy 1292 1415 * @ticket 43440 1416 * 1417 * @covers ::wp_comments_personal_data_exporter 1293 1418 */ 1294 1419 public function test_wp_comments_personal_data_exporter_no_comments_found() { 1295 1420 … … 1308 1433 * 1309 1434 * @group privacy 1310 1435 * @ticket 43440 1436 * 1437 * @covers ::wp_comments_personal_data_exporter 1311 1438 */ 1312 1439 public function test_wp_comments_personal_data_exporter_empty_comment_prop() { 1313 1440 $args = array( … … 1339 1466 * 1340 1467 * @group privacy 1341 1468 * @ticket 43440 1469 * 1470 * @covers ::wp_comments_personal_data_exporter 1342 1471 */ 1343 1472 public function test_wp_comments_personal_data_exporter_empty_second_page() { 1344 1473 $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 * 230 239 */ 231 240 function test_wpdb_supposedly_protected_properties() { 232 241 global $wpdb; … … 243 252 244 253 /** 245 254 * @ticket 21212 255 * 246 256 */ 247 257 function test_wpdb_actually_protected_properties() { 248 258 global $wpdb; … … 274 284 * Test that an escaped %%f is not altered 275 285 * 276 286 * @ticket 19861 287 * 288 * @covers wpdb::placeholder_escape 289 * @covers wpdb::remove_placeholder_escape 277 290 */ 278 291 public function test_double_escaped_placeholders() { 279 292 global $wpdb; … … 289 302 * Test that SQL modes are set correctly 290 303 * 291 304 * @ticket 26847 305 * 306 * @covers wpdb::set_sql_mode 292 307 */ 293 308 function test_set_sql_mode() { 294 309 global $wpdb; … … 309 324 * Test that incompatible SQL modes are blocked 310 325 * 311 326 * @ticket 26847 327 * 328 * @covers wpdb::set_sql_mode 312 329 */ 313 330 function test_set_incompatible_sql_mode() { 314 331 global $wpdb; … … 327 344 * Test that incompatible SQL modes can be changed 328 345 * 329 346 * @ticket 26847 347 * 348 * @covers wpdb::set_sql_mode 330 349 */ 331 350 function test_set_allowed_incompatible_sql_mode() { 332 351 global $wpdb; … … 360 379 /** 361 380 * @ticket 25604 362 381 * @expectedIncorrectUsage wpdb::prepare 382 * 383 * @covers wpdb::prepare 363 384 */ 364 385 function test_prepare_without_arguments() { 365 386 global $wpdb; … … 370 391 $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0", $prepared ); 371 392 } 372 393 394 /** 395 * 396 * @covers wpdb::prepare 397 */ 373 398 function test_prepare_sprintf() { 374 399 global $wpdb; 375 400 … … 379 404 380 405 /** 381 406 * @expectedIncorrectUsage wpdb::prepare 407 * 408 * @covers wpdb::prepare 382 409 */ 383 410 function test_prepare_sprintf_invalid_args() { 384 411 global $wpdb; … … 392 419 $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared ); 393 420 } 394 421 422 /** 423 * 424 * @covers wpdb::prepare 425 */ 395 426 function test_prepare_vsprintf() { 396 427 global $wpdb; 397 428 … … 401 432 402 433 /** 403 434 * @expectedIncorrectUsage wpdb::prepare 435 * 436 * @covers wpdb::prepare 404 437 */ 405 438 function test_prepare_vsprintf_invalid_args() { 406 439 global $wpdb; … … 418 451 * @ticket 42040 419 452 * @dataProvider data_prepare_incorrect_arg_count 420 453 * @expectedIncorrectUsage wpdb::prepare 454 * 455 * @covers wpdb::prepare 421 456 */ 422 457 public function test_prepare_incorrect_arg_count( $query, $args, $expected ) { 423 458 global $wpdb; … … 479 514 ); 480 515 } 481 516 517 /** 518 * 519 * @covers wpdb::db_version 520 */ 482 521 function test_db_version() { 483 522 global $wpdb; 484 523 485 524 $this->assertTrue( version_compare( $wpdb->db_version(), '5.0', '>=' ) ); 486 525 } 487 526 /** 527 * 528 * @covers wpdb::get_caller 529 */ 488 530 function test_get_caller() { 489 531 global $wpdb; 490 532 $str = $wpdb->get_caller(); … … 493 535 $this->assertEquals( $called, end( $calls ) ); 494 536 } 495 537 538 /** 539 * 540 * @covers wpdb::has_cap 541 */ 496 542 function test_has_cap() { 497 543 global $wpdb; 498 544 $this->assertTrue( $wpdb->has_cap( 'collation' ) ); … … 513 559 514 560 /** 515 561 * @expectedDeprecated supports_collation 562 * 563 * @covers wpdb::supports_collation 516 564 */ 517 565 function test_supports_collation() { 518 566 global $wpdb; … … 519 567 $this->assertTrue( $wpdb->supports_collation() ); 520 568 } 521 569 570 /** 571 * 572 * @covers wpdb::check_database_version 573 */ 522 574 function test_check_database_version() { 523 575 global $wpdb; 524 576 $this->assertEmpty( $wpdb->check_database_version() ); … … 526 578 527 579 /** 528 580 * @expectedException WPDieException 581 * 582 * @covers wpdb::bail 529 583 */ 530 584 function test_bail() { 531 585 global $wpdb; 532 586 $wpdb->bail( 'Database is dead.' ); 533 587 } 534 588 /** 589 * 590 * @covers wpdb::timer_start 591 * @covers wpdb::timer_stop 592 */ 535 593 function test_timers() { 536 594 global $wpdb; 537 595 … … 542 600 $this->assertNotEquals( $wpdb->time_start, $stop ); 543 601 $this->assertGreaterThan( $stop, $wpdb->time_start ); 544 602 } 545 603 /** 604 * 605 * @covers wpdb::get_col_info 606 */ 546 607 function test_get_col_info() { 547 608 global $wpdb; 548 609 … … 552 613 $this->assertEquals( array( $wpdb->users ), $wpdb->get_col_info( 'table' ) ); 553 614 $this->assertEquals( $wpdb->users, $wpdb->get_col_info( 'table', 0 ) ); 554 615 } 555 616 /** 617 * 618 * @covers wpdb::query 619 * @covers wpdb::delete 620 */ 556 621 function test_query_and_delete() { 557 622 global $wpdb; 558 623 $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); … … 561 626 $d_rows = $wpdb->delete( $wpdb->users, array( 'ID' => $wpdb->insert_id ) ); 562 627 $this->assertEquals( 1, $d_rows ); 563 628 } 564 629 /** 630 * 631 * @covers wpdb::query 632 * @covers wpdb::get_row 633 */ 565 634 function test_get_row() { 566 635 global $wpdb; 567 636 $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); … … 584 653 * @dataProvider data_test_get_col 585 654 * 586 655 * @ticket 45299 656 * 657 * @covers wpdb::get_col 587 658 */ 588 659 function test_get_col( $query, $expected, $last_result, $column ) { 589 660 global $wpdb; … … 664 735 ); 665 736 } 666 737 738 /** 739 * 740 * @covers wpdb::replace 741 */ 667 742 function test_replace() { 668 743 global $wpdb; 669 744 $rows1 = $wpdb->insert( $wpdb->users, array( 'display_name' => 'Walter Sobchak' ) ); … … 691 766 * wpdb::update() requires a WHERE condition. 692 767 * 693 768 * @ticket 26106 769 * 770 * @covers wpdb::update 694 771 */ 695 772 function test_empty_where_on_update() { 696 773 global $wpdb; … … 713 790 * mysqli_ incorrect flush and further sync issues. 714 791 * 715 792 * @ticket 28155 793 * 716 794 */ 717 795 function test_mysqli_flush_sync() { 718 796 global $wpdb; … … 873 951 /** 874 952 * @dataProvider data_get_table_from_query 875 953 * @ticket 21212 954 * 955 * @covers wpdb::get_table_from_query 876 956 */ 877 957 function test_get_table_from_query( $query, $table ) { 878 958 $this->assertEquals( $table, self::$_wpdb->get_table_from_query( $query ) ); … … 888 968 /** 889 969 * @dataProvider data_get_table_from_query_false 890 970 * @ticket 21212 971 * 972 * @covers wpdb::get_table_from_query 891 973 */ 892 974 function test_get_table_from_query_false( $query ) { 893 975 $this->assertFalse( self::$_wpdb->get_table_from_query( $query ) ); … … 915 997 /** 916 998 * @dataProvider data_get_escaped_table_from_show_query 917 999 * @ticket 38751 1000 * 1001 * @covers wpdb::get_table_from_query 918 1002 */ 919 1003 function test_get_escaped_table_from_show_query( $query, $table ) { 920 1004 $this->assertEquals( $table, self::$_wpdb->get_table_from_query( $query ) ); … … 1030 1114 /** 1031 1115 * @dataProvider data_process_field_formats 1032 1116 * @ticket 21212 1117 * 1118 * @covers wpdb::process_field_formats 1033 1119 */ 1034 1120 function test_process_field_formats( $data, $format, $expected, $message ) { 1035 1121 $actual = self::$_wpdb->process_field_formats( $data, $format ); … … 1038 1124 1039 1125 /** 1040 1126 * @ticket 21212 1127 * 1128 * @covers wpdb::process_fields 1041 1129 */ 1042 1130 function test_process_fields() { 1043 1131 global $wpdb; … … 1068 1156 /** 1069 1157 * @ticket 21212 1070 1158 * @depends test_process_fields 1159 * 1160 * @covers wpdb::process_fields 1071 1161 */ 1072 1162 function test_process_fields_on_nonexistent_table( $data ) { 1073 1163 self::$_wpdb->suppress_errors( true ); … … 1078 1168 1079 1169 /** 1080 1170 * @ticket 21212 1171 * 1172 * @covers wpdb::get_table_charset 1081 1173 */ 1082 1174 function test_pre_get_table_charset_filter() { 1083 1175 add_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10, 2 ); … … 1092 1184 1093 1185 /** 1094 1186 * @ticket 21212 1187 * 1188 * @covers wpdb::get_col_charset 1095 1189 */ 1096 1190 function test_pre_get_col_charset_filter() { 1097 1191 add_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10, 3 ); … … 1106 1200 1107 1201 /** 1108 1202 * @ticket 15158 1203 * 1204 * @covers wpdb::insert 1109 1205 */ 1110 1206 function test_null_insert() { 1111 1207 global $wpdb; … … 1128 1224 1129 1225 /** 1130 1226 * @ticket 15158 1227 * 1228 * @covers wpdb::insert 1131 1229 */ 1132 1230 function test_null_update_value() { 1133 1231 global $wpdb; … … 1166 1264 1167 1265 /** 1168 1266 * @ticket 15158 1267 * 1268 * @covers wpdb::update 1169 1269 */ 1170 1270 function test_null_update_where() { 1171 1271 global $wpdb; … … 1204 1304 1205 1305 /** 1206 1306 * @ticket 15158 1307 * 1308 * @covers wpdb::delete 1207 1309 */ 1208 1310 function test_null_delete() { 1209 1311 global $wpdb; … … 1240 1342 1241 1343 /** 1242 1344 * @ticket 34903 1345 * 1346 * @covers wpdb::close 1243 1347 */ 1244 1348 function test_close() { 1245 1349 global $wpdb; … … 1259 1363 1260 1364 /** 1261 1365 * @ticket 36917 1366 * 1367 * @covers wpdb::determine_charset 1262 1368 */ 1263 1369 function test_charset_not_determined_when_disconnected() { 1264 1370 global $wpdb; … … 1277 1383 1278 1384 /** 1279 1385 * @ticket 36917 1386 * 1387 * @covers wpdb::determine_charset 1280 1388 */ 1281 1389 function test_charset_switched_to_utf8mb4() { 1282 1390 global $wpdb; … … 1296 1404 /** 1297 1405 * @ticket 32105 1298 1406 * @ticket 36917 1407 * 1408 * @covers wpdb::determine_charset 1299 1409 */ 1300 1410 function test_collate_switched_to_utf8mb4_520() { 1301 1411 global $wpdb; … … 1315 1425 /** 1316 1426 * @ticket 32405 1317 1427 * @ticket 36917 1428 * 1429 * @covers wpdb::determine_charset 1318 1430 */ 1319 1431 function test_non_unicode_collations() { 1320 1432 global $wpdb; … … 1333 1445 1334 1446 /** 1335 1447 * @ticket 37982 1448 * 1449 * @covers wpdb::determine_charset 1336 1450 */ 1337 1451 function test_charset_switched_to_utf8() { 1338 1452 global $wpdb; … … 1352 1466 1353 1467 /** 1354 1468 * @dataProvider data_prepare_with_placeholders 1469 * 1470 * @covers wpdb::prepare 1355 1471 */ 1356 1472 function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) { 1357 1473 global $wpdb; … … 1371 1487 1372 1488 /** 1373 1489 * @dataProvider data_prepare_with_placeholders 1490 * 1491 * @covers wpdb::prepare 1374 1492 */ 1375 1493 function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) { 1376 1494 global $wpdb; … … 1565 1683 1566 1684 /** 1567 1685 * @dataProvider data_escape_and_prepare 1686 * 1687 * @covers esc_sql 1568 1688 */ 1569 1689 function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) { 1570 1690 global $wpdb; … … 1612 1732 1613 1733 /** 1614 1734 * @expectedIncorrectUsage wpdb::prepare 1735 * 1736 * @covers wpdb::prepare 1615 1737 */ 1616 1738 function test_double_prepare() { 1617 1739 global $wpdb; … … 1623 1745 $this->assertNull( $query ); 1624 1746 } 1625 1747 1748 /** 1749 * 1750 * @covers wpdb::prepare 1751 */ 1626 1752 function test_prepare_numeric_placeholders_float_args() { 1627 1753 global $wpdb; 1628 1754 … … 1638 1764 $this->assertContains( ' second=2.2', $actual ); 1639 1765 } 1640 1766 1767 /** 1768 * 1769 * @covers wpdb::prepare 1770 */ 1641 1771 function test_prepare_numeric_placeholders_float_array() { 1642 1772 global $wpdb; 1643 1773 … … 1652 1782 $this->assertContains( ' second=2.2', $actual ); 1653 1783 } 1654 1784 1785 /** 1786 * 1787 * @covers wpdb::prepare 1788 */ 1655 1789 function test_query_unescapes_placeholders() { 1656 1790 global $wpdb; 1657 1791 … … 1671 1805 $this->assertEquals( $value, $actual ); 1672 1806 } 1673 1807 1808 /** 1809 * 1810 * @covers wpdb::placeholder_escape 1811 */ 1674 1812 function test_esc_sql_with_unsupported_placeholder_type() { 1675 1813 global $wpdb; 1676 1814 … … 1684 1822 /** 1685 1823 * @dataProvider parse_db_host_data_provider 1686 1824 * @ticket 41722 1825 * 1826 * @covers wpdb:: 1827 * 1828 * @covers wpdb::600179 1687 1829 */ 1688 1830 public function test_parse_db_host( $host_string, $expect_bail, $host, $port, $socket, $is_ipv6 ) { 1689 1831 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 * 12 * @covers ::add_filter 13 */ 10 14 function test_simple_filter() { 11 15 $a = new MockAction(); 12 16 $tag = __FUNCTION__; … … 25 29 $this->assertEquals( array( $val ), $args ); 26 30 } 27 31 32 /** 33 * 34 * @covers ::remove_filter 35 */ 28 36 function test_remove_filter() { 29 37 $a = new MockAction(); 30 38 $tag = __FUNCTION__; … … 45 53 46 54 } 47 55 56 /** 57 * 58 * @covers ::has_filter 59 */ 48 60 function test_has_filter() { 49 61 $tag = __FUNCTION__; 50 62 $func = __FUNCTION__ . '_func'; … … 59 71 $this->assertFalse( has_filter( $tag ) ); 60 72 } 61 73 62 // One tag with multiple filters. 74 /** 75 * One tag with multiple filters. 76 * 77 * @covers ::add_filter 78 */ 63 79 function test_multiple_filters() { 64 80 $a1 = new MockAction(); 65 81 $a2 = new MockAction(); … … 77 93 $this->assertEquals( 1, $a2->get_call_count() ); 78 94 } 79 95 96 /** 97 * One tag with multiple filters. 98 * 99 * @covers ::add_filter 100 */ 80 101 function test_filter_args_1() { 81 102 $a = new MockAction(); 82 103 $tag = __FUNCTION__; … … 92 113 $this->assertEquals( array( $val, $arg1 ), array_pop( $argsvar ) ); 93 114 } 94 115 116 /** 117 * One tag with multiple filters. 118 * 119 * @covers ::add_filter 120 */ 95 121 function test_filter_args_2() { 96 122 $a1 = new MockAction(); 97 123 $a2 = new MockAction(); … … 117 143 $this->assertEquals( array( $val ), array_pop( $argsvar2 ) ); 118 144 } 119 145 146 /** 147 * One tag with multiple filters. 148 * 149 * @covers ::add_filter 150 */ 120 151 function test_filter_priority() { 121 152 $a = new MockAction(); 122 153 $tag = __FUNCTION__; … … 148 179 $this->assertEquals( $expected, $a->get_events() ); 149 180 } 150 181 182 /** 183 * One tag with multiple filters. 184 * 185 * @covers ::add_filter 186 */ 151 187 function test_all_filter() { 152 188 $a = new MockAction(); 153 189 $tag1 = __FUNCTION__ . '_1'; … … 172 208 173 209 } 174 210 211 /** 212 * One tag with multiple filters. 213 * 214 * @covers ::add_filter 215 */ 175 216 function test_remove_all_filter() { 176 217 $a = new MockAction(); 177 218 $tag = __FUNCTION__; … … 198 239 199 240 /** 200 241 * @ticket 20920 242 * 243 * @covers ::add_filter 201 244 */ 202 245 function test_remove_all_filters_should_respect_the_priority_argument() { 203 246 $a = new MockAction(); … … 217 260 218 261 /** 219 262 * @ticket 9886 263 * 264 * @covers ::add_filter 220 265 */ 221 266 function test_filter_ref_array() { 222 267 $obj = new stdClass(); … … 236 281 237 282 /** 238 283 * @ticket 12723 284 * 285 * @covers ::add_filter 239 286 */ 240 287 function test_filter_ref_array_result() { 241 288 $obj = new stdClass(); … … 271 318 272 319 /** 273 320 * @ticket 29070 321 * 322 * @covers ::has_filter 274 323 */ 275 324 function test_has_filter_after_remove_all_filters() { 276 325 $a = new MockAction(); … … 298 347 /** 299 348 * @ticket 10441 300 349 * @expectedDeprecated tests_apply_filters_deprecated 350 * 351 * @covers ::apply_filters_deprecated 301 352 */ 302 353 public function test_apply_filters_deprecated() { 303 354 $p = 'Foo'; … … 317 368 /** 318 369 * @ticket 10441 319 370 * @expectedDeprecated tests_apply_filters_deprecated 371 * 372 * @covers ::apply_filters_deprecated 320 373 */ 321 374 public function test_apply_filters_deprecated_with_multiple_params() { 322 375 $p1 = 'Foo1'; … … 341 394 342 395 /** 343 396 * @ticket 10441 397 * 398 * @covers ::apply_filters_deprecated 344 399 */ 345 400 public function test_apply_filters_deprecated_without_filter() { 346 401 $val = 'Foobar'; … … 351 406 private $current_priority; 352 407 /** 353 408 * @ticket 39007 409 * 410 * @covers ::add_action 354 411 */ 355 412 public function test_current_priority() { 356 413 add_action( 'test_current_priority', array( $this, '_current_priority_action' ), 99 ); … … 360 417 $this->assertSame( 99, $this->current_priority ); 361 418 } 362 419 420 /** 421 * One tag with multiple filters. 422 * 423 */ 363 424 public function _current_priority_action() { 364 425 global $wp_filter; 365 426 $this->current_priority = $wp_filter[ current_filter() ]->current_priority(); … … 367 428 368 429 /** 369 430 * @ticket 39007 431 * 432 * @covers ::add_action 370 433 */ 371 434 public function test_other_priority() { 372 435 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->assertEquals( $non_pretty_permalink, get_permalink( $p ) );131 $this->assertEquals( $non_pretty_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 * @covers PHPMailer\PHPMailer::validateAddress 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 * 51 * @covers ::add_shortcode 52 */ 49 53 function test_img_caption_shortcode_added() { 50 54 global $shortcode_tags; 51 55 $this->assertEquals( 'img_caption_shortcode', $shortcode_tags['caption'] ); … … 52 56 $this->assertEquals( 'img_caption_shortcode', $shortcode_tags['wp_caption'] ); 53 57 } 54 58 59 /** 60 * 61 * @covers ::img_caption_shortcode 62 */ 55 63 function test_img_caption_shortcode_with_empty_params() { 56 64 $result = img_caption_shortcode( array() ); 57 65 $this->assertNull( $result ); … … 59 67 60 68 /** 61 69 * @ticket 33981 70 * 71 * @covers ::img_caption_shortcode 62 72 */ 63 73 function test_img_caption_shortcode_with_empty_params_but_content() { 64 74 $result = img_caption_shortcode( array(), $this->caption ); … … 67 77 68 78 /** 69 79 * @ticket 33981 80 * 81 * @covers ::img_caption_shortcode 70 82 */ 71 83 function test_img_caption_shortcode_short_circuit_filter() { 72 84 add_filter( 'img_caption_shortcode', array( $this, '_return_alt_caption' ) ); … … 84 96 85 97 /** 86 98 * @ticket 33981 99 * 100 * @covers ::img_caption_shortcode 87 101 */ 88 102 function test_img_caption_shortcode_empty_width() { 89 103 $result = img_caption_shortcode( … … 97 111 98 112 /** 99 113 * @ticket 33981 114 * 115 * @covers ::img_caption_shortcode 100 116 */ 101 117 function test_img_caption_shortcode_empty_caption() { 102 118 $result = img_caption_shortcode( … … 109 125 110 126 /** 111 127 * @ticket 33981 128 * 129 * @covers ::img_caption_shortcode 112 130 */ 113 131 function test_img_caption_shortcode_empty_caption_and_content() { 114 132 $result = img_caption_shortcode( … … 120 138 $this->assertEquals( $this->caption, $result ); 121 139 } 122 140 141 /** 142 * 143 * @covers ::img_caption_shortcode 144 */ 123 145 function test_img_caption_shortcode_with_old_format() { 124 146 $result = img_caption_shortcode( 125 147 array( … … 139 161 } 140 162 } 141 163 164 /** 165 * 166 * @covers ::img_caption_shortcode 167 */ 142 168 function test_img_caption_shortcode_with_old_format_id_and_align() { 143 169 $result = img_caption_shortcode( 144 170 array( … … 153 179 $this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); 154 180 } 155 181 182 /** 183 * 184 * @covers ::img_caption_shortcode 185 */ 156 186 function test_img_caption_shortcode_with_old_format_and_class() { 157 187 $result = img_caption_shortcode( 158 188 array( … … 165 195 166 196 } 167 197 198 /** 199 * 200 * @covers ::img_caption_shortcode 201 */ 168 202 function test_new_img_caption_shortcode_with_html_caption() { 169 203 $result = img_caption_shortcode( 170 204 array( … … 177 211 $this->assertEquals( 1, preg_match_all( "~{$our_preg}~", $result, $_r ) ); 178 212 } 179 213 214 /** 215 * 216 * @covers ::img_caption_shortcode 217 */ 180 218 function test_new_img_caption_shortcode_new_format() { 181 219 $result = img_caption_shortcode( 182 220 array( 'width' => 20 ), … … 189 227 $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); 190 228 } 191 229 230 /** 231 * 232 * @covers ::img_caption_shortcode 233 */ 192 234 function test_new_img_caption_shortcode_new_format_and_linked_image() { 193 235 $linked_image = "<a href='#'>{$this->img_content}</a>"; 194 236 $result = img_caption_shortcode( … … 202 244 $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); 203 245 } 204 246 247 /** 248 * 249 * @covers ::img_caption_shortcode 250 */ 205 251 function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() { 206 252 $linked_image = "<a href='#'>{$this->img_content}</a>"; 207 253 $result = img_caption_shortcode( … … 217 263 218 264 /** 219 265 * @ticket 34595 266 * 267 * @covers ::img_caption_shortcode 220 268 */ 221 269 function test_img_caption_shortcode_has_aria_describedby() { 222 270 $result = img_caption_shortcode( … … 230 278 $this->assertEquals( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) ); 231 279 } 232 280 281 /** 282 * 283 * @covers ::wp_oembed_remove_provider 284 */ 233 285 function test_add_remove_oembed_provider() { 234 286 wp_oembed_add_provider( 'http://foo.bar/*', 'http://foo.bar/oembed' ); 235 287 $this->assertTrue( wp_oembed_remove_provider( 'http://foo.bar/*' ) ); … … 238 290 239 291 /** 240 292 * @ticket 23776 293 * 294 * @covers WP_Embed::autoembed 241 295 */ 242 296 function test_autoembed_empty() { 243 297 global $wp_embed; … … 250 304 251 305 /** 252 306 * @ticket 23776 307 * 308 * @covers WP_Embed::autoembed 253 309 */ 254 310 function test_autoembed_no_paragraphs_around_urls() { 255 311 global $wp_embed; … … 329 385 330 386 /** 331 387 * @dataProvider data_autoembed 388 * 389 * @covers WP_Embed::autoembed 332 390 */ 333 391 function test_autoembed( $content, $result = null ) { 334 392 $wp_embed = new Test_Autoembed; … … 336 394 $this->assertEquals( $wp_embed->autoembed( $content ), $result ? $result : $content ); 337 395 } 338 396 397 /** 398 * 399 * @covers ::wp_prepare_attachment_for_js 400 */ 339 401 function test_wp_prepare_attachment_for_js() { 340 402 // Attachment without media. 341 403 $id = wp_insert_attachment( … … 389 451 390 452 /** 391 453 * @ticket 38965 454 * 455 * @covers ::wp_prepare_attachment_for_js 392 456 */ 393 457 function test_wp_prepare_attachment_for_js_without_image_sizes() { 394 458 // Create the attachement post. … … 420 484 /** 421 485 * @ticket 19067 422 486 * @expectedDeprecated wp_convert_bytes_to_hr 487 * 488 * @covers ::wp_convert_bytes_to_hr 489 * @covers ::size_format 423 490 */ 424 491 function test_wp_convert_bytes_to_hr() { 425 492 $kb = 1024; … … 452 519 $this->assertEquals( 1022.99902344, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 ); 453 520 454 521 // Edge. 455 $this->assertEquals( '-1B', wp_convert_byt es_to_hr( -1 ) );522 $this->assertEquals( '-1B', wp_convert_bytWP_Embedes_to_hr( -1 ) ); 456 523 $this->assertEquals( '0B', wp_convert_bytes_to_hr( 0 ) ); 457 524 } 458 525 459 526 /** 460 527 * @ticket 22960 528 * 529 * @covers ::get_attached_media 461 530 */ 462 531 function test_get_attached_images() { 463 532 $post_id = self::factory()->post->create(); … … 476 545 477 546 /** 478 547 * @ticket 22960 548 * 549 * @covers ::wp_update_attachment_metadata 479 550 */ 480 551 function test_post_galleries_images() { 481 552 $ids1 = array(); … … 527 598 528 599 /** 529 600 * @ticket 39304 601 * 602 * @covers ::get_post_galleries 530 603 */ 531 604 function test_post_galleries_images_without_global_post() { 532 605 // Set up an unattached image. … … 552 625 553 626 /** 554 627 * @ticket 39304 628 * 629 * @covers ::get_post_galleries 555 630 */ 556 631 function test_post_galleries_ignores_global_post() { 557 632 $global_post_id = $this->factory->post->create( … … 587 662 588 663 /** 589 664 * @ticket 39304 665 * 666 * @covers ::get_post_galleries 590 667 */ 591 668 function test_post_galleries_respects_id_attrs() { 592 669 $post_id = $this->factory->post->create( … … 626 703 627 704 /** 628 705 * @ticket 22960 706 * 707 * @covers ::get_post_gallery_images 629 708 */ 630 709 function test_post_gallery_images() { 631 710 $ids1 = array(); … … 675 754 $this->assertEquals( $srcs, $ids1_srcs ); 676 755 } 677 756 757 /** 758 * 759 * @covers ::get_media_embedded_in_content 760 */ 678 761 function test_get_media_embedded_in_content() { 679 762 $object = <<<OBJ 680 763 <object src="this" data="that"> … … 739 822 $this->assertEquals( $contents, $matches ); 740 823 } 741 824 825 /** 826 * 827 * @covers ::get_media_embedded_in_content 828 */ 742 829 function test_get_media_embedded_in_content_order() { 743 830 $audio = <<<AUDIO 744 831 <audio preload="none"> … … 769 856 770 857 /** 771 858 * @ticket 35367 859 * 860 * @covers ::wp_audio_shortcode 772 861 */ 773 862 function test_wp_audio_shortcode_with_bad_attr() { 774 863 $this->assertSame( … … 783 872 784 873 /** 785 874 * @ticket 35367 875 * 876 * @covers ::wp_audio_shortcode 786 877 */ 787 878 function test_wp_audio_shortcode_attributes() { 788 879 $actual = wp_audio_shortcode( … … 819 910 820 911 /** 821 912 * Test [video] shortcode processing 913 * 914 * @covers ::wp_video_shortcode 822 915 */ 823 916 function test_video_shortcode_body() { 824 917 $width = 720; … … 865 958 /** 866 959 * @ticket 35367 867 960 * @depends test_video_shortcode_body 961 * 962 * @covers ::wp_video_shortcode 868 963 */ 869 964 function test_wp_video_shortcode_with_empty_params() { 870 965 $this->assertNull( wp_video_shortcode( array() ) ); … … 873 968 /** 874 969 * @ticket 35367 875 970 * @depends test_video_shortcode_body 971 * 972 * @covers ::wp_video_shortcode 876 973 */ 877 974 function test_wp_video_shortcode_with_bad_attr() { 878 975 $this->assertSame( … … 888 985 /** 889 986 * @ticket 35367 890 987 * @depends test_video_shortcode_body 988 * 989 * @covers ::wp_video_shortcode 891 990 */ 892 991 function test_wp_video_shortcode_attributes() { 893 992 $actual = wp_video_shortcode( … … 930 1029 /** 931 1030 * @ticket 40866 932 1031 * @depends test_video_shortcode_body 1032 * 1033 * @covers ::wp_video_shortcode 933 1034 */ 934 1035 function test_wp_video_shortcode_youtube_remove_feature() { 935 1036 $actual = wp_video_shortcode( … … 944 1045 /** 945 1046 * @ticket 40866 946 1047 * @depends test_video_shortcode_body 1048 * 1049 * @covers ::wp_video_shortcode 947 1050 */ 948 1051 function test_wp_video_shortcode_youtube_force_ssl() { 949 1052 $actual = wp_video_shortcode( … … 958 1061 /** 959 1062 * @ticket 40866 960 1063 * @depends test_video_shortcode_body 1064 * 1065 * @covers ::wp_video_shortcode 961 1066 */ 962 1067 function test_wp_video_shortcode_vimeo_force_ssl_remove_query_args() { 963 1068 $actual = wp_video_shortcode( … … 973 1078 /** 974 1079 * @ticket 40977 975 1080 * @depends test_video_shortcode_body 1081 * 1082 * @covers ::wp_video_shortcode 976 1083 */ 977 1084 function test_wp_video_shortcode_vimeo_adds_loop() { 978 1085 $actual = wp_video_shortcode( … … 987 1094 /** 988 1095 * @ticket 40977 989 1096 * @depends test_video_shortcode_body 1097 * 1098 * @covers ::wp_video_shortcode 990 1099 */ 991 1100 function test_wp_video_shortcode_vimeo_force_adds_loop_true() { 992 1101 $actual = wp_video_shortcode( … … 1001 1110 1002 1111 /** 1003 1112 * @ticket 26768 1113 * 1114 * @covers ::add_image_size 1004 1115 */ 1005 1116 function test_add_image_size() { 1006 1117 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1022 1133 1023 1134 /** 1024 1135 * @ticket 26768 1136 * 1137 * @covers ::remove_image_size 1025 1138 */ 1026 1139 function test_remove_image_size() { 1027 1140 add_image_size( 'test-size', 200, 600 ); … … 1032 1145 1033 1146 /** 1034 1147 * @ticket 26951 1148 * 1149 * @covers ::has_image_size 1035 1150 */ 1036 1151 function test_has_image_size() { 1037 1152 add_image_size( 'test-size', 200, 600 ); … … 1043 1158 1044 1159 /** 1045 1160 * @ticket 30346 1161 * 1162 * @covers ::attachment_url_to_postid 1046 1163 */ 1047 1164 function test_attachment_url_to_postid() { 1048 1165 $image_path = '2014/11/' . $this->img_name; … … 1061 1178 1062 1179 /** 1063 1180 * @ticket 33109 1181 * 1182 * @covers ::attachment_url_to_postid 1064 1183 */ 1065 1184 function test_attachment_url_to_postid_with_different_scheme() { 1066 1185 $image_path = '2014/11/' . $this->img_name; … … 1079 1198 1080 1199 /** 1081 1200 * @ticket 39768 1201 * 1202 * @covers ::attachment_url_to_postid 1082 1203 */ 1083 1204 function test_attachment_url_to_postid_should_be_case_sensitive() { 1084 1205 $image_path_lower_case = '2014/11/' . $this->img_name; … … 1105 1226 $this->assertEquals( $attachment_id_upper_case, attachment_url_to_postid( $image_url ) ); 1106 1227 } 1107 1228 1229 /** 1230 * 1231 * @covers ::attachment_url_to_postid 1232 */ 1108 1233 function test_attachment_url_to_postid_filtered() { 1109 1234 $image_path = '2014/11/' . $this->img_name; 1110 1235 $attachment_id = self::factory()->attachment->create_object( … … 1129 1254 1130 1255 /** 1131 1256 * @ticket 31044 1257 * 1258 * @covers ::attachment_url_to_postid 1132 1259 */ 1133 1260 function test_attachment_url_to_postid_with_empty_url() { 1134 1261 $post_id = attachment_url_to_postid( '' ); … … 1138 1265 1139 1266 /** 1140 1267 * @ticket 22768 1268 * 1269 * @covers ::media_handle_upload 1141 1270 */ 1142 1271 public function test_media_handle_upload_sets_post_excerpt() { 1143 1272 $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg'; … … 1177 1306 1178 1307 /** 1179 1308 * @ticket 37989 1309 * 1310 * @covers ::media_handle_upload 1180 1311 */ 1181 1312 public function test_media_handle_upload_expected_titles() { 1182 1313 $test_file = DIR_TESTDATA . '/images/test-image.jpg'; … … 1216 1347 1217 1348 /** 1218 1349 * @ticket 33016 1350 * 1351 * @covers WP_Embed::autoembed 1219 1352 */ 1220 1353 function test_multiline_cdata() { 1221 1354 global $wp_embed; … … 1233 1366 1234 1367 /** 1235 1368 * @ticket 33016 1369 * 1370 * @covers WP_Embed::autoembed 1236 1371 */ 1237 1372 function test_multiline_comment() { 1238 1373 global $wp_embed; … … 1250 1385 1251 1386 /** 1252 1387 * @ticket 33016 1388 * 1389 * @covers WP_Embed::autoembed 1253 1390 */ 1254 1391 function test_multiline_comment_with_embeds() { 1255 1392 $content = <<<EOF … … 1293 1430 1294 1431 /** 1295 1432 * @ticket 33016 1433 * 1434 * @covers WP_Embed::autoembed 1296 1435 */ 1297 1436 function test_oembed_explicit_media_link() { 1298 1437 global $wp_embed; … … 1330 1469 * Tests the default output of `wp_get_attachment_image()`. 1331 1470 * 1332 1471 * @ticket 34635 1472 * 1473 * @covers ::wp_get_attachment_image 1333 1474 */ 1334 1475 function test_wp_get_attachment_image_defaults() { 1335 1476 $image = image_downsize( self::$large_id, 'thumbnail' ); … … 1347 1488 * Test that `wp_get_attachment_image()` returns a proper alt value. 1348 1489 * 1349 1490 * @ticket 34635 1491 * 1492 * @covers ::wp_get_attachment_image 1350 1493 */ 1351 1494 function test_wp_get_attachment_image_with_alt() { 1352 1495 // Add test alt metadata. … … 1368 1511 1369 1512 /** 1370 1513 * @ticket 33878 1514 * 1515 * @covers ::wp_get_attachment_image 1371 1516 */ 1372 1517 function test_wp_get_attachment_image_url() { 1373 1518 $this->assertFalse( wp_get_attachment_image_url( 0 ) ); … … 1389 1534 1390 1535 /** 1391 1536 * @ticket 12235 1537 * 1538 * @covers ::wp_get_attachment_caption 1392 1539 */ 1393 1540 function test_wp_get_attachment_caption() { 1394 $this->assertFalse( wp_get_attachment_caption( 0 ) );1541 $this->assertFalse( ( 0 ) ); 1395 1542 1396 1543 $caption = 'This is a caption.'; 1397 1544 … … 1413 1560 1414 1561 /** 1415 1562 * @ticket 12235 1563 * 1564 * @covers ::wp_get_attachment_caption 1416 1565 */ 1417 1566 function test_wp_get_attachment_caption_empty() { 1418 1567 $post_id = self::factory()->post->create(); … … 1463 1612 1464 1613 /** 1465 1614 * @ticket 33641 1615 * 1616 * @covers ::wp_calculate_image_srcset 1466 1617 */ 1467 1618 function test_wp_calculate_image_srcset() { 1468 1619 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1510 1661 1511 1662 /** 1512 1663 * @ticket 33641 1664 * 1665 * @covers ::wp_calculate_image_srcset 1513 1666 */ 1514 1667 function test_wp_calculate_image_srcset_no_date_uploads() { 1515 1668 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1566 1719 1567 1720 /** 1568 1721 * @ticket 33641 1722 * 1723 * @covers ::wp_calculate_image_srcset 1569 1724 */ 1570 1725 function test_wp_calculate_image_srcset_with_edits() { 1571 1726 // For this test we're going to mock metadata changes from an edit. … … 1599 1754 1600 1755 /** 1601 1756 * @ticket 35106 1757 * 1758 * @covers ::wp_calculate_image_srcset 1602 1759 */ 1603 1760 function test_wp_calculate_image_srcset_with_absolute_path_in_meta() { 1604 1761 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1650 1807 1651 1808 /** 1652 1809 * @ticket 33641 1810 * 1811 * @covers ::wp_calculate_image_srcset 1653 1812 */ 1654 1813 function test_wp_calculate_image_srcset_false() { 1655 1814 $sizes = wp_calculate_image_srcset( array( 400, 300 ), 'file.png', array() ); … … 1660 1819 1661 1820 /** 1662 1821 * @ticket 33641 1822 * 1823 * @covers ::wp_calculate_image_srcset 1663 1824 */ 1664 1825 function test_wp_calculate_image_srcset_no_width() { 1665 1826 $file = get_attached_file( self::$large_id ); … … 1677 1838 /** 1678 1839 * @ticket 34955 1679 1840 * @ticket 33641 1841 * 1842 * @covers ::wp_calculate_image_srcset 1680 1843 */ 1681 1844 function test_wp_calculate_image_srcset_ratio_variance() { 1682 1845 // Mock data for this test. … … 1726 1889 /** 1727 1890 * @ticket 35108 1728 1891 * @ticket 33641 1892 * 1893 * @covers ::wp_calculate_image_srcset 1729 1894 */ 1730 1895 function test_wp_calculate_image_srcset_include_src() { 1731 1896 // Mock data for this test. … … 1775 1940 1776 1941 /** 1777 1942 * @ticket 35480 1943 * 1944 * @covers ::wp_calculate_image_srcset 1778 1945 */ 1779 1946 function test_wp_calculate_image_srcset_corrupted_image_meta() { 1780 1947 $size_array = array( 300, 150 ); … … 1849 2016 /** 1850 2017 * @ticket 36549 1851 2018 * @ticket 33641 2019 * 2020 * @covers ::wp_calculate_image_srcset 1852 2021 */ 1853 2022 function test_wp_calculate_image_srcset_with_spaces_in_filenames() { 1854 2023 // Mock data for this test. … … 1896 2065 1897 2066 /** 1898 2067 * @ticket 33641 2068 * 2069 * @covers ::wp_calculate_image_srcset 1899 2070 */ 1900 2071 function test_wp_get_attachment_image_srcset() { 1901 2072 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); … … 1935 2106 1936 2107 /** 1937 2108 * @ticket 33641 2109 * 2110 * @covers ::wp_calculate_image_srcset 1938 2111 */ 1939 2112 function test_wp_get_attachment_image_srcset_single_srcset() { 1940 2113 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 1950 2123 1951 2124 /** 1952 2125 * @ticket 33641 2126 * 2127 * @covers ::wp_calculate_image_srcset 1953 2128 */ 1954 2129 function test_wp_get_attachment_image_srcset_invalidsize() { 1955 2130 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 1966 2141 1967 2142 /** 1968 2143 * @ticket 33641 2144 * 2145 * @covers ::wp_calculate_image_src 1969 2146 */ 1970 2147 function test_wp_get_attachment_image_sizes() { 1971 2148 // Test sizes against the default WP sizes. … … 1986 2163 1987 2164 /** 1988 2165 * @ticket 33641 2166 * 2167 * @covers ::wp_calculate_image_sizes 1989 2168 */ 1990 2169 function test_wp_calculate_image_sizes() { 1991 2170 // Test sizes against the default WP sizes. … … 2009 2188 2010 2189 /** 2011 2190 * @ticket 33641 2191 * 2192 * @covers ::wp_filter_content_tags 2012 2193 */ 2013 2194 function test_wp_filter_content_tags_srcset_sizes() { 2014 2195 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2099 2280 * 2100 2281 * @ticket 34898 2101 2282 * @ticket 33641 2283 * 2284 * @covers ::wp_filter_content_tags 2102 2285 */ 2103 2286 function test_wp_filter_content_tags_srcset_sizes_wrong() { 2104 2287 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); … … 2112 2295 2113 2296 /** 2114 2297 * @ticket 33641 2298 * 2299 * @covers ::wp_filter_content_tags 2115 2300 */ 2116 2301 function test_wp_filter_content_tags_srcset_sizes_with_preexisting_srcset() { 2117 2302 // Generate HTML and add a dummy srcset attribute. … … 2126 2311 /** 2127 2312 * @ticket 33641 2128 2313 * @ticket 34528 2314 * 2315 * @covers ::wp_calculate_image_srcset 2129 2316 */ 2130 2317 function test_wp_calculate_image_srcset_animated_gifs() { 2131 2318 // Mock meta for an animated gif. … … 2170 2357 /** 2171 2358 * @ticket 35045 2172 2359 * @ticket 33641 2360 * 2361 * @covers ::wp_filter_content_tags 2173 2362 */ 2174 2363 function test_wp_filter_content_tags_schemes() { 2175 2364 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2221 2410 /** 2222 2411 * @ticket 34945 2223 2412 * @ticket 33641 2413 * 2414 * @covers ::wp_calculate_image_srcset 2224 2415 */ 2225 2416 function test_wp_get_attachment_image_with_https_on() { 2226 2417 // Mock meta for the image. … … 2266 2457 2267 2458 /** 2268 2459 * @ticket 36084 2460 * 2461 * @covers :get_image_send_to_editor: 2269 2462 */ 2270 2463 function test_get_image_send_to_editor_defaults() { 2271 2464 $id = self::$large_id; … … 2286 2479 2287 2480 /** 2288 2481 * @ticket 36084 2482 * 2483 * @covers ::get_image_send_to_editor 2289 2484 */ 2290 2485 function test_get_image_send_to_editor_defaults_with_optional_params() { 2291 2486 $id = self::$large_id; … … 2310 2505 2311 2506 /** 2312 2507 * @ticket 36084 2508 * 2509 * @covers ::get_image_send_to_editor 2313 2510 */ 2314 2511 function test_get_image_send_to_editor_defaults_no_caption_no_rel() { 2315 2512 $id = self::$large_id; … … 2341 2538 * used in the output of `wp_get_attachment_image()`. 2342 2539 * 2343 2540 * @ticket 36246 2541 * 2542 * @covers ::wp_get_attachment_image 2344 2543 */ 2345 2544 function test_wp_get_attachment_image_should_use_wp_get_attachment_metadata() { 2346 2545 add_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ), 10, 2 ); … … 2376 2575 2377 2576 /** 2378 2577 * @ticket 37813 2578 * 2579 * @covers ::wp_insert_attachment 2379 2580 */ 2380 2581 public function test_return_type_when_inserting_attachment_with_error_in_data() { 2381 2582 $data = array( … … 2395 2596 2396 2597 /** 2397 2598 * @ticket 35218 2599 * 2600 * @covers ::wp_get_media_creation_timestamp 2398 2601 */ 2399 2602 function test_wp_get_media_creation_timestamp_video_asf() { 2400 2603 $metadata = array( … … 2411 2614 2412 2615 /** 2413 2616 * @ticket 35218 2617 * 2618 * @covers ::wp_get_media_creation_timestamp 2414 2619 */ 2415 2620 function test_wp_get_media_creation_timestamp_video_matroska() { 2416 2621 $metadata = array( … … 2429 2634 2430 2635 /** 2431 2636 * @ticket 35218 2637 * 2638 * @covers ::wp_get_media_creation_timestamp 2432 2639 */ 2433 2640 function test_wp_get_media_creation_timestamp_video_quicktime() { 2434 2641 $metadata = array( … … 2448 2655 } 2449 2656 2450 2657 /** 2451 * @ticket 35218 2658 * @ticket 2659 * 2660 * @covers ::wp_get_media_creation_timestamp 2452 2661 */ 2453 2662 function test_wp_get_media_creation_timestamp_video_webm() { 2454 2663 $metadata = array( … … 2472 2681 *`wp_read_audio_metadata()`. 2473 2682 * 2474 2683 * @ticket 42017 2684 * 2685 * @covers ::wp_read_audio_metadata 2475 2686 */ 2476 2687 function test_wp_read_audio_metadata_adds_creation_date_with_mp4() { 2477 2688 $video = DIR_TESTDATA . '/uploads/small-video.mp4'; … … 2482 2693 2483 2694 /** 2484 2695 * @ticket 35218 2696 * 2697 * @covers ::wp_read_video_metadata 2485 2698 */ 2486 2699 function test_wp_read_video_metadata_adds_creation_date_with_quicktime() { 2487 2700 $video = DIR_TESTDATA . '/uploads/small-video.mov'; … … 2492 2705 2493 2706 /** 2494 2707 * @ticket 35218 2708 * 2709 * @covers ::wp_read_video_metadata 2495 2710 */ 2496 2711 function test_wp_read_video_metadata_adds_creation_date_with_mp4() { 2497 2712 $video = DIR_TESTDATA . '/uploads/small-video.mp4'; … … 2502 2717 2503 2718 /** 2504 2719 * @ticket 35218 2720 * 2721 * @covers ::wp_read_video_metadata 2505 2722 */ 2506 2723 function test_wp_read_video_metadata_adds_creation_date_with_mkv() { 2507 2724 $video = DIR_TESTDATA . '/uploads/small-video.mkv'; … … 2512 2729 2513 2730 /** 2514 2731 * @ticket 35218 2732 * 2733 * @covers ::wp_read_video_metadata 2515 2734 */ 2516 2735 function test_wp_read_video_metadata_adds_creation_date_with_webm() { 2517 2736 $video = DIR_TESTDATA . '/uploads/small-video.webm'; … … 2522 2741 2523 2742 /** 2524 2743 * @ticket 10752 2744 * 2745 * @covers ::media_handle_upload 2525 2746 */ 2526 2747 public function test_media_handle_upload_uses_post_parent_for_directory_date() { 2527 2748 $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg'; … … 2568 2789 2569 2790 /** 2570 2791 * @ticket 10752 2792 * 2793 * @covers ::media_handle_upload 2571 2794 */ 2572 2795 public function test_media_handle_upload_ignores_page_parent_for_directory_date() { 2573 2796 $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg'; … … 2620 2843 2621 2844 /** 2622 2845 * @ticket 50367 2846 * 2847 * @covers ::wp_filter_content_tags 2623 2848 */ 2624 2849 function test_wp_filter_content_tags_width_height() { 2625 2850 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2665 2890 /** 2666 2891 * @ticket 44427 2667 2892 * @ticket 50367 2893 * 2894 * @covers ::wp_filter_content_tags 2668 2895 */ 2669 2896 function test_wp_filter_content_tags_loading_lazy() { 2670 2897 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2713 2940 2714 2941 /** 2715 2942 * @ticket 44427 2943 * 2944 * @covers ::wp_filter_content_tags 2716 2945 */ 2717 2946 function test_wp_filter_content_tags_loading_lazy_opted_in() { 2718 2947 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); … … 2738 2967 2739 2968 /** 2740 2969 * @ticket 44427 2970 * 2971 * @covers ::wp_filter_content_tags 2741 2972 */ 2742 2973 function test_wp_filter_content_tags_loading_lazy_opted_out() { 2743 2974 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); … … 2761 2992 /** 2762 2993 * @ticket 44427 2763 2994 * @ticket 50367 2995 * 2996 * @covers ::wp_img_tag_add_loading_attr 2764 2997 */ 2765 2998 function test_wp_img_tag_add_loading_attr() { 2766 2999 $img = '<img src="example.png" alt=" width="300" height="225" />'; … … 2772 3005 /** 2773 3006 * @ticket 44427 2774 3007 * @ticket 50367 3008 * 3009 * @covers ::wp_img_tag_add_loading_attr 2775 3010 */ 2776 3011 function test_wp_img_tag_add_loading_attr_without_src() { 2777 3012 $img = '<img alt=" width="300" height="225" />'; … … 2783 3018 /** 2784 3019 * @ticket 44427 2785 3020 * @ticket 50367 3021 * 3022 * @covers ::wp_img_tag_add_loading_attr 2786 3023 */ 2787 3024 function test_wp_img_tag_add_loading_attr_with_single_quotes() { 2788 3025 $img = "<img src='example.png' alt=' width='300' height='225' />"; … … 2798 3035 /** 2799 3036 * @ticket 44427 2800 3037 * @ticket 50425 3038 * 3039 * @covers ::wp_img_tag_add_loading_attr 2801 3040 */ 2802 3041 function test_wp_img_tag_add_loading_attr_opt_out() { 2803 3042 $img = '<img src="example.png" alt=" width="300" height="225" />'; … … 2809 3048 /** 2810 3049 * @ticket 44427 2811 3050 * @ticket 50425 3051 * 3052 * @covers ::wp_get_attachment_image 2812 3053 */ 2813 3054 function test_wp_get_attachment_image_loading() { 2814 3055 $img = wp_get_attachment_image( self::$large_id ); … … 2819 3060 /** 2820 3061 * @ticket 44427 2821 3062 * @ticket 50425 3063 * 3064 * @covers ::wp_get_attachment_image 2822 3065 */ 2823 3066 function test_wp_get_attachment_image_loading_opt_out() { 2824 3067 add_filter( 'wp_lazy_loading_enabled', '__return_false' ); … … 2831 3074 /** 2832 3075 * @ticket 44427 2833 3076 * @ticket 50425 3077 * 3078 * @covers ::wp_get_attachment_image 2834 3079 */ 2835 3080 function test_wp_get_attachment_image_loading_opt_out_individual() { 2836 3081 // The default is already tested above, the filter below ensures that … … 2850 3095 * 2851 3096 * @param string $tag_name Tag name. 2852 3097 * @param bool $expected Expected return value. 3098 * 3099 * @covers ::wp_lazy_loading_enabled 2853 3100 */ 2854 3101 function test_wp_lazy_loading_enabled_tag_name_defaults( $tag_name, $expected ) { 2855 3102 if ( $expected ) { … … 2873 3120 * 2874 3121 * @param string $context Function context. 2875 3122 * @param bool $expected Expected return value. 3123 * 3124 * @covers ::wp_lazy_loading_enabled 2876 3125 */ 2877 3126 function test_wp_lazy_loading_enabled_context_defaults( $context, $expected ) { 2878 3127 if ( $expected ) { … … 2895 3144 2896 3145 /** 2897 3146 * @ticket 50543 3147 * 3148 * @covers ::wp_image_file_matches_image_meta 2898 3149 */ 2899 3150 function test_wp_image_file_matches_image_meta() { 2900 3151 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2907 3158 2908 3159 /** 2909 3160 * @ticket 50543 3161 * 3162 * @covers ::wp_image_file_matches_image_meta 2910 3163 */ 2911 3164 function test_wp_image_file_matches_image_meta_no_subsizes() { 2912 3165 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2919 3172 2920 3173 /** 2921 3174 * @ticket 50543 3175 * 3176 * @covers ::wp_image_file_matches_image_meta 2922 3177 */ 2923 3178 function test_wp_image_file_matches_image_meta_invalid_meta() { 2924 3179 $image_meta = ''; // Attachment is not an image. … … 2929 3184 2930 3185 /** 2931 3186 * @ticket 50543 3187 * 3188 * @covers ::wp_image_file_matches_image_meta 2932 3189 */ 2933 3190 function test_wp_image_file_matches_image_meta_different_meta() { 2934 3191 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2939 3196 2940 3197 /** 2941 3198 * @ticket 50543 3199 * 3200 * @covers ::wp_image_file_matches_image_meta 2942 3201 */ 2943 3202 function test_wp_image_file_matches_image_meta_original_image() { 2944 3203 $image_meta = wp_get_attachment_metadata( self::$large_id ); … … 2949 3208 2950 3209 /** 2951 3210 * @ticket 22101 3211 * 3212 * @covers ::gallery_shortcode 2952 3213 */ 2953 3214 function test_gallery_shortcode_when_is_feed_true() { 2954 3215 -
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 * @covers ::wp_set_current_user 17 * @covers ::wp_get_current_user 18 * @covers ::get_userdata 19 * @covers ::get_user_by 20 * @covers ::cache_users 21 * @covers ::wp_mail 22 * @covers ::wp_authenticate 23 * @covers ::wp_logout 24 * @covers ::wp_validate_auth_cookie 25 * @covers ::wp_generate_auth_cookie 26 * @covers ::wp_parse_auth_cookie 27 * @covers ::wp_set_auth_cookie 28 * @covers ::wp_clear_auth_cookie 29 * @covers ::is_user_logged_in 30 * @covers ::auth_redirect 31 * @covers ::check_admin_referer 32 * @covers ::check_ajax_referer 33 * @covers ::wp_redirect 34 * @covers ::wp_sanitize_redirect 35 * @covers ::_wp_sanitize_utf8_in_redirect 36 * @covers ::wp_safe_redirect 37 * @covers ::wp_validate_redirect 38 * @covers ::wp_notify_postauthor 39 * @covers ::wp_notify_moderator 40 * @covers ::wp_password_change_notification 41 * @covers ::wp_new_user_notification 42 * @covers ::wp_nonce_tick 43 * @covers ::wp_verify_nonce 44 * @covers ::wp_create_nonce 45 * @covers ::wp_salt 46 * @covers ::wp_hash 47 * @covers ::wp_hash_password 48 * @covers ::wp_check_password 49 * @covers ::wp_generate_password 50 * @covers ::wp_rand 51 * @covers ::wp_set_password 52 * @covers ::get_avatar 53 * @covers ::wp_text_diff 54 * @covers ::install_network 55 * @covers ::wp_install 56 * @covers ::wp_install_defaults 57 * @covers ::wp_new_blog_notification 58 * @covers ::wp_upgrade 59 * @covers ::install_global_terms 60 * @covers ::wp_cache_add 61 * @covers ::wp_cache_close 62 * @covers ::wp_cache_decr 63 * @covers ::wp_cache_delete 64 * @covers ::wp_cache_flush 65 * @covers ::wp_cache_get 66 * @covers ::wp_cache_get_multiple 67 * @covers ::wp_cache_incr 68 * @covers ::wp_cache_init 69 * @covers ::wp_cache_replace 70 * @covers ::wp_cache_set 71 * @covers ::wp_cache_switch_to_blog 72 * @covers ::wp_cache_add_global_groups 73 * @covers ::wp_cache_add_non_persistent_groups 74 * @covers ::wp_cache_reset 15 75 */ 16 76 public function test_pluggable_function_signatures_match( $function ) { 17 77 … … 53 113 * 54 114 * @ticket 33654 55 115 * @ticket 33867 116 * 117 * @covers ::wp_set_current_user 118 * @covers ::wp_get_current_user 119 * @covers ::get_userdata 120 * @covers ::get_user_by 121 * @covers ::cache_users 122 * @covers ::wp_mail 123 * @covers ::wp_authenticate 124 * @covers ::wp_logout 125 * @covers ::wp_validate_auth_cookie 126 * @covers ::wp_generate_auth_cookie 127 * @covers ::wp_parse_auth_cookie 128 * @covers ::wp_set_auth_cookie 129 * @covers ::wp_clear_auth_cookie 130 * @covers ::is_user_logged_in 131 * @covers ::auth_redirect 132 * @covers ::check_admin_referer 133 * @covers ::check_ajax_referer 134 * @covers ::wp_redirect 135 * @covers ::wp_sanitize_redirect 136 * @covers ::_wp_sanitize_utf8_in_redirect 137 * @covers ::wp_safe_redirect 138 * @covers ::wp_validate_redirect 139 * @covers ::wp_notify_postauthor 140 * @covers ::wp_notify_moderator 141 * @covers ::wp_password_change_notification 142 * @covers ::wp_new_user_notification 143 * @covers ::wp_nonce_tick 144 * @covers ::wp_verify_nonce 145 * @covers ::wp_create_nonce 146 * @covers ::wp_salt 147 * @covers ::wp_hash 148 * @covers ::wp_hash_password 149 * @covers ::wp_check_password 150 * @covers ::wp_generate_password 151 * @covers ::wp_rand 152 * @covers ::wp_set_password 153 * @covers ::get_avatar 154 * @covers ::wp_text_diff 155 * @covers ::install_network 156 * @covers ::wp_install 157 * @covers ::wp_install_defaults 158 * @covers ::wp_new_blog_notification 159 * @covers ::wp_upgrade 160 * @covers ::install_global_terms 161 * @covers ::wp_cache_add 162 * @covers ::wp_cache_close 163 * @covers ::wp_cache_decr 164 * @covers ::wp_cache_delete 165 * @covers ::wp_cache_flush 166 * @covers ::wp_cache_get 167 * @covers ::wp_cache_get_multiple 168 * @covers ::wp_cache_incr 169 * @covers ::wp_cache_init 170 * @covers ::wp_cache_replace 171 * @covers ::wp_cache_set 172 * @covers ::wp_cache_switch_to_blog 173 * @covers ::wp_cache_add_global_groups 174 * @covers ::wp_cache_add_non_persistent_groups 175 * @covers ::wp_cache_reset 176 56 177 */ 57 178 public function test_all_pluggable_functions_exist() { 58 179 -
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/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 * 57 * @covers ::create_initial_taxonomies 58 */ 48 59 public function test_add_extra_api_taxonomy_arguments() { 49 60 $taxonomy = get_taxonomy( 'category' ); 50 61 $this->assertTrue( $taxonomy->show_in_rest ); … … 57 68 $this->assertEquals( 'WP_REST_Terms_Controller', $taxonomy->rest_controller_class ); 58 69 } 59 70 71 /** 72 * 73 * @covers ::create_initial_post_types 74 */ 60 75 public function test_add_extra_api_post_type_arguments() { 61 76 $post_type = get_post_type_object( 'post' ); 62 77 $this->assertTrue( $post_type->show_in_rest ); … … 78 93 * Check that a single route is canonicalized. 79 94 * 80 95 * Ensures that single and multiple routes are handled correctly. 96 * 97 * @covers ::register_rest_route 81 98 */ 82 99 public function test_route_canonicalized() { 83 100 register_rest_route( … … 114 131 * Check that a single route is canonicalized. 115 132 * 116 133 * Ensures that single and multiple routes are handled correctly. 134 * 135 * @covers ::register_rest_route 117 136 */ 118 137 public function test_route_canonicalized_multiple() { 119 138 register_rest_route( … … 157 176 158 177 /** 159 178 * Check that routes are merged by default. 179 * 180 * @covers ::register_rest_route 160 181 */ 161 182 public function test_route_merge() { 162 183 register_rest_route( … … 186 207 187 208 /** 188 209 * Check that we can override routes. 210 * 211 * @covers ::register_rest_route 189 212 */ 190 213 public function test_route_override() { 191 214 register_rest_route( … … 224 247 * Test that we reject routes without namespaces 225 248 * 226 249 * @expectedIncorrectUsage register_rest_route 250 * 251 * @covers ::register_rest_route 227 252 */ 228 253 public function test_route_reject_empty_namespace() { 229 254 register_rest_route( … … 244 269 * Test that we reject empty routes 245 270 * 246 271 * @expectedIncorrectUsage register_rest_route 272 * 273 * @covers ::register_rest_route 247 274 */ 248 275 public function test_route_reject_empty_route() { 249 276 register_rest_route( … … 262 289 263 290 /** 264 291 * The rest_route query variable should be registered. 292 * 293 * @covers ::rest_api_init 265 294 */ 266 295 function test_rest_route_query_var() { 267 296 rest_api_init(); … … 268 297 $this->assertTrue( in_array( 'rest_route', $GLOBALS['wp']->public_query_vars, true ) ); 269 298 } 270 299 300 /** 301 * 302 * @covers ::register_rest_route 303 */ 271 304 public function test_route_method() { 272 305 register_rest_route( 273 306 'test-ns', … … 286 319 287 320 /** 288 321 * The 'methods' arg should accept a single value as well as array. 322 * 323 * @covers ::register_rest_route 289 324 */ 290 325 public function test_route_method_string() { 291 326 register_rest_route( … … 305 340 306 341 /** 307 342 * The 'methods' arg should accept a single value as well as array. 343 * 344 * @covers ::register_rest_route 308 345 */ 309 346 public function test_route_method_array() { 310 347 register_rest_route( … … 330 367 331 368 /** 332 369 * The 'methods' arg should a comma-separated string. 370 * 371 * @covers ::register_rest_route 333 372 */ 334 373 public function test_route_method_comma_separated() { 335 374 register_rest_route( … … 353 392 ); 354 393 } 355 394 395 /** 396 * 397 * @covers ::register_rest_route 398 */ 356 399 public function test_options_request() { 357 400 register_rest_route( 358 401 'test-ns', … … 375 418 376 419 /** 377 420 * Ensure that the OPTIONS handler doesn't kick in for non-OPTIONS requests. 421 * 422 * @covers ::rest_handle_options_request 378 423 */ 379 424 public function test_options_request_not_options() { 380 425 register_rest_route( … … 395 440 396 441 /** 397 442 * Ensure that result fields are not allowed if no request['_fields'] is present. 443 * 444 * @covers ::rest_filter_response_fields 398 445 */ 399 446 public function test_rest_filter_response_fields_no_request_filter() { 400 447 $response = new WP_REST_Response(); … … 407 454 408 455 /** 409 456 * Ensure that result fields are allowed if request['_fields'] is present. 457 * 458 * @covers ::rest_filter_response_fields 410 459 */ 411 460 public function test_rest_filter_response_fields_single_field_filter() { 412 461 $response = new WP_REST_Response(); … … 427 476 428 477 /** 429 478 * Ensure that multiple comma-separated fields may be allowed with request['_fields']. 479 * 480 * @covers ::rest_filter_response_fields 430 481 */ 431 482 public function test_rest_filter_response_fields_multi_field_filter() { 432 483 $response = new WP_REST_Response(); … … 458 509 /** 459 510 * Ensure that multiple comma-separated fields may be allowed 460 511 * with request['_fields'] using query parameter array syntax. 512 * 513 * @covers ::rest_filter_response_fields 461 514 */ 462 515 public function test_rest_filter_response_fields_multi_field_filter_array() { 463 516 $response = new WP_REST_Response(); … … 489 542 490 543 /** 491 544 * Ensure that request['_fields'] allowed list apply to items in response collections. 545 * 546 * @covers ::rest_filter_response_fields 492 547 */ 493 548 public function test_rest_filter_response_fields_numeric_array() { 494 549 $response = new WP_REST_Response(); … … 539 594 * Ensure that nested fields may be allowed with request['_fields']. 540 595 * 541 596 * @ticket 42094 597 * 598 * @covers ::rest_filter_response_fields 542 599 */ 543 600 public function test_rest_filter_response_fields_nested_field_filter() { 544 601 $response = new WP_REST_Response(); … … 580 637 * Ensure inclusion of deeply nested fields may be controlled with request['_fields']. 581 638 * 582 639 * @ticket 49648 640 * 641 * @covers ::rest_filter_response_fields 583 642 */ 584 643 public function test_rest_filter_response_fields_deeply_nested_field_filter() { 585 644 $response = new WP_REST_Response(); … … 622 681 * Ensure that specifying a single top-level key in _fields includes that field and all children. 623 682 * 624 683 * @ticket 48266 684 * 685 * @covers ::rest_filter_response_fields 625 686 */ 626 687 public function test_rest_filter_response_fields_top_level_key() { 627 688 $response = new WP_REST_Response(); … … 654 715 * Ensure that a top-level key in _fields supersedes any specified children of that field. 655 716 * 656 717 * @ticket 48266 718 * 719 * @covers ::rest_filter_response_fields 657 720 */ 658 721 public function test_rest_filter_response_fields_child_after_parent() { 659 722 $response = new WP_REST_Response(); … … 686 749 * Ensure that specifying two sibling properties in _fields causes both to be included. 687 750 * 688 751 * @ticket 48266 752 * 753 * @covers ::rest_filter_response_fields 689 754 */ 690 755 public function test_rest_filter_response_fields_include_all_specified_siblings() { 691 756 $response = new WP_REST_Response(); … … 716 781 717 782 /** 718 783 * @ticket 42094 784 * 785 * @covers ::rest_is_field_included 719 786 */ 720 787 public function test_rest_is_field_included() { 721 788 $fields = array( … … 741 808 /** 742 809 * The get_rest_url function should return a URL consistently terminated with a "/", 743 810 * whether the blog is configured with pretty permalink support or not. 811 * 812 * @covers ::get_rest_url 744 813 */ 745 814 public function test_rest_url_generation() { 746 815 // In pretty permalinks case, we expect a path of wp-json/ with no query. … … 758 827 759 828 /** 760 829 * @ticket 34299 830 * 831 * @covers ::get_rest_url 761 832 */ 762 833 public function test_rest_url_scheme() { 763 834 $_SERVER['SERVER_NAME'] = parse_url( home_url(), PHP_URL_HOST ); … … 799 870 800 871 /** 801 872 * @ticket 42452 873 * 874 * @covers ::get_rest_url 802 875 */ 803 876 public function test_always_prepend_path_with_slash_in_rest_url_filter() { 804 877 $filter = new MockAction(); … … 844 917 845 918 /** 846 919 * @dataProvider jsonp_callback_provider 920 * 921 * @covers ::wp_check_jsonp_callback 847 922 */ 848 923 public function test_jsonp_callback_check( $callback, $valid ) { 849 924 $this->assertEquals( $valid, wp_check_jsonp_callback( $callback ) ); … … 876 951 877 952 /** 878 953 * @dataProvider rest_date_provider 954 * 955 * @covers ::rest_parse_date 879 956 */ 880 957 public function test_rest_parse_date( $string, $value ) { 881 958 $this->assertEquals( $value, rest_parse_date( $string ) ); … … 908 985 909 986 /** 910 987 * @dataProvider rest_date_force_utc_provider 988 * 989 * @covers ::rest_parse_date 911 990 */ 912 991 public function test_rest_parse_date_force_utc( $string, $value ) { 913 992 $this->assertEquals( $value, rest_parse_date( $string, true ) ); … … 917 996 return 'Spy_REST_Server'; 918 997 } 919 998 999 /** 1000 * 1001 * @covers ::register_rest_route 1002 */ 920 1003 public function test_register_rest_route_without_server() { 921 1004 $GLOBALS['wp_rest_server'] = null; 922 1005 add_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) ); … … 935 1018 $this->assertEquals( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); 936 1019 } 937 1020 1021 /** 1022 * 1023 */ 938 1024 function test_rest_preload_api_request_with_method() { 939 1025 $rest_server = $GLOBALS['wp_rest_server']; 940 1026 $GLOBALS['wp_rest_server'] = null; … … 958 1044 959 1045 /** 960 1046 * @ticket 40614 1047 * 1048 * @covers ::rest_ensure_request 961 1049 */ 962 1050 function test_rest_ensure_request_accepts_path_string() { 963 1051 $request = rest_ensure_request( '/wp/v2/posts' ); … … 968 1056 969 1057 /** 970 1058 * @dataProvider _dp_rest_parse_embed_param 1059 * 1060 * @covers ::rest_parse_embed_param 971 1061 */ 972 1062 public function test_rest_parse_embed_param( $expected, $embed ) { 973 1063 $this->assertEquals( $expected, rest_parse_embed_param( $embed ) ); … … 997 1087 * @ticket 48819 998 1088 * 999 1089 * @dataProvider _dp_rest_filter_response_by_context 1090 * 1091 * @covers ::rest_filter_response_by_context 1000 1092 */ 1001 1093 public function test_rest_filter_response_by_context( $schema, $data, $expected ) { 1002 1094 $this->assertEquals( $expected, rest_filter_response_by_context( $data, $schema, 'view' ) ); … … 1004 1096 1005 1097 /** 1006 1098 * @ticket 49749 1099 * 1100 * @covers ::register_rest_route 1007 1101 */ 1008 1102 public function test_register_route_with_invalid_namespace() { 1009 1103 $this->setExpectedIncorrectUsage( 'register_rest_route' ); … … 1025 1119 1026 1120 /** 1027 1121 * @ticket 50075 1122 * 1123 * @covers ::register_rest_route 1028 1124 */ 1029 1125 public function test_register_route_with_missing_permission_callback_top_level_route() { 1030 1126 $this->setExpectedIncorrectUsage( 'register_rest_route' ); … … 1042 1138 1043 1139 /** 1044 1140 * @ticket 50075 1141 * 1142 * @covers ::register_rest_route 1045 1143 */ 1046 1144 public function test_register_route_with_missing_permission_callback_single_wrapped_route() { 1047 1145 $this->setExpectedIncorrectUsage( 'register_rest_route' ); … … 1062 1160 1063 1161 /** 1064 1162 * @ticket 50075 1163 * 1164 * @covers ::register_rest_route 1065 1165 */ 1066 1166 public function test_register_route_with_missing_permission_callback_multiple_wrapped_route() { 1067 1167 $this->setExpectedIncorrectUsage( 'register_rest_route' ); … … 1514 1614 ); 1515 1615 } 1516 1616 1617 /** 1618 * 1619 * @covers ::rest_ensure_response 1620 */ 1517 1621 function test_rest_ensure_response_accepts_wp_error_and_returns_wp_error() { 1518 1622 $response = rest_ensure_response( new WP_Error() ); 1519 1623 $this->assertInstanceOf( 'WP_Error', $response ); … … 1524 1628 * 1525 1629 * @param mixed $response The response passed to rest_ensure_response(). 1526 1630 * @param mixed $expected_data The expected data a response should include. 1631 * 1632 * @covers ::rest_ensure_response 1527 1633 */ 1528 1634 function test_rest_ensure_response_returns_instance_of_wp_rest_response( $response, $expected_data ) { 1529 1635 $response_object = rest_ensure_response( $response ); … … 1550 1656 1551 1657 /** 1552 1658 * @ticket 49116 1659 * 1660 * @covers ::rest_get_route_for_post 1553 1661 */ 1554 1662 public function test_rest_get_route_for_post_non_post() { 1555 1663 $this->assertEquals( '', rest_get_route_for_post( 'garbage' ) ); … … 1557 1665 1558 1666 /** 1559 1667 * @ticket 49116 1668 * 1669 * @covers ::rest_get_route_for_post 1560 1670 */ 1561 1671 public function test_rest_get_route_for_post_invalid_post_type() { 1562 1672 register_post_type( 'invalid' ); … … 1568 1678 1569 1679 /** 1570 1680 * @ticket 49116 1681 * 1682 * @covers ::rest_get_route_for_post 1571 1683 */ 1572 1684 public function test_rest_get_route_for_post_non_rest() { 1573 1685 $post = self::factory()->post->create_and_get( array( 'post_type' => 'custom_css' ) ); … … 1576 1688 1577 1689 /** 1578 1690 * @ticket 49116 1691 * 1692 * @covers ::rest_get_route_for_post 1579 1693 */ 1580 1694 public function test_rest_get_route_for_post_custom_controller() { 1581 1695 $post = self::factory()->post->create_and_get( array( 'post_type' => 'wp_block' ) ); … … 1584 1698 1585 1699 /** 1586 1700 * @ticket 49116 1701 * 1702 * @covers ::rest_get_route_for_post 1587 1703 */ 1588 1704 public function test_rest_get_route_for_post() { 1589 1705 $post = self::factory()->post->create_and_get(); … … 1592 1708 1593 1709 /** 1594 1710 * @ticket 49116 1711 * 1712 * @covers ::rest_get_route_for_post 1595 1713 */ 1596 1714 public function test_rest_get_route_for_media() { 1597 1715 $post = self::factory()->attachment->create_and_get(); … … 1600 1718 1601 1719 /** 1602 1720 * @ticket 49116 1721 * 1722 * @covers ::rest_get_route_for_post 1603 1723 */ 1604 1724 public function test_rest_get_route_for_post_id() { 1605 1725 $post = self::factory()->post->create_and_get(); … … 1608 1728 1609 1729 /** 1610 1730 * @ticket 49116 1731 * 1732 * @covers ::rest_get_route_for_term 1611 1733 */ 1612 1734 public function test_rest_get_route_for_term_non_term() { 1613 1735 $this->assertEquals( '', rest_get_route_for_term( 'garbage' ) ); … … 1615 1737 1616 1738 /** 1617 1739 * @ticket 49116 1740 * 1741 * @covers ::rest_get_route_for_term 1618 1742 */ 1619 1743 public function test_rest_get_route_for_term_invalid_term_type() { 1620 1744 register_taxonomy( 'invalid', 'post' ); … … 1626 1750 1627 1751 /** 1628 1752 * @ticket 49116 1753 * 1754 * @covers ::rest_get_route_for_term 1629 1755 */ 1630 1756 public function test_rest_get_route_for_term_non_rest() { 1631 1757 $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'post_format' ) ); … … 1634 1760 1635 1761 /** 1636 1762 * @ticket 49116 1763 * 1764 * @covers ::rest_get_route_for_term 1637 1765 */ 1638 1766 public function test_rest_get_route_for_term() { 1639 1767 $term = self::factory()->term->create_and_get(); … … 1642 1770 1643 1771 /** 1644 1772 * @ticket 49116 1773 * 1774 * @covers ::rest_get_route_for_term 1645 1775 */ 1646 1776 public function test_rest_get_route_for_category() { 1647 1777 $term = self::factory()->category->create_and_get(); … … 1650 1780 1651 1781 /** 1652 1782 * @ticket 49116 1783 * 1784 * @covers ::rest_get_route_for_term 1653 1785 */ 1654 1786 public function test_rest_get_route_for_term_id() { 1655 1787 $term = self::factory()->term->create_and_get(); … … 1663 1795 * 1664 1796 * @param bool $expected Expected result of the check. 1665 1797 * @param mixed $value The value to check. 1798 * 1799 * @covers ::rest_is_object 1666 1800 */ 1667 1801 public function test_rest_is_object( $expected, $value ) { 1668 1802 $is_object = rest_is_object( $value ); … … 1726 1860 * 1727 1861 * @param array $expected Expected sanitized version. 1728 1862 * @param mixed $value The value to sanitize. 1863 * 1864 * @covers ::rest_sanitize_object 1729 1865 */ 1730 1866 public function test_rest_sanitize_object( $expected, $value ) { 1731 1867 $sanitized = rest_sanitize_object( $value ); … … 1784 1920 * 1785 1921 * @param bool $expected Expected result of the check. 1786 1922 * @param mixed $value The value to check. 1923 * 1924 * @covers ::rest_is_array 1787 1925 */ 1788 1926 public function test_rest_is_array( $expected, $value ) { 1789 1927 $is_array = rest_is_array( $value ); … … 1855 1993 * 1856 1994 * @param array $expected Expected sanitized version. 1857 1995 * @param mixed $value The value to sanitize. 1996 * 1997 * @covers ::rest_sanitize_array 1858 1998 */ 1859 1999 public function test_rest_sanitize_array( $expected, $value ) { 1860 2000 $sanitized = rest_sanitize_array( $value ); … … 1926 2066 * @param string $expected The expected best type. 1927 2067 * @param mixed $value The value to test. 1928 2068 * @param array $types The list of available types. 2069 * 2070 * @covers ::rest_get_best_type_for_value 1929 2071 */ 1930 2072 public function test_get_best_type_for_value( $expected, $value, $types ) { 1931 2073 $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::id 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::ID 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 254 279 */ 255 280 function test_user_meta_properties() { 256 281 $user = new WP_User( self::$author_id ); … … 264 289 265 290 /** 266 291 * @expectedDeprecated WP_User->id 292 * 293 * @covers WP_User::id 267 294 */ 268 295 function test_id_property_back_compat() { 269 296 $user = new WP_User( self::$author_id ); … … 276 303 277 304 /** 278 305 * ticket 19265 306 * 307 * @covers WP_User::user_level 279 308 */ 280 309 function test_user_level_property_back_compat() { 281 310 $roles = array( … … 294 323 } 295 324 } 296 325 326 /** 327 * 328 * @covers WP_User::__construct 329 */ 297 330 function test_construction() { 298 331 $user = new WP_User( self::$author_id ); 299 332 $this->assertInstanceOf( 'WP_User', $user ); … … 333 366 $this->assertEquals( $user->user_login, $user7->user_login ); 334 367 } 335 368 369 /** 370 * 371 * @covers WP_User::get 372 */ 336 373 function test_get() { 337 374 $user = new WP_User( self::$author_id ); 338 375 $this->assertEquals( 'author_login', $user->get( 'user_login' ) ); … … 344 381 $this->assertEquals( 'abcdefg', $user->get( 'dashed-key' ) ); 345 382 } 346 383 384 /** 385 * 386 * @covers WP_User::has_prop 387 */ 347 388 function test_has_prop() { 348 389 $user = new WP_User( self::$author_id ); 349 390 $this->assertTrue( $user->has_prop( 'user_email' ) ); … … 354 395 $this->assertTrue( $user->has_prop( 'dashed-key' ) ); 355 396 } 356 397 398 /** 399 * 400 * @covers ::wp_update_user 401 */ 357 402 function test_update_user() { 358 403 $user = new WP_User( self::$author_id ); 359 404 … … 411 456 412 457 /** 413 458 * ticket 19595 459 * 460 * @covers WP_User::__construct 414 461 */ 415 462 function test_global_userdata() { 416 463 global $userdata, $wpdb; … … 427 474 428 475 /** 429 476 * ticket 19769 477 * 478 * @covers WP_User::__construct 430 479 */ 431 480 function test_global_userdata_is_null_when_logged_out() { 432 481 global $userdata; … … 448 497 $this->assertFalse( $user->exists() ); 449 498 } 450 499 500 /** 501 * 502 * @covers WP_User::__construct 503 */ 451 504 function test_global_authordata() { 452 505 global $authordata, $id; 453 506 … … 480 533 481 534 /** 482 535 * @ticket 13317 536 * 537 * @covers ::get_userdata 483 538 */ 484 539 function test_get_userdata() { 485 540 $this->assertFalse( get_userdata( 0 ) ); … … 490 545 491 546 /** 492 547 * @ticket 23480 548 * 549 * @covers WP_User::get_data_by 493 550 */ 494 551 function test_user_get_data_by_id() { 495 552 $user = WP_User::get_data_by( 'id', self::$author_id ); … … 521 578 522 579 /** 523 580 * @ticket 33869 581 * 582 * @covers WP_User::get_data_by 524 583 */ 525 584 public function test_user_get_data_by_ID_should_alias_to_id() { 526 585 $user = WP_User::get_data_by( 'ID', self::$author_id ); … … 529 588 530 589 /** 531 590 * @ticket 21431 591 * 592 * @covers ::count_many_users_posts 532 593 */ 533 594 function test_count_many_users_posts() { 534 595 $user_id_b = self::factory()->user->create( array( 'role' => 'author' ) ); … … 562 623 563 624 /** 564 625 * @ticket 22858 626 * 627 * @covers ::wp_update_user 565 628 */ 566 629 function test_wp_update_user_on_nonexistent_users() { 567 630 $user_id = 1; … … 576 639 577 640 /** 578 641 * @ticket 28435 642 * 643 * @covers ::wp_update_user 579 644 */ 580 645 function test_wp_update_user_should_not_change_password_when_passed_WP_User_instance() { 581 646 $testuserid = 1; … … 591 656 /** 592 657 * @ticket 45747 593 658 * @group ms-excluded 659 * 660 * @covers ::wp_update_user 594 661 */ 595 662 function test_wp_update_user_should_not_mark_user_as_spam_on_single_site() { 596 663 $u = wp_update_user( … … 615 682 616 683 /** 617 684 * @ticket 28315 685 * 686 * @covers ::update_user_meta 618 687 */ 619 688 function test_user_meta_error() { 620 689 $id1 = wp_insert_user( … … 646 715 647 716 /** 648 717 * @ticket 30647 718 * 719 * @covers ::update_user_meta 649 720 */ 650 721 function test_user_update_email_error() { 651 722 $id1 = wp_insert_user( … … 691 762 /** 692 763 * @ticket 27317 693 764 * @dataProvider _illegal_user_logins_data 765 * 766 * @covers ::wp_insert_user 694 767 */ 695 768 function test_illegal_user_logins_single( $user_login ) { 696 769 $user_data = array( … … 715 788 /** 716 789 * @ticket 27317 717 790 * @dataProvider _illegal_user_logins_data 791 * 792 * @covers ::register_new_user 718 793 */ 719 794 function test_illegal_user_logins_single_wp_create_user( $user_login ) { 720 795 $user_email = 'testuser-' . $user_login . '@example.com'; … … 735 810 /** 736 811 * @ticket 27317 737 812 * @group ms-required 813 * 814 * @covers ::wpmu_validate_user_signup 738 815 */ 739 816 function test_illegal_user_logins_multisite() { 740 817 $user_data = array( … … 773 850 774 851 /** 775 852 * @ticket 24618 853 * 854 * @covers ::validate_username 776 855 */ 777 856 public function test_validate_username_string() { 778 857 $this->assertTrue( validate_username( 'johndoe' ) ); … … 781 860 782 861 /** 783 862 * @ticket 24618 863 * 864 * @covers ::validate_username 784 865 */ 785 866 public function test_validate_username_contains_uppercase_letters() { 786 867 if ( is_multisite() ) { … … 792 873 793 874 /** 794 875 * @ticket 24618 876 * 877 * @covers ::validate_username 795 878 */ 796 879 public function test_validate_username_empty() { 797 880 $this->assertFalse( validate_username( '' ) ); … … 799 882 800 883 /** 801 884 * @ticket 24618 885 * 886 * @covers ::validate_username 802 887 */ 803 888 public function test_validate_username_invalid() { 804 889 $this->assertFalse( validate_username( '@#&99sd' ) ); … … 806 891 807 892 /** 808 893 * @ticket 29880 894 * 895 * @covers ::wp_insert_user 809 896 */ 810 897 public function test_wp_insert_user_should_not_wipe_existing_password() { 811 898 $user_details = array( … … 828 915 829 916 /** 830 917 * @ticket 29696 918 * 919 * @covers ::wp_insert_user 831 920 */ 832 921 public function test_wp_insert_user_should_sanitize_user_nicename_parameter() { 833 922 $user = $this->author; … … 843 932 844 933 /** 845 934 * @ticket 33793 935 * 936 * @covers ::wp_insert_user 846 937 */ 847 938 public function test_wp_insert_user_should_accept_user_login_with_60_characters() { 848 939 $user_login = str_repeat( 'a', 60 ); … … 864 955 865 956 /** 866 957 * @ticket 33793 958 * 959 * @covers ::wp_insert_user 867 960 */ 868 961 public function test_wp_insert_user_should_reject_user_login_over_60_characters() { 869 962 $user_login = str_repeat( 'a', 61 ); … … 882 975 883 976 /** 884 977 * @ticket 33793 978 * 979 * @covers ::wp_insert_user 885 980 */ 886 981 public function test_wp_insert_user_should_reject_user_nicename_over_50_characters() { 887 982 $user_nicename = str_repeat( 'a', 51 ); … … 900 995 901 996 /** 902 997 * @ticket 33793 998 * 999 * @covers ::wp_insert_user 903 1000 */ 904 1001 public function test_wp_insert_user_should_not_generate_user_nicename_longer_than_50_chars() { 905 1002 $user_login = str_repeat( 'a', 55 ); … … 919 1016 920 1017 /** 921 1018 * @ticket 33793 1019 * 1020 * @covers ::wp_insert_user 922 1021 */ 923 1022 public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename() { 924 1023 $u1 = self::factory()->user->create( … … 949 1048 950 1049 /** 951 1050 * @ticket 33793 1051 * 1052 * @covers ::wp_insert_user 952 1053 */ 953 1054 public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() { 954 1055 $user_ids = self::factory()->user->create_many( … … 985 1086 986 1087 /** 987 1088 * @ticket 28004 1089 * 1090 * @covers ::wp_insert_user 988 1091 */ 989 1092 public function test_wp_insert_user_with_invalid_user_id() { 990 1093 global $wpdb; … … 1005 1108 1006 1109 /** 1007 1110 * @ticket 47902 1111 * 1112 * @covers ::wp_insert_user 1008 1113 */ 1009 1114 public function test_wp_insert_user_with_empty_data() { 1010 1115 add_filter( 'wp_pre_insert_user_data', '__return_empty_array' ); … … 1019 1124 1020 1125 /** 1021 1126 * @ticket 35750 1127 * 1128 * @covers ::wp_update_user 1022 1129 */ 1023 1130 public function test_wp_update_user_should_delete_userslugs_cache() { 1024 1131 $u = self::factory()->user->create(); … … 1036 1143 $this->assertEquals( $u, wp_cache_get( $updated_user->user_nicename, 'userslugs' ) ); 1037 1144 } 1038 1145 1146 /** 1147 * 1148 * @covers ::wp_update_user 1149 */ 1039 1150 public function test_changing_email_invalidates_password_reset_key() { 1040 1151 global $wpdb; 1041 1152 … … 1088 1199 $this->assertEmpty( $user->user_activation_key ); 1089 1200 } 1090 1201 1202 /** 1203 * 1204 * @covers ::get_users 1205 */ 1091 1206 public function test_search_users_login() { 1092 1207 $users = get_users( 1093 1208 array( … … 1099 1214 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1100 1215 } 1101 1216 1217 /** 1218 * 1219 * @covers ::get_users 1220 */ 1102 1221 public function test_search_users_url() { 1103 1222 $users = get_users( 1104 1223 array( … … 1110 1229 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1111 1230 } 1112 1231 1232 /** 1233 * 1234 * @covers ::get_users 1235 */ 1113 1236 public function test_search_users_email() { 1114 1237 $users = get_users( 1115 1238 array( … … 1121 1244 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1122 1245 } 1123 1246 1247 /** 1248 * 1249 * @covers ::get_users 1250 */ 1124 1251 public function test_search_users_nicename() { 1125 1252 $users = get_users( 1126 1253 array( … … 1132 1259 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1133 1260 } 1134 1261 1262 /** 1263 * 1264 * @covers ::get_users 1265 */ 1135 1266 public function test_search_users_display_name() { 1136 1267 $users = get_users( 1137 1268 array( … … 1145 1276 1146 1277 /** 1147 1278 * @ticket 32158 1279 * 1280 * @covers ::wp_update_user 1148 1281 */ 1149 1282 function test_email_case() { 1150 1283 // Alter the case of the email address (which stays the same). … … 1159 1292 1160 1293 /** 1161 1294 * @ticket 32158 1295 * 1296 * @covers ::wp_update_user 1162 1297 */ 1163 1298 function test_email_change() { 1164 1299 // Change the email address. … … 1182 1317 * @dataProvider data_wp_new_user_notifications 1183 1318 * @ticket 33654 1184 1319 * @ticket 36009 1320 * 1321 * @covers ::wp_new_user_notification 1185 1322 */ 1186 1323 function test_wp_new_user_notification( $notify, $admin_email_sent_expected, $user_email_sent_expected ) { 1187 1324 reset_phpmailer_instance(); … … 1262 1399 * 1263 1400 * @ticket 33654 1264 1401 * @expectedDeprecated wp_new_user_notification 1402 * 1403 * @covers ::wp_new_user_notification 1265 1404 */ 1266 1405 function test_wp_new_user_notification_old_signature_throws_deprecated_warning_but_sends() { 1267 1406 reset_phpmailer_instance(); … … 1287 1426 * Set up a user and try sending a notification using `wp_new_user_notification( $user );`. 1288 1427 * 1289 1428 * @ticket 34377 1429 * 1430 * @covers ::wp_new_user_notification 1290 1431 */ 1291 1432 function test_wp_new_user_notification_old_signature_no_password() { 1292 1433 reset_phpmailer_instance(); … … 1312 1453 * Ensure blog's admin email change notification emails do not contain encoded HTML entities 1313 1454 * 1314 1455 * @ticket 40015 1456 * 1457 * @covers ::update_option_new_admin_email 1315 1458 */ 1316 1459 function test_new_admin_email_notification_html_entities_decoded() { 1317 1460 reset_phpmailer_instance(); … … 1345 1488 * - is not a valid email 1346 1489 * 1347 1490 * @dataProvider data_user_admin_email_confirmation_emails 1491 * 1492 * @covers ::update_option_new_admin_email 1348 1493 */ 1349 1494 function test_new_admin_email_confirmation_not_sent_when_email_invalid( $email, $message ) { 1350 1495 reset_phpmailer_instance(); … … 1386 1531 * - Matches another user's email 1387 1532 * 1388 1533 * @dataProvider data_user_change_email_confirmation_emails 1534 * 1535 * @covers ::send_confirmation_on_profile_email 1389 1536 */ 1390 1537 function test_profile_email_confirmation_not_sent_invalid_email( $email, $message ) { 1391 1538 … … 1451 1598 * Checks that calling edit_user() with no password returns an error when adding, and doesn't when updating. 1452 1599 * 1453 1600 * @ticket 35715 1601 * 1602 * @covers ::edit_user 1454 1603 */ 1455 1604 function test_edit_user_blank_pw() { 1456 1605 $_POST = array(); … … 1520 1669 1521 1670 /** 1522 1671 * @ticket 16470 1672 * 1673 * @covers ::wp_set_current_user 1523 1674 */ 1524 1675 function test_send_confirmation_on_profile_email() { 1525 1676 reset_phpmailer_instance(); … … 1555 1706 1556 1707 /** 1557 1708 * @ticket 16470 1709 * 1710 * @covers ::wp_set_current_user 1558 1711 */ 1559 1712 function test_remove_send_confirmation_on_profile_email() { 1560 1713 remove_action( 'personal_options_update', 'send_confirmation_on_profile_email' ); … … 1595 1748 * 1596 1749 * @ticket 16470 1597 1750 * @ticket 40015 1751 * 1752 * @covers ::send_confirmation_on_profile_email 1598 1753 */ 1599 1754 function test_send_confirmation_on_profile_email_html_entities_decoded() { 1600 1755 $user_id = self::factory()->user->create( … … 1631 1786 1632 1787 /** 1633 1788 * @ticket 42564 1789 * 1790 * @covers ::edit_user 1634 1791 */ 1635 1792 function test_edit_user_role_update() { 1636 1793 $_POST = array(); … … 1674 1831 * Testing the `wp_user_personal_data_exporter()` function when no user exists. 1675 1832 * 1676 1833 * @ticket 43547 1834 * 1835 * @covers ::wp_user_personal_data_exporter 1677 1836 */ 1678 1837 function test_wp_user_personal_data_exporter_no_user() { 1679 1838 $actual = wp_user_personal_data_exporter( 'not-a-user-email@test.com' ); … … 1691 1850 * user exists. 1692 1851 * 1693 1852 * @ticket 43547 1853 * 1854 * @covers ::wp_user_personal_data_exporter 1694 1855 */ 1695 1856 function test_wp_user_personal_data_exporter() { 1696 1857 $test_user = new WP_User( self::$contrib_id ); … … 1711 1872 * with Community Events Location IP data. 1712 1873 * 1713 1874 * @ticket 43921 1875 * 1876 * @covers ::wp_user_personal_data_exporter 1714 1877 */ 1715 1878 function test_wp_community_events_location_ip_personal_data_exporter() { 1716 1879 $test_user = new WP_User( self::$contrib_id ); … … 1735 1898 * with Community Events Location city data. 1736 1899 * 1737 1900 * @ticket 43921 1901 * 1902 * @covers ::wp_user_personal_data_exporter 1738 1903 */ 1739 1904 function test_wp_community_events_location_city_personal_data_exporter() { 1740 1905 $test_user = new WP_User( self::$contrib_id ); … … 1777 1942 * with Session Tokens data. 1778 1943 * 1779 1944 * @ticket 45889 1945 * 1946 * @covers ::wp_user_personal_data_exporter 1780 1947 */ 1781 1948 function test_wp_session_tokens_personal_data_exporter() { 1782 1949 $test_user = new WP_User( self::$contrib_id ); … … 1821 1988 * @since 5.4.0 1822 1989 * 1823 1990 * @ticket 47509 1991 * 1992 * @covers ::wp_user_personal_data_exporter 1824 1993 */ 1825 1994 function test_filter_wp_privacy_additional_user_profile_data() { 1826 1995 $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; … … 39 42 register_widget( $widget_class ); 40 43 $this->assertArrayHasKey( $widget_class, $wp_widget_factory->widgets ); 41 44 42 unregister_widget( $widget_class );45 ( $widget_class ); 43 46 $this->assertArrayNotHasKey( $widget_class, $wp_widget_factory->widgets ); 44 47 } 45 48 … … 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