Make WordPress Core

Changeset 1148 in tests for trunk/tests/image/functions.php


Ignore:
Timestamp:
11/21/2012 03:01:28 PM (13 years ago)
Author:
ryan
Message:

Pinking shears and eol-style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/image/functions.php

    r1126 r1148  
    1414     */
    1515    protected function get_mime_type( $filename ) {
    16         $mime_type = ''; 
    17         if ( extension_loaded( 'fileinfo' ) ) { 
     16        $mime_type = '';
     17        if ( extension_loaded( 'fileinfo' ) ) {
    1818            $finfo = new finfo();
    1919            $mime_type = $finfo->file( $filename, FILEINFO_MIME );
    20         } elseif ( function_exists('mime_content_type') ) { 
     20        } elseif ( function_exists('mime_content_type') ) {
    2121            $mime_type = mime_content_type( $filename );
    2222        }
     
    2626        return $mime_type;
    2727    }
    28    
     28
    2929    function test_is_image_positive() {
    3030        // these are all image files recognized by php
     
    9393            $this->assertFalse( file_is_displayable_image( DIR_TESTDATA.'/images/'.$file ), "file_is_valid_image($file) should return false" );
    9494        }
    95     }   
    96    
     95    }
     96
    9797    /**
    9898     * Test save image file and mime_types
     
    108108            'image/png'
    109109        );
    110        
     110
    111111        // Test each image editor engine
    112112        $classes = array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick');
    113113        foreach ( $classes as $class ) {
    114            
     114
    115115            // If the image editor isn't available, skip it
    116116            if ( ! call_user_func( array( $class, 'test' ) ) ) {
     
    122122            // Call wp_save_image_file
    123123            $img = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' );
    124            
     124
    125125            // Save a file as each mime type, assert it works
    126126            foreach ( $mime_types as $mime_type ) {
    127                 $file = wp_tempnam();               
     127                $file = wp_tempnam();
    128128                $ret = wp_save_image_file( $file, $img, $mime_type, 1 );
    129129                $this->assertNotEmpty( $ret );
    130130                $this->assertNotInstanceOf( 'WP_Error', $ret );
    131131                $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
    132                
     132
    133133                // Clean up
    134134                @unlink( $file );
     
    140140        }
    141141    }
    142    
     142
    143143    /**
    144144     * Test that a passed mime type overrides the extension in the filename
     
    163163            $file = wp_tempnam( 'tmp.jpg' );
    164164            $ret = $img->save( $file, $mime_type );
    165            
     165
    166166            // Make assertions
    167167            $this->assertNotEmpty( $ret );
    168168            $this->assertNotInstanceOf( 'WP_Error', $ret );
    169169            $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
    170            
     170
    171171            // Clean up
    172172            @unlink( $file );
     
    202202            $filter = create_function( '', "return '$class';" );
    203203            add_filter( 'image_editor_class', $filter );
    204            
     204
    205205            // Save the image as each file extension, check the mime type
    206206            $img = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' );
Note: See TracChangeset for help on using the changeset viewer.