WordPress.org

Make WordPress Core

Changeset 1126 in tests


Ignore:
Timestamp:
11/13/2012 01:35:46 PM (6 years ago)
Author:
ryan
Message:

wp_crop_image() tests. see #WP6821

File:
1 edited

Legend:

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

    r1121 r1126  
    243243        }
    244244    }
     245
     246    public function test_wp_crop_image_file() {
     247        $file = wp_crop_image( DIR_TESTDATA . '/images/canola.jpg',
     248                              0, 0, 100, 100, 100, 100 );
     249        $this->assertNotInstanceOf( 'WP_Error', $file );
     250        $this->assertFileExists( $file );
     251        $image = WP_Image_Editor::get_instance( $file );
     252        $size = $image->get_size();
     253        $this->assertEquals( 100, $size['height'] );
     254        $this->assertEquals( 100, $size['width'] );
     255    }
     256
     257    public function test_wp_crop_image_url() {
     258        $file = wp_crop_image( 'http://asdftestblog1.files.wordpress.com/2008/04/canola.jpg',
     259                              0, 0, 100, 100, 100, 100, false,
     260                              DIR_TESTDATA . '/images/' . rand_str() . '.jpg' );
     261        $this->assertNotInstanceOf( 'WP_Error', $file );
     262        $this->assertFileExists( $file );
     263        $image = WP_Image_Editor::get_instance( $file );
     264        $size = $image->get_size();
     265        $this->assertEquals( 100, $size['height'] );
     266        $this->assertEquals( 100, $size['width'] );
     267    }
     268
     269    public function test_wp_crop_image_file_not_exist() {
     270        $file = wp_crop_image( DIR_TESTDATA . '/images/canoladoesnotexist.jpg',
     271                              0, 0, 100, 100, 100, 100 );
     272        $this->assertInstanceOf( 'WP_Error', $file );
     273    }
     274
     275    public function test_wp_crop_image_url_not_exist() {
     276        $file = wp_crop_image( 'http://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',
     277                              0, 0, 100, 100, 100, 100 );
     278        $this->assertInstanceOf( 'WP_Error', $file );
     279    }
    245280}
Note: See TracChangeset for help on using the changeset viewer.