Changeset 31647
- Timestamp:
- 03/06/2015 08:37:08 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r31646 r31647 5092 5092 5093 5093 $check = wp_check_filetype( $file ); 5094 if ( empty( $check['ext'] ) || 'import' !== $post->post_mime_type) {5094 if ( empty( $check['ext'] ) ) { 5095 5095 return false; 5096 5096 } 5097 5097 5098 $ext = $check['ext']; 5099 5100 if ( 'import' !== $post->post_mime_type ) { 5101 return $type === $ext; 5102 } 5098 5103 5099 5104 switch ( $type ) { -
trunk/tests/phpunit/tests/post/attachments.php
r31614 r31647 440 440 } 441 441 442 public function test_wp_attachment_is() { 443 $filename = DIR_TESTDATA . '/images/test-image.jpg'; 444 $contents = file_get_contents( $filename ); 445 446 $upload = wp_upload_bits( basename( $filename ), null, $contents ); 447 $attachment_id = $this->_make_attachment( $upload ); 448 449 $this->assertTrue( wp_attachment_is_image( $attachment_id ) ); 450 $this->assertTrue( wp_attachment_is( 'image', $attachment_id ) ); 451 $this->assertFalse( wp_attachment_is( 'audio', $attachment_id ) ); 452 $this->assertFalse( wp_attachment_is( 'video', $attachment_id ) ); 453 } 454 455 public function test_wp_attachment_is_default() { 456 $filename = DIR_TESTDATA . '/images/test-image.psd'; 457 $contents = file_get_contents( $filename ); 458 459 $upload = wp_upload_bits( basename( $filename ), null, $contents ); 460 $attachment_id = $this->_make_attachment( $upload ); 461 462 $this->assertFalse( wp_attachment_is_image( $attachment_id ) ); 463 $this->assertTrue( wp_attachment_is( 'psd', $attachment_id ) ); 464 $this->assertFalse( wp_attachment_is( 'audio', $attachment_id ) ); 465 $this->assertFalse( wp_attachment_is( 'video', $attachment_id ) ); 466 } 442 467 }
Note: See TracChangeset
for help on using the changeset viewer.