Make WordPress Core

Changeset 938 in tests for trunk/tests/xmlrpc/wp/uploadFile.php


Ignore:
Timestamp:
07/26/2012 10:42:24 PM (14 years ago)
Author:
markoheijnen
Message:

XML-RPC: Added mime test to wp.uploadFile. Also removed base64_encode() since it breaks the image

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/xmlrpc/wp/uploadFile.php

    r928 r938  
    55 */
    66class Tests_XMLRPC_wp_uploadFile extends WP_XMLRPC_UnitTestCase {
     7
    78        function test_valid_attachment() {
    89                $this->make_user_by_role( 'editor' );
    910
    1011                // create attachment
    11                 $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
     12                $filename = ( DIR_TESTDATA . '/images/a2-small.jpg' );
    1213                $contents = file_get_contents( $filename );
    1314                $data = array(
    1415                        'name' => 'a2-small.jpg',
    1516                        'type' => 'image/jpeg',
    16                         'bits' => base64_encode( $contents )
     17                        'bits' => $contents
    1718                );
    1819
    … …  
    3031
    3132        /**
    32          * @ticket 21292
     33         * @tickets 21292
    3334         */
    3435        function test_network_limit() {
    … …  
    3839
    3940                // create attachment
    40                 $filename = ( DIR_TESTDATA.'/images/canola.jpg' );
     41                $filename = ( DIR_TESTDATA . '/images/canola.jpg' );
    4142                $contents = file_get_contents( $filename );
    4243                $data = array(
    43                         'name' => 'a2-small.jpg',
     44                        'name' => 'canola.jpg',
    4445                        'type' => 'image/jpeg',
    45                         'bits' => base64_encode( $contents )
     46                        'bits' => $contents
    4647                );
    4748
    … …  
    4950
    5051                // Only multisite should have a limit
    51                 if ( is_multisite() ) {
     52                if ( is_multisite() )
    5253                        $this->assertInstanceOf( 'IXR_Error', $result );
    53                 }
    54                 else {
     54                else
    5555                        $this->assertNotInstanceOf( 'IXR_Error', $result );
    56                 }
     56        }
    5757
     58        /**
     59         * @ticket 11946
     60         */
     61        function test_valid_mime() {
     62                $this->make_user_by_role( 'editor' );
     63
     64                // create attachment
     65                $filename = ( DIR_TESTDATA . '/images/test-image-mime-jpg.png' );
     66                $contents = file_get_contents( $filename );
     67                $data = array(
     68                        'name' => 'test-image-mime-jpg.png',
     69                        'type' => 'image/png',
     70                        'bits' => $contents
     71                );
     72
     73                $result = $this->myxmlrpcserver->mw_newMediaObject( array( 0, 'editor', 'editor', $data ) );
     74
     75                $this->assertNotInstanceOf( 'IXR_Error', $result );
     76
     77                $this->assertEquals( 'image/jpeg', $result['type'] );
    5878        }
    5979}
Note: See TracChangeset for help on using the changeset viewer.