WordPress.org

Make WordPress Core

Changeset 1156 in tests


Ignore:
Timestamp:
11/23/12 16:32:35 (17 months ago)
Author:
ryan
Message:

wp_prepare_attachment_for_js() tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/media.php

    r951 r1156  
    110110        $this->assertFalse( wp_oembed_remove_provider( 'http://foo.bar/*' ) ); 
    111111    } 
     112 
     113    function test_wp_prepare_attachment_for_js() { 
     114        // Attachment without media 
     115        $id = wp_insert_attachment(array( 
     116            'post_status' => 'publish', 
     117            'post_title' => 'Prepare', 
     118            'post_content_filtered' => 'Prepare', 
     119            'post_type' => 'post' 
     120        )); 
     121        $post = get_post( $id ); 
     122 
     123        $prepped = wp_prepare_attachment_for_js( $post ); 
     124        $this->assertInternalType( 'array', $prepped ); 
     125        $this->assertEquals( 0, $prepped['uploadedTo'] ); 
     126        $this->assertEquals( '', $prepped['mime'] ); 
     127        $this->assertEquals( '', $prepped['type'] ); 
     128        $this->assertEquals( '', $prepped['subtype'] ); 
     129        $this->assertEquals( '', $prepped['url'] ); 
     130        $this->assertEquals( site_url( 'wp-includes/images/crystal/default.png' ), $prepped['icon'] ); 
     131 
     132        // Fake a mime 
     133        $post->post_mime_type = 'image/jpeg'; 
     134        $prepped = wp_prepare_attachment_for_js( $post ); 
     135        $this->assertEquals( 'image/jpeg', $prepped['mime'] ); 
     136        $this->assertEquals( 'image', $prepped['type'] ); 
     137        $this->assertEquals( 'jpeg', $prepped['subtype'] ); 
     138 
     139        // Fake a mime without a slash. See #WP22532 
     140        $post->post_mime_type = 'image'; 
     141        $prepped = wp_prepare_attachment_for_js( $post ); 
     142        $this->assertEquals( 'image', $prepped['mime'] ); 
     143        $this->assertEquals( 'image', $prepped['type'] ); 
     144        $this->assertEquals( '', $prepped['subtype'] ); 
     145    } 
    112146} 
Note: See TracChangeset for help on using the changeset viewer.