diff --git a/tests/phpunit/tests/post/getBodyClass.php b/tests/phpunit/tests/post/getBodyClass.php index 771b8e3a02..8501c34574 100644 --- a/tests/phpunit/tests/post/getBodyClass.php +++ b/tests/phpunit/tests/post/getBodyClass.php @@ -158,4 +158,23 @@ class Tests_Post_GetBodyClass extends WP_UnitTestCase { $this->assertContains( 'post-template-cpt', $class ); $this->assertContains( 'post-template-templatescpt-php', $class ); } + + /** + * @ticket 38225 + */ + public function test_attachment_body_classes() { + $post_id = self::factory()->post->create(); + + $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array( + 'post_mime_type' => 'image/jpeg', + ) ); + + $this->go_to( get_permalink( $attachment_id ) ); + + $class = get_body_class(); + + $this->assertContains( 'attachment', $class ); + $this->assertContains( "attachmentid-{$attachment_id}", $class ); + $this->assertContains( 'attachment-jpeg', $class ); + } } diff --git a/tests/phpunit/tests/query/conditionals.php b/tests/phpunit/tests/query/conditionals.php index 4a6d2be548..5085052d69 100644 --- a/tests/phpunit/tests/query/conditionals.php +++ b/tests/phpunit/tests/query/conditionals.php @@ -818,6 +818,25 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->set_permalink_structure(); } + /** + * @ticket 38225 + */ + function test_is_single_with_attachment() { + $post_id = self::factory()->post->create(); + + $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array( + 'post_mime_type' => 'image/jpeg', + ) ); + + $this->go_to( get_permalink( $attachment_id ) ); + + $q = $GLOBALS['wp_query']; + + $this->assertTrue( is_single() ); + $this->assertTrue( $q->is_single ); + $this->assertTrue( $q->is_attachment ); + } + function test_is_page() { $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); $this->go_to( "/?page_id=$post_id" );