mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Add unit tests for wp_attachment_is(), checks the whitelist and arbitrary extension.
See #25275. git-svn-id: https://develop.svn.wordpress.org/trunk@31647 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -439,4 +439,29 @@ class Tests_Post_Attachments extends WP_UnitTestCase {
|
||||
$_SERVER['HTTP_HOST'] = $http_host;
|
||||
}
|
||||
|
||||
public function test_wp_attachment_is() {
|
||||
$filename = DIR_TESTDATA . '/images/test-image.jpg';
|
||||
$contents = file_get_contents( $filename );
|
||||
|
||||
$upload = wp_upload_bits( basename( $filename ), null, $contents );
|
||||
$attachment_id = $this->_make_attachment( $upload );
|
||||
|
||||
$this->assertTrue( wp_attachment_is_image( $attachment_id ) );
|
||||
$this->assertTrue( wp_attachment_is( 'image', $attachment_id ) );
|
||||
$this->assertFalse( wp_attachment_is( 'audio', $attachment_id ) );
|
||||
$this->assertFalse( wp_attachment_is( 'video', $attachment_id ) );
|
||||
}
|
||||
|
||||
public function test_wp_attachment_is_default() {
|
||||
$filename = DIR_TESTDATA . '/images/test-image.psd';
|
||||
$contents = file_get_contents( $filename );
|
||||
|
||||
$upload = wp_upload_bits( basename( $filename ), null, $contents );
|
||||
$attachment_id = $this->_make_attachment( $upload );
|
||||
|
||||
$this->assertFalse( wp_attachment_is_image( $attachment_id ) );
|
||||
$this->assertTrue( wp_attachment_is( 'psd', $attachment_id ) );
|
||||
$this->assertFalse( wp_attachment_is( 'audio', $attachment_id ) );
|
||||
$this->assertFalse( wp_attachment_is( 'video', $attachment_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user