Changeset 35162 for trunk/tests/phpunit/tests/post.php
- Timestamp:
- 10/14/2015 09:23:03 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.