Changeset 35162
- Timestamp:
- 10/14/2015 09:23:03 PM (9 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/category.php
r33681 r35162 22 22 function test_get_all_category_ids() { 23 23 // create categories 24 $this->factory->category->create_many( 15);24 $this->factory->category->create_many( 2 ); 25 25 26 26 // create new taxonomy to ensure not included 27 27 register_taxonomy( 'test_tax_cat', 'post' ); 28 28 wp_insert_term( "test1", 'test_tax_cat' ); 29 wp_insert_term( "test2", 'test_tax_cat' );30 wp_insert_term( "test3", 'test_tax_cat' );31 29 32 30 // Validate length is 1 + created due to uncategorized 33 31 $cat_ids = get_all_category_ids(); 34 $this->assertEquals( 16, count($cat_ids));32 $this->assertEquals( 3, count($cat_ids)); 35 33 } 36 34 -
trunk/tests/phpunit/tests/customize/nav-menus.php
r34857 r35162 125 125 126 126 // Create pages. 127 $this->factory->post->create_many( 1 5, array( 'post_type' => 'page' ) );127 $this->factory->post->create_many( 12, array( 'post_type' => 'page' ) ); 128 128 129 129 // Home is included in menu items when page is zero. -
trunk/tests/phpunit/tests/feed/rss2.php
r34802 r35162 17 17 18 18 self::$user = $factory->user->create(); 19 self::$posts = $factory->post->create_many( 25, array(19 self::$posts = $factory->post->create_many( 5, array( 20 20 'post_author' => self::$user, 21 21 ) ); -
trunk/tests/phpunit/tests/general/archives.php
r34828 r35162 17 17 global $wpdb; 18 18 19 $this->factory->post->create_many( 15, array( 'post_type' => 'post' ) );19 $this->factory->post->create_many( 3, array( 'post_type' => 'post' ) ); 20 20 wp_cache_delete( 'last_changed', 'posts' ); 21 21 $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) ); -
trunk/tests/phpunit/tests/post.php
r34810 r35162 805 805 $post_type = rand_str(20); 806 806 register_post_type( $post_type ); 807 $this->factory->post->create_many( 10, array(807 $this->factory->post->create_many( 3, array( 808 808 'post_type' => $post_type, 809 809 'post_author' => $this->author_id 810 810 ) ); 811 811 $count1 = wp_count_posts( $post_type, 'readable' ); 812 $this->assertEquals( 10, $count1->publish );812 $this->assertEquals( 3, $count1->publish ); 813 813 add_filter( 'wp_count_posts', array( $this, 'filter_wp_count_posts' ) ); 814 814 815 815 $count2 = wp_count_posts( $post_type, 'readable' ); 816 $this->assertEquals( 7, $count2->publish );816 $this->assertEquals( 2, $count2->publish ); 817 817 818 818 remove_filter( 'wp_count_posts', array( $this, 'filter_wp_count_posts' ) ); … … 820 820 821 821 function filter_wp_count_posts( $counts ) { 822 $counts->publish = 7;822 $counts->publish = 2; 823 823 return $counts; 824 824 } 825 825 826 826 function test_wp_count_posts_insert_invalidation() { 827 $post_ids = $this->factory->post->create_many( 10);827 $post_ids = $this->factory->post->create_many( 3 ); 828 828 $initial_counts = wp_count_posts(); 829 829 … … 838 838 $after_draft_counts = wp_count_posts(); 839 839 $this->assertEquals( 1, $after_draft_counts->draft ); 840 $this->assertEquals( 9, $after_draft_counts->publish );840 $this->assertEquals( 2, $after_draft_counts->publish ); 841 841 $this->assertNotEquals( $initial_counts->publish, $after_draft_counts->publish ); 842 842 } 843 843 844 844 function test_wp_count_posts_trash_invalidation() { 845 $post_ids = $this->factory->post->create_many( 10);845 $post_ids = $this->factory->post->create_many( 3 ); 846 846 $initial_counts = wp_count_posts(); 847 847 … … 856 856 $after_trash_counts = wp_count_posts(); 857 857 $this->assertEquals( 1, $after_trash_counts->trash ); 858 $this->assertEquals( 9, $after_trash_counts->publish );858 $this->assertEquals( 2, $after_trash_counts->publish ); 859 859 $this->assertNotEquals( $initial_counts->publish, $after_trash_counts->publish ); 860 860 } -
trunk/tests/phpunit/tests/post/getPages.php
r34699 r35162 16 16 global $wpdb; 17 17 18 $this->factory->post->create_many( 15, array( 'post_type' => 'page' ) );18 $this->factory->post->create_many( 3, array( 'post_type' => 'page' ) ); 19 19 wp_cache_delete( 'last_changed', 'posts' ); 20 20 $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) ); 21 21 22 22 $pages = get_pages(); 23 $this->assertEquals( 15, count( $pages ) );23 $this->assertEquals( 3, count( $pages ) ); 24 24 $this->assertNotEmpty( $time1 = wp_cache_get( 'last_changed', 'posts' ) ); 25 25 $num_queries = $wpdb->num_queries; … … 29 29 // Again. num_queries and last_changed should remain the same. 30 30 $pages = get_pages(); 31 $this->assertEquals( 15, count( $pages ) );31 $this->assertEquals( 3, count( $pages ) ); 32 32 $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); 33 33 $this->assertEquals( $num_queries, $wpdb->num_queries ); … … 37 37 // Again with different args. last_changed should not increment because of 38 38 // different args to get_pages(). num_queries should bump by 1. 39 $pages = get_pages( array( 'number' => 10) );40 $this->assertEquals( 10, count( $pages ) );39 $pages = get_pages( array( 'number' => 2 ) ); 40 $this->assertEquals( 2, count( $pages ) ); 41 41 $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); 42 42 $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); … … 47 47 48 48 // Again. num_queries and last_changed should remain the same. 49 $pages = get_pages( array( 'number' => 10) );50 $this->assertEquals( 10, count( $pages ) );49 $pages = get_pages( array( 'number' => 2 ) ); 50 $this->assertEquals( 2, count( $pages ) ); 51 51 $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); 52 52 $this->assertEquals( $num_queries, $wpdb->num_queries ); … … 56 56 // Do the first query again. The interim queries should not affect it. 57 57 $pages = get_pages(); 58 $this->assertEquals( 15, count( $pages ) );58 $this->assertEquals( 3, count( $pages ) ); 59 59 $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); 60 60 $this->assertEquals( $num_queries, $wpdb->num_queries ); … … 69 69 70 70 // last_changed bumped so num_queries should increment. 71 $pages = get_pages( array( 'number' => 10) );72 $this->assertEquals( 10, count( $pages ) );71 $pages = get_pages( array( 'number' => 2 ) ); 72 $this->assertEquals( 2, count( $pages ) ); 73 73 $this->assertEquals( $time2, wp_cache_get( 'last_changed', 'posts' ) ); 74 74 $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); … … 89 89 // num_queries should bump after wp_delete_post() bumps last_changed. 90 90 $pages = get_pages(); 91 $this->assertEquals( 14, count( $pages ) );91 $this->assertEquals( 2, count( $pages ) ); 92 92 $this->assertEquals( $last_changed, wp_cache_get( 'last_changed', 'posts' ) ); 93 93 $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); -
trunk/tests/phpunit/tests/post/query.php
r33653 r35162 72 72 function test_the_posts_filter() { 73 73 // Create posts and clear their caches. 74 $post_ids = $this->factory->post->create_many( 10);74 $post_ids = $this->factory->post->create_many( 4 ); 75 75 foreach ( $post_ids as $post_id ) 76 76 clean_post_cache( $post_id ); … … 80 80 $query = new WP_Query( array( 81 81 'post_type' => 'post', 82 'posts_per_page' => 5,83 ) ); 84 85 // Sixth post added in filter86 $this->assertEquals( 6, count( $query->posts ) );87 $this->assertEquals( 6, $query->post_count );82 'posts_per_page' => 3, 83 ) ); 84 85 // Fourth post added in filter 86 $this->assertEquals( 4, count( $query->posts ) ); 87 $this->assertEquals( 4, $query->post_count ); 88 88 89 89 foreach ( $query->posts as $post ) { -
trunk/tests/phpunit/tests/query/conditionals.php
r34810 r35162 252 252 // 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]', 253 253 function test_paged() { 254 $this->factory->post->create_many( 15 ); 254 update_option( 'posts_per_page', 2 ); 255 $this->factory->post->create_many( 5 ); 255 256 for ( $i = 2; $i <= 3; $i++ ) { 256 257 $this->go_to("/page/{$i}/"); … … 305 306 // 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]', 306 307 function test_search_paged() { 307 $this->factory->post->create_many( 10, array( 'post_title' => 'test' ) ); 308 update_option( 'posts_per_page', 2 ); 309 $this->factory->post->create_many( 3, array( 'post_title' => 'test' ) ); 308 310 $this->go_to('/search/test/page/2/'); 309 311 $this->assertQueryTrue('is_search', 'is_paged'); … … 345 347 // 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]', 346 348 function test_category_paged() { 347 $this->factory->post->create_many( 10 ); 349 update_option( 'posts_per_page', 2 ); 350 $this->factory->post->create_many( 3 ); 348 351 $this->go_to('/category/uncategorized/page/2/'); 349 352 $this->assertQueryTrue('is_archive', 'is_category', 'is_paged'); … … 378 381 // 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]', 379 382 function test_tag_paged() { 380 $post_ids = $this->factory->post->create_many( 10 ); 383 update_option( 'posts_per_page', 2 ); 384 $post_ids = $this->factory->post->create_many( 3 ); 381 385 foreach ( $post_ids as $post_id ) 382 386 $this->factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' ); … … 424 428 // 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]', 425 429 function test_author_paged() { 430 update_option( 'posts_per_page', 2 ); 426 431 $user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) ); 427 $this->factory->post->create_many( 10, array( 'post_author' => $user_id ) );432 $this->factory->post->create_many( 3, array( 'post_author' => $user_id ) ); 428 433 $this->go_to('/author/user-a/page/2/'); 429 434 $this->assertQueryTrue('is_archive', 'is_author', 'is_paged'); … … 465 470 // '([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]', 466 471 function test_ymd_paged() { 467 $this->factory->post->create_many( 10, array( 'post_date' => '2007-09-04 00:00:00' ) ); 472 update_option( 'posts_per_page', 2 ); 473 $this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); 468 474 $this->go_to('/2007/09/04/page/2/'); 469 475 $this->assertQueryTrue('is_archive', 'is_day', 'is_date', 'is_paged'); … … 498 504 // '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]', 499 505 function test_ym_paged() { 500 $this->factory->post->create_many( 10, array( 'post_date' => '2007-09-04 00:00:00' ) ); 506 update_option( 'posts_per_page', 2 ); 507 $this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); 501 508 $this->go_to('/2007/09/page/2/'); 502 509 $this->assertQueryTrue('is_archive', 'is_date', 'is_month', 'is_paged'); … … 531 538 // '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]', 532 539 function test_y_paged() { 533 $this->factory->post->create_many( 10, array( 'post_date' => '2007-09-04 00:00:00' ) ); 540 update_option( 'posts_per_page', 2 ); 541 $this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); 534 542 $this->go_to('/2007/page/2/'); 535 543 $this->assertQueryTrue('is_archive', 'is_date', 'is_year', 'is_paged'); -
trunk/tests/phpunit/tests/query/taxQuery.php
r31346 r35162 841 841 // An empty tax query should return an empty array, not all posts. 842 842 843 $this->factory->post->create_many( 10);843 $this->factory->post->create_many( 2 ); 844 844 845 845 $query = new WP_Query( array( … … 874 874 // An empty tax query should return an empty array, not all posts. 875 875 876 $this->factory->post->create_many( 10);876 $this->factory->post->create_many( 2 ); 877 877 878 878 $query = new WP_Query( array(
Note: See TracChangeset
for help on using the changeset viewer.