Make WordPress Core

Ticket #22356: 22356.8.tests.diff

File 22356.8.tests.diff, 4.2 KB (added by scribu, 12 years ago)
  • includes/mock-image-editor.php

    diff --git includes/mock-image-editor.php includes/mock-image-editor.php
    index c7d0a5a..3722e22 100644
    if (class_exists( 'WP_Image_Editor' ) ) : 
    77                public static $load_return = true;
    88                public static $test_return = true;
    99
    10                 protected function load() {
     10                public function load() {
    1111                        return self::$load_return;
    1212                }
    1313                public static function test() {
    if (class_exists( 'WP_Image_Editor' ) ) : 
    3939                }
    4040        }
    4141
    42 endif;
    43  No newline at end of file
     42endif;
  • tests/image/editor.php

    diff --git tests/image/editor.php tests/image/editor.php
    index 2000e67..51d88d2 100644
    class Tests_Image_Editor extends WP_UnitTestCase { 
    1717         * Setup test fixture
    1818         */
    1919        public function setup() {
    20                 if ( !class_exists( 'WP_Image_Editor' ) )
    21                         $this->markTestSkipped();
     20                require_once( ABSPATH . WPINC . '/class-wp-image-editor.php' );
    2221
    23                 // Include our custom mock
    2422                include_once( DIR_TESTDATA . '/../includes/mock-image-editor.php' );
    2523
    2624                // Mock up an abstract image editor based on WP_Image_Editor
    class Tests_Image_Editor extends WP_UnitTestCase { 
    6159        }
    6260
    6361        /**
    64          * Test get_instance where load returns true
     62         * Test wp_get_image_editor() where load returns true
    6563         * @ticket 6821
    6664         */
    67         public function test_get_instance_load_returns_true() {
     65        public function test_get_editor_load_returns_true() {
    6866
    6967                // Swap out the PHPUnit mock with our custom mock
    7068                $func = create_function( '', 'return "WP_Image_Editor_Mock";');
    class Tests_Image_Editor extends WP_UnitTestCase { 
    7573                WP_Image_Editor_Mock::$load_return = true;
    7674
    7775                // Load an image
    78                 $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' );
     76                $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
    7977
    8078                // Everything should work
    8179                $this->assertInstanceOf( 'WP_Image_Editor_Mock', $editor );
    class Tests_Image_Editor extends WP_UnitTestCase { 
    8583        }
    8684
    8785        /**
    88          * Test get_instance where load returns false
     86         * Test wp_get_image_editor() where load returns false
    8987         * @ticket 6821
    9088         */
    91         public function test_get_instance_load_returns_false() {
     89        public function test_get_editor_load_returns_false() {
    9290
    9391                // Swap out the PHPUnit mock with our custom mock
    9492                $func = create_function( '', 'return "WP_Image_Editor_Mock";');
    class Tests_Image_Editor extends WP_UnitTestCase { 
    9997                WP_Image_Editor_Mock::$load_return = new WP_Error();
    10098
    10199                // Load an image
    102                 $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' );
     100                $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
    103101
    104102                // Everything should work
    105103                $this->assertInstanceOf( 'WP_Error', $editor );
    class Tests_Image_Editor extends WP_UnitTestCase { 
    115113        public function test_set_quality() {
    116114
    117115                // Get an editor
    118                 $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' );
     116                $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
    119117
    120118                // Make quality readable
    121119                $property = new ReflectionProperty( $editor, 'quality' );
    class Tests_Image_Editor extends WP_UnitTestCase { 
    142140        public function test_generate_filename() {
    143141
    144142                // Get an editor
    145                 $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' );
     143                $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
     144
    146145                $property = new ReflectionProperty( $editor, 'size' );
    147146                $property->setAccessible( true );
    148147                $property->setValue( $editor, array(
    class Tests_Image_Editor extends WP_UnitTestCase { 
    172171         */
    173172        public function test_get_size() {
    174173
    175                 $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' );
     174                $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
    176175
    177176                // Size should be false by default
    178177                $this->assertNull( $editor->get_size() );
    class Tests_Image_Editor extends WP_UnitTestCase { 
    194193         * @ticket 6821
    195194         */
    196195        public function test_get_suffix() {
    197                 $editor = WP_Image_Editor::get_instance( DIR_TESTDATA . '/images/canola.jpg' );
     196                $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
    198197
    199198                // Size should be false by default
    200199                $this->assertFalse( $editor->get_suffix() );