Media/Unit Tests: ensure that image sizes are indeed removed when errors are raised before assertions in Tests_Media
.
See #36588. git-svn-id: https://develop.svn.wordpress.org/trunk@37328 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fe85e78329
commit
ec0614cf17
@ -7,6 +7,11 @@
|
||||
class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
function tearDown() {
|
||||
$this->remove_added_uploads();
|
||||
|
||||
remove_image_size( 'test-size' );
|
||||
remove_image_size( 'false-height' );
|
||||
remove_image_size( 'false-width' );
|
||||
remove_image_size( 'off-by-one' );
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
@ -69,12 +74,12 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
// look for a size by name
|
||||
$image = image_get_intermediate_size( $id, 'test-size' );
|
||||
|
||||
// cleanup
|
||||
remove_image_size( 'test-size' );
|
||||
|
||||
// test for the expected string because the array will by definition
|
||||
// return with the correct height and width attributes
|
||||
$this->assertTrue( strpos( $image['file'], '330x220' ) > 0 );
|
||||
|
||||
// cleanup
|
||||
remove_image_size( 'test-size' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,11 +101,6 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
// test for the expected string because the array will by definition
|
||||
// return with the correct height and width attributes
|
||||
$this->assertTrue( strpos( $image['file'], '330x220' ) > 0 );
|
||||
|
||||
// cleanup
|
||||
remove_image_size( 'test-size' );
|
||||
remove_image_size( 'false-height' );
|
||||
remove_image_size( 'false-width' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,11 +123,6 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
// you have to test for the string because the image will by definition
|
||||
// return with the correct height and width attributes
|
||||
$this->assertTrue( strpos( $image['file'], '450x300' ) > 0 );
|
||||
|
||||
// cleanup
|
||||
remove_image_size( 'test-size' );
|
||||
remove_image_size( 'false-height' );
|
||||
remove_image_size( 'false-width' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,10 +144,6 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
// you have to test for the string because the image will by definition
|
||||
// return with the correct height and width attributes
|
||||
$this->assertFalse( $image );
|
||||
|
||||
// cleanup
|
||||
remove_image_size( 'false-height' );
|
||||
remove_image_size( 'false-width' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,10 +171,6 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
// test for the expected string because the array will by definition
|
||||
// return with the correct height and width attributes
|
||||
$this->assertTrue( strpos( $image['file'], $image_w . 'x' . $image_h ) > 0 );
|
||||
|
||||
// cleanup
|
||||
remove_image_size( 'test-size' );
|
||||
remove_image_size( 'false-height' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,10 +199,6 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
// test for the expected string because the array will by definition
|
||||
// return with the correct height and width attributes
|
||||
$this->assertTrue( strpos( $image['file'], $image_w . 'x' . $image_h ) > 0 );
|
||||
|
||||
// cleanup
|
||||
remove_image_size( 'test-size' );
|
||||
remove_image_size( 'false-height' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,8 +223,5 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
$image = image_get_intermediate_size( $id, array( 0, $height ) );
|
||||
|
||||
$this->assertTrue( strpos( $image['file'], $width . 'x' . $height ) > 0 );
|
||||
|
||||
// cleanup
|
||||
remove_image_size( 'off-by-one' );
|
||||
}
|
||||
}
|
||||
|
@ -584,14 +584,19 @@ VIDEO;
|
||||
$_wp_additional_image_sizes = array();
|
||||
}
|
||||
|
||||
remove_image_size( 'test-size' );
|
||||
|
||||
$this->assertArrayNotHasKey( 'test-size', $_wp_additional_image_sizes );
|
||||
add_image_size( 'test-size', 200, 600 );
|
||||
$this->assertArrayHasKey( 'test-size', $_wp_additional_image_sizes );
|
||||
$this->assertEquals( 200, $_wp_additional_image_sizes['test-size']['width'] );
|
||||
$this->assertEquals( 600, $_wp_additional_image_sizes['test-size']['height'] );
|
||||
|
||||
$sizes = $_wp_additional_image_sizes;
|
||||
|
||||
// Clean up
|
||||
remove_image_size( 'test-size' );
|
||||
|
||||
$this->assertArrayHasKey( 'test-size', $sizes );
|
||||
$this->assertEquals( 200, $sizes['test-size']['width'] );
|
||||
$this->assertEquals( 600, $sizes['test-size']['height'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user