* Fix the horrendous whitespace in `tests/media.php`

* Suppress the deprecated function notice for `wp_convert_bytes_to_hr()`
* Add assertions for `size_format()`

See #25282.




git-svn-id: https://develop.svn.wordpress.org/trunk@25382 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2013-09-12 04:55:24 +00:00
parent 1e460fd6e2
commit 9cb4234c3f
1 changed files with 105 additions and 84 deletions

View File

@ -19,6 +19,22 @@ CAP;
$this->img_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $this->img_name;
$this->img_html = '<img src="' . $this->img_url . '"/>';
$this->img_dimensions = array( 'width' => 100, 'height' => 100 );
add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) );
}
function tearDown() {
parent::tearDown();
remove_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) );
}
function deprecated_function_run( $function ) {
if ( in_array( $function, array( 'wp_convert_bytes_to_hr' ) ) )
add_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) );
}
function deprecated_function_trigger_error() {
remove_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) );
return false;
}
function test_img_caption_shortcode_added() {
@ -163,6 +179,11 @@ CAP;
$this->assertEquals( '1MB', wp_convert_bytes_to_hr( $mb ) );
$this->assertEquals( '1kB', wp_convert_bytes_to_hr( $kb ) );
$this->assertEquals( '1 TB', size_format( $tb ) );
$this->assertEquals( '1 GB', size_format( $gb ) );
$this->assertEquals( '1 MB', size_format( $mb ) );
$this->assertEquals( '1 kB', size_format( $kb ) );
// now some values around
$hr = wp_convert_bytes_to_hr( $tb + $tb / 2 + $mb );
$this->assertTrue( abs( 1.50000095367 - (float) str_replace( ',', '.', $hr ) ) < 0.0001 );