Query: Add tests for WP_Query::is_single()
and get_body_class()
with attachments.
See [39052] See #38225. git-svn-id: https://develop.svn.wordpress.org/trunk@39095 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4ab3f9fc3a
commit
4dfb71c3b5
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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" );
|
||||
|
Loading…
Reference in New Issue
Block a user