Make WordPress Core

Changeset 865 in tests for trunk/wp-testcase/test_query.php


Ignore:
Timestamp:
07/02/2012 06:15:04 PM (14 years ago)
Author:
nacin
Message:

For query tests that don't require a post (or comment) to pass, test twice - with and without posts/comments.

Remove cruft. Uncomment knownWPBug (it passes in 3.5, but the ticket is currently open for discussion).

Remove @ticket, as these get picked up as groups.

Exclude final file to be ported, this time with a relative path. see #97.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-testcase/test_query.php

    r864 r865  
    3131                parent::tearDown();
    3232                $GLOBALS['wp_rewrite']->init();
    33         }
    34 
    35         function _all_post_ids( $type='post' ) {
    36                 global $wpdb;
    37                 return $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s and post_status='publish'", $type ) );
    3833        }
    3934
     
    10095        function test_post_comments_feed() {
    10196                $post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
    102                 // Comments aren't needed for this test to pass.
    103                 // $this->factory->comment->create_post_comments( $post_id, 2 );
     97                $this->factory->comment->create_post_comments( $post_id, 2 );
     98                $this->go_to( get_post_comments_feed_link( $post_id ) );
     99                $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
     100        }
     101
     102
     103        function test_post_comments_feed_with_no_comments() {
     104                $post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
    104105                $this->go_to( get_post_comments_feed_link( $post_id ) );
    105106                $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
     
    162163                $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
    163164                foreach ( $page_ids as $page_id ) {
    164                         // Comments aren't needed for this test to pass.
    165                         // $this->factory->comment->create_post_comments( $page_id, 2 );
    166 
     165                        $this->factory->comment->create_post_comments( $page_id, 2 );
    167166                        $url = get_permalink( $page_id );
    168167                        $this->go_to("{$url}feed/");
     
    175174                        $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID );
    176175                }
    177 
     176        }
     177
     178        function test_page_feed_with_no_comments() {
     179                $page_ids = array();
     180                $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
     181                $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
     182                $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
     183                foreach ( $page_ids as $page_id ) {
     184                        $url = get_permalink( $page_id );
     185                        $this->go_to("{$url}feed/");
     186
     187                        // make sure the correct wp_query flags are set
     188                        $this->assertQueryTrue('is_page', 'is_singular', 'is_feed', 'is_comment_feed');
     189
     190                        // make sure the correct page was fetched
     191                        global $wp_query;
     192                        $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID );
     193                }
    178194        }
    179195
     
    185201                $page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
    186202                foreach ( $page_ids as $page_id ) {
    187                         // Comments aren't needed for this test to pass.
    188                         // $this->factory->comment->create_post_comments( $page_id, 2 );
     203                        $this->factory->comment->create_post_comments( $page_id, 2 );
    189204
    190205                        $url = get_permalink( $page_id );
     
    344359
    345360        function test_search_encoded_chars() {
    346                 // $this->knownWPBug(13961);
     361                $this->knownWPBug(13961);
    347362                $this->go_to('/search/F%C3%BCnf%2Bbar/');
    348363                $this->assertEquals( get_query_var( 's' ), 'Fünf+bar' );
     
    406421                foreach ( $post_ids as $post_id )
    407422                        $this->factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' );
    408                 // $this->markTestSkipped(); // tag-a doesn't have enough posts -> 404
    409423                $this->go_to('/tag/tag-a/page/2/');
    410424                $this->assertQueryTrue('is_archive', 'is_tag', 'is_paged');
     
    448462        function test_author() {
    449463                $user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
    450                 // A post isn't needed for this test to pass.
    451                 // $this->factory->post->create( array( 'post_author' => $user_id ) );
     464                $this->factory->post->create( array( 'post_author' => $user_id ) );
     465                $this->go_to('/author/user-a/');
     466                $this->assertQueryTrue('is_archive', 'is_author');
     467        }
     468
     469        function test_author_with_no_posts() {
     470                $user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
    452471                $this->go_to('/author/user-a/');
    453472                $this->assertQueryTrue('is_archive', 'is_author');
     
    588607                        'post_content' => 'Page 1 <!--nextpage--> Page 2'
    589608                ) );
    590                 // $this->markTestSkipped(); // @todo post doesn't exist in Data Set 1
    591                 // and the short version
    592609                $this->go_to('/2007/09/04/a-post-with-multiple-pages/2/');
    593610                // should is_paged be true also?
Note: See TracChangeset for help on using the changeset viewer.