WordPress.org

Make WordPress Core

Changeset 37328


Ignore:
Timestamp:
04/29/2016 05:51:54 PM (4 years ago)
Author:
wonderboymusic
Message:

Media/Unit Tests: ensure that image sizes are indeed removed when errors are raised before assertions in Tests_Media.

See #36588.

Location:
trunk/tests/phpunit/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/intermediate_size.php

    r35348 r37328  
    88    function tearDown() {
    99        $this->remove_added_uploads();
     10
     11        remove_image_size( 'test-size' );
     12        remove_image_size( 'false-height' );
     13        remove_image_size( 'false-width' );
     14        remove_image_size( 'off-by-one' );
    1015        parent::tearDown();
    1116    }
     
    7075        $image = image_get_intermediate_size( $id, 'test-size' );
    7176
    72         // test for the expected string because the array will by definition
    73         // return with the correct height and width attributes
    74         $this->assertTrue( strpos( $image['file'], '330x220' ) > 0 );
    75 
    7677        // cleanup
    7778        remove_image_size( 'test-size' );
     79
     80        // test for the expected string because the array will by definition
     81        // return with the correct height and width attributes
     82        $this->assertTrue( strpos( $image['file'], '330x220' ) > 0 );
    7883    }
    7984
     
    97102        // return with the correct height and width attributes
    98103        $this->assertTrue( strpos( $image['file'], '330x220' ) > 0 );
    99 
    100         // cleanup
    101         remove_image_size( 'test-size' );
    102         remove_image_size( 'false-height' );
    103         remove_image_size( 'false-width' );
    104104    }
    105105
     
    124124        // return with the correct height and width attributes
    125125        $this->assertTrue( strpos( $image['file'], '450x300' ) > 0 );
    126 
    127         // cleanup
    128         remove_image_size( 'test-size' );
    129         remove_image_size( 'false-height' );
    130         remove_image_size( 'false-width' );
    131126    }
    132127
     
    150145        // return with the correct height and width attributes
    151146        $this->assertFalse( $image );
    152 
    153         // cleanup
    154         remove_image_size( 'false-height' );
    155         remove_image_size( 'false-width' );
    156147    }
    157148
     
    181172        // return with the correct height and width attributes
    182173        $this->assertTrue( strpos( $image['file'], $image_w . 'x' . $image_h ) > 0 );
    183 
    184         // cleanup
    185         remove_image_size( 'test-size' );
    186         remove_image_size( 'false-height' );
    187174    }
    188175
     
    213200        // return with the correct height and width attributes
    214201        $this->assertTrue( strpos( $image['file'], $image_w . 'x' . $image_h ) > 0 );
    215 
    216         // cleanup
    217         remove_image_size( 'test-size' );
    218         remove_image_size( 'false-height' );
    219202    }
    220203
     
    241224
    242225        $this->assertTrue( strpos( $image['file'], $width . 'x' . $height ) > 0 );
    243 
    244         // cleanup
    245         remove_image_size( 'off-by-one' );
    246226    }
    247227}
  • trunk/tests/phpunit/tests/media.php

    r37035 r37328  
    585585        }
    586586
     587        remove_image_size( 'test-size' );
     588
    587589        $this->assertArrayNotHasKey( 'test-size', $_wp_additional_image_sizes );
    588590        add_image_size( 'test-size', 200, 600 );
    589         $this->assertArrayHasKey( 'test-size', $_wp_additional_image_sizes );
    590         $this->assertEquals( 200, $_wp_additional_image_sizes['test-size']['width'] );
    591         $this->assertEquals( 600, $_wp_additional_image_sizes['test-size']['height'] );
     591
     592        $sizes = $_wp_additional_image_sizes;
    592593
    593594        // Clean up
    594595        remove_image_size( 'test-size' );
     596
     597        $this->assertArrayHasKey( 'test-size', $sizes );
     598        $this->assertEquals( 200, $sizes['test-size']['width'] );
     599        $this->assertEquals( 600, $sizes['test-size']['height'] );
    595600    }
    596601
Note: See TracChangeset for help on using the changeset viewer.