Changeset 52010 for trunk/tests/phpunit/tests/query/conditionals.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/conditionals.php
r51568 r52010 15 15 protected $post_ids; 16 16 17 function set_up() {17 public function set_up() { 18 18 parent::set_up(); 19 19 … … 26 26 } 27 27 28 function test_home() {28 public function test_home() { 29 29 $this->go_to( '/' ); 30 30 $this->assertQueryTrue( 'is_home', 'is_front_page' ); 31 31 } 32 32 33 function test_page_on_front() {33 public function test_page_on_front() { 34 34 $page_on_front = self::factory()->post->create( 35 35 array( … … 57 57 } 58 58 59 function test_404() {59 public function test_404() { 60 60 $this->go_to( '/notapage' ); 61 61 $this->assertQueryTrue( 'is_404' ); 62 62 } 63 63 64 function test_permalink() {64 public function test_permalink() { 65 65 $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); 66 66 $this->go_to( get_permalink( $post_id ) ); … … 68 68 } 69 69 70 function test_post_comments_feed() {70 public function test_post_comments_feed() { 71 71 $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); 72 72 self::factory()->comment->create_post_comments( $post_id, 2 ); … … 76 76 77 77 78 function test_post_comments_feed_with_no_comments() {78 public function test_post_comments_feed_with_no_comments() { 79 79 $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); 80 80 $this->go_to( get_post_comments_feed_link( $post_id ) ); … … 82 82 } 83 83 84 function test_attachment_comments_feed() {84 public function test_attachment_comments_feed() { 85 85 $attachment_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); 86 86 self::factory()->comment->create_post_comments( $attachment_id, 2 ); … … 89 89 } 90 90 91 function test_page() {91 public function test_page() { 92 92 $page_id = self::factory()->post->create( 93 93 array( … … 100 100 } 101 101 102 function test_parent_page() {102 public function test_parent_page() { 103 103 $page_id = self::factory()->post->create( 104 104 array( … … 112 112 } 113 113 114 function test_child_page_1() {114 public function test_child_page_1() { 115 115 $page_id = self::factory()->post->create( 116 116 array( … … 131 131 } 132 132 133 function test_child_page_2() {133 public function test_child_page_2() { 134 134 $page_id = self::factory()->post->create( 135 135 array( … … 158 158 159 159 // '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1' 160 function test_page_trackback() {160 public function test_page_trackback() { 161 161 $page_ids = array(); 162 162 $page_id = self::factory()->post->create( … … 196 196 197 197 // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' 198 function test_page_feed() {198 public function test_page_feed() { 199 199 $page_ids = array(); 200 200 $page_id = self::factory()->post->create( … … 234 234 } 235 235 236 function test_page_feed_with_no_comments() {236 public function test_page_feed_with_no_comments() { 237 237 $page_ids = array(); 238 238 $page_id = self::factory()->post->create( … … 272 272 273 273 // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' 274 function test_page_feed_atom() {274 public function test_page_feed_atom() { 275 275 $page_ids = array(); 276 276 $page_id = self::factory()->post->create( … … 312 312 313 313 // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' 314 function test_page_page_2() {314 public function test_page_page_2() { 315 315 $page_id = self::factory()->post->create( 316 316 array( … … 331 331 332 332 // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' 333 function test_page_page_2_no_slash() {333 public function test_page_page_2_no_slash() { 334 334 $page_id = self::factory()->post->create( 335 335 array( … … 350 350 351 351 // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]' 352 function test_pagination_of_posts_page() {352 public function test_pagination_of_posts_page() { 353 353 $page_id = self::factory()->post->create( 354 354 array( … … 381 381 // 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', 382 382 // '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', 383 function test_main_feed_2() {383 public function test_main_feed_2() { 384 384 self::factory()->post->create(); // @test_404 385 385 $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); … … 399 399 } 400 400 401 function test_main_feed() {401 public function test_main_feed() { 402 402 self::factory()->post->create(); // @test_404 403 403 $types = array( 'rss2', 'rss', 'atom' ); … … 409 409 410 410 // 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]', 411 function test_paged() {411 public function test_paged() { 412 412 update_option( 'posts_per_page', 2 ); 413 413 self::factory()->post->create_many( 5 ); … … 420 420 // 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', 421 421 // 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', 422 function test_main_comments_feed() {422 public function test_main_comments_feed() { 423 423 $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); 424 424 self::factory()->comment->create_post_comments( $post_id, 2 ); … … 446 446 // 'search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]', 447 447 // 'search/(.+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]', 448 function test_search_feed() {448 public function test_search_feed() { 449 449 // Check the long form. 450 450 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); … … 463 463 464 464 // 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]', 465 function test_search_paged() {465 public function test_search_paged() { 466 466 update_option( 'posts_per_page', 2 ); 467 467 self::factory()->post->create_many( 3, array( 'post_title' => 'test' ) ); … … 471 471 472 472 // 'search/(.+)/?$' => 'index.php?s=$matches[1]', 473 function test_search() {473 public function test_search() { 474 474 $this->go_to( '/search/test/' ); 475 475 $this->assertQueryTrue( 'is_search' ); … … 479 479 * @ticket 13961 480 480 */ 481 function test_search_encoded_chars() {481 public function test_search_encoded_chars() { 482 482 $this->go_to( '/search/F%C3%BCnf%2Bbar/' ); 483 483 $this->assertSame( get_query_var( 's' ), 'Fünf+bar' ); … … 486 486 // 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', 487 487 // 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', 488 function test_category_feed() {488 public function test_category_feed() { 489 489 self::factory()->term->create( 490 490 array( … … 510 510 511 511 // 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]', 512 function test_category_paged() {512 public function test_category_paged() { 513 513 update_option( 'posts_per_page', 2 ); 514 514 self::factory()->post->create_many( 3 ); … … 518 518 519 519 // 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]', 520 function test_category() {520 public function test_category() { 521 521 self::factory()->term->create( 522 522 array( … … 531 531 // 'tag/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', 532 532 // 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', 533 function test_tag_feed() {533 public function test_tag_feed() { 534 534 self::factory()->term->create( 535 535 array( … … 554 554 555 555 // 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]', 556 function test_tag_paged() {556 public function test_tag_paged() { 557 557 update_option( 'posts_per_page', 2 ); 558 558 $post_ids = self::factory()->post->create_many( 3 ); … … 565 565 566 566 // 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]', 567 function test_tag() {567 public function test_tag() { 568 568 $term_id = self::factory()->term->create( 569 569 array( … … 590 590 // 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', 591 591 // 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', 592 function test_author_feed() {592 public function test_author_feed() { 593 593 self::factory()->user->create( array( 'user_login' => 'user-a' ) ); 594 594 // Check the long form. … … 608 608 609 609 // 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]', 610 function test_author_paged() {610 public function test_author_paged() { 611 611 update_option( 'posts_per_page', 2 ); 612 612 $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); … … 617 617 618 618 // 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]', 619 function test_author() {619 public function test_author() { 620 620 $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); 621 621 self::factory()->post->create( array( 'post_author' => $user_id ) ); … … 624 624 } 625 625 626 function test_author_with_no_posts() {626 public function test_author_with_no_posts() { 627 627 $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); 628 628 $this->go_to( '/author/user-a/' ); … … 632 632 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', 633 633 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', 634 function test_ymd_feed() {634 public function test_ymd_feed() { 635 635 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 636 636 // Check the long form. … … 650 650 651 651 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]', 652 function test_ymd_paged() {652 public function test_ymd_paged() { 653 653 update_option( 'posts_per_page', 2 ); 654 654 self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); … … 658 658 659 659 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]', 660 function test_ymd() {660 public function test_ymd() { 661 661 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 662 662 $this->go_to( '/2007/09/04/' ); … … 666 666 // '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', 667 667 // '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', 668 function test_ym_feed() {668 public function test_ym_feed() { 669 669 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 670 670 // Check the long form. … … 684 684 685 685 // '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]', 686 function test_ym_paged() {686 public function test_ym_paged() { 687 687 update_option( 'posts_per_page', 2 ); 688 688 self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); … … 692 692 693 693 // '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]', 694 function test_ym() {694 public function test_ym() { 695 695 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 696 696 $this->go_to( '/2007/09/' ); … … 700 700 // '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', 701 701 // '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', 702 function test_y_feed() {702 public function test_y_feed() { 703 703 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 704 704 // Check the long form. … … 718 718 719 719 // '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]', 720 function test_y_paged() {720 public function test_y_paged() { 721 721 update_option( 'posts_per_page', 2 ); 722 722 self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); … … 726 726 727 727 // '([0-9]{4})/?$' => 'index.php?year=$matches[1]', 728 function test_y() {728 public function test_y() { 729 729 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 730 730 $this->go_to( '/2007/' ); … … 733 733 734 734 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1', 735 function test_post_trackback() {735 public function test_post_trackback() { 736 736 $post_id = self::factory()->post->create(); 737 737 $permalink = get_permalink( $post_id ); … … 742 742 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', 743 743 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', 744 function test_post_comment_feed() {744 public function test_post_comment_feed() { 745 745 $post_id = self::factory()->post->create(); 746 746 $permalink = get_permalink( $post_id ); … … 761 761 762 762 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]', 763 function test_post_paged_short() {763 public function test_post_paged_short() { 764 764 $post_id = self::factory()->post->create( 765 765 array( … … 776 776 777 777 // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 778 function test_post_attachment() {778 public function test_post_attachment() { 779 779 $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); 780 780 $permalink = get_attachment_link( $post_id ); … … 794 794 * @expectedIncorrectUsage WP_Date_Query 795 795 */ 796 function test_bad_dates() {796 public function test_bad_dates() { 797 797 $this->go_to( '/2013/13/13/' ); 798 798 $this->assertQueryTrue( 'is_404' ); … … 802 802 } 803 803 804 function test_post_type_archive_with_tax_query() {804 public function test_post_type_archive_with_tax_query() { 805 805 delete_option( 'rewrite_rules' ); 806 806 … … 833 833 } 834 834 835 function pre_get_posts_with_tax_query( &$query ) {835 public function pre_get_posts_with_tax_query( &$query ) { 836 836 $term = get_term_by( 'slug', 'tag-slug', 'post_tag' ); 837 837 $query->set( … … 847 847 } 848 848 849 function test_post_type_array() {849 public function test_post_type_array() { 850 850 delete_option( 'rewrite_rules' ); 851 851 … … 875 875 } 876 876 877 function pre_get_posts_with_type_array( &$query ) {877 public function pre_get_posts_with_type_array( &$query ) { 878 878 $query->set( 'post_type', array( 'post', 'thearray' ) ); 879 879 } 880 880 881 function test_is_single() {881 public function test_is_single() { 882 882 $post_id = self::factory()->post->create(); 883 883 $this->go_to( "/?p=$post_id" ); … … 899 899 * @ticket 16802 900 900 */ 901 function test_is_single_with_parent() {901 public function test_is_single_with_parent() { 902 902 // Use custom hierarchical post type. 903 903 $post_type = 'test_hierarchical'; … … 1006 1006 * @ticket 38225 1007 1007 */ 1008 function test_is_single_with_attachment() {1008 public function test_is_single_with_attachment() { 1009 1009 $post_id = self::factory()->post->create(); 1010 1010 … … 1026 1026 } 1027 1027 1028 function test_is_page() {1028 public function test_is_page() { 1029 1029 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 1030 1030 $this->go_to( "/?page_id=$post_id" ); … … 1046 1046 * @ticket 16802 1047 1047 */ 1048 function test_is_page_with_parent() {1048 public function test_is_page_with_parent() { 1049 1049 $parent_id = self::factory()->post->create( 1050 1050 array( … … 1080 1080 } 1081 1081 1082 function test_is_attachment() {1082 public function test_is_attachment() { 1083 1083 $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); 1084 1084 $this->go_to( "/?attachment_id=$post_id" ); … … 1237 1237 } 1238 1238 1239 function test_is_page_template() {1239 public function test_is_page_template() { 1240 1240 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 1241 1241 update_post_meta( $post_id, '_wp_page_template', 'example.php' ); … … 1247 1247 * @ticket 31271 1248 1248 */ 1249 function test_is_page_template_default() {1249 public function test_is_page_template_default() { 1250 1250 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 1251 1251 $this->go_to( "/?page_id=$post_id" ); … … 1257 1257 * @ticket 31271 1258 1258 */ 1259 function test_is_page_template_array() {1259 public function test_is_page_template_array() { 1260 1260 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 1261 1261 update_post_meta( $post_id, '_wp_page_template', 'example.php' ); … … 1268 1268 * @ticket 18375 1269 1269 */ 1270 function test_is_page_template_other_post_type() {1270 public function test_is_page_template_other_post_type() { 1271 1271 $post_id = self::factory()->post->create( array( 'post_type' => 'post' ) ); 1272 1272 update_post_meta( $post_id, '_wp_page_template', 'example.php' ); … … 1279 1279 * @ticket 39211 1280 1280 */ 1281 function test_is_page_template_not_singular() {1281 public function test_is_page_template_not_singular() { 1282 1282 global $wpdb; 1283 1283
Note: See TracChangeset
for help on using the changeset viewer.