Skip to content

Commit 71183db

Browse files
committed
Tests: Cover post MIME type retrieval.
Verify that `get_post_mime_type()` returns the stored attachment MIME type and returns `false` for a nonexistent post. Reuse existing `get_post()` coverage for input resolution. Developed in: #15145 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@65098 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4f0b127 commit 71183db

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Tests for get_post_mime_type().
4+
*
5+
* @group post
6+
*
7+
* @covers ::get_post_mime_type
8+
*/
9+
class Tests_Post_GetPostMimeType extends WP_UnitTestCase {
10+
11+
/**
12+
* @ticket 65819
13+
*/
14+
public function test_returns_false_for_nonexistent_post() {
15+
$this->assertFalse( get_post_mime_type( PHP_INT_MAX ) );
16+
}
17+
18+
/**
19+
* @ticket 65819
20+
*/
21+
public function test_returns_stored_mime_type_for_attachment() {
22+
$attachment_id = self::factory()->attachment->create_object(
23+
array(
24+
'post_mime_type' => 'image/jpeg',
25+
'post_type' => 'attachment',
26+
)
27+
);
28+
29+
$this->assertSame( 'image/jpeg', get_post_mime_type( $attachment_id ) );
30+
}
31+
}

0 commit comments

Comments
 (0)