Ticket #39265: root.patch
File root.patch, 264.7 KB (added by , 4 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