Make WordPress Core

Changeset 39095


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

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

See [39052]
See #38225.

Location:
trunk/tests/phpunit/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getBodyClass.php

    r38951 r39095  
    159159        $this->assertContains( 'post-template-templatescpt-php', $class );
    160160    }
     161
     162    /**
     163     * @ticket 38225
     164     */
     165    public function test_attachment_body_classes() {
     166        $post_id = self::factory()->post->create();
     167
     168        $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array(
     169            'post_mime_type' => 'image/jpeg',
     170        ) );
     171
     172        $this->go_to( get_permalink( $attachment_id ) );
     173
     174        $class = get_body_class();
     175
     176        $this->assertContains( 'attachment', $class );
     177        $this->assertContains( "attachmentid-{$attachment_id}", $class );
     178        $this->assertContains( 'attachment-jpeg', $class );
     179    }
    161180}
  • 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.