WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/02/2016 07:22:17 PM (3 years ago)
Author:
ocean90
Message:

Query: Add tests for WP_Query::is_single() and get_body_class() with attachments.

See [39052]
See #38225.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/conditionals.php

    r38951 r39095  
    819819    }
    820820
     821    /**
     822     * @ticket 38225
     823     */
     824    function test_is_single_with_attachment() {
     825        $post_id = self::factory()->post->create();
     826
     827        $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array(
     828            'post_mime_type' => 'image/jpeg',
     829        ) );
     830
     831        $this->go_to( get_permalink( $attachment_id ) );
     832
     833        $q = $GLOBALS['wp_query'];
     834
     835        $this->assertTrue( is_single() );
     836        $this->assertTrue( $q->is_single );
     837        $this->assertTrue( $q->is_attachment );
     838    }
     839
    821840    function test_is_page() {
    822841        $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
Note: See TracChangeset for help on using the changeset viewer.