mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Move wp_filesize() tests to their own file.
This aims to make the tests more discoverable and easier to expand. Includes splitting the `wp_filesize` and `pre_wp_filesize` filter tests into a separate test case. Follow-up to [52837], [52932], [54402]. Props pbearne, spacedmonkey, SergeyBiryukov. See #57171. git-svn-id: https://develop.svn.wordpress.org/trunk@54861 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
239a6c33ec
commit
e507aee79f
@ -2065,41 +2065,6 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_get_default_extension_for_mime_type( null ), 'false not returned when null as mime type supplied' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 49412
|
||||
* @covers ::wp_filesize
|
||||
*/
|
||||
function test_wp_filesize_with_nonexistent_file() {
|
||||
$file = 'nonexistent/file.jpg';
|
||||
$this->assertSame( 0, wp_filesize( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 49412
|
||||
* @covers ::wp_filesize
|
||||
*/
|
||||
function test_wp_filesize() {
|
||||
$file = DIR_TESTDATA . '/images/test-image-upside-down.jpg';
|
||||
|
||||
$this->assertSame( filesize( $file ), wp_filesize( $file ) );
|
||||
|
||||
$filter = function() {
|
||||
return 999;
|
||||
};
|
||||
|
||||
add_filter( 'wp_filesize', $filter );
|
||||
|
||||
$this->assertSame( 999, wp_filesize( $file ) );
|
||||
|
||||
$pre_filter = function() {
|
||||
return 111;
|
||||
};
|
||||
|
||||
add_filter( 'pre_wp_filesize', $pre_filter );
|
||||
|
||||
$this->assertSame( 111, wp_filesize( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 55505
|
||||
* @covers ::wp_recursive_ksort
|
||||
|
||||
53
tests/phpunit/tests/functions/wpFilesize.php
Normal file
53
tests/phpunit/tests/functions/wpFilesize.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests for the wp_filesize() function.
|
||||
*
|
||||
* @group functions.php
|
||||
* @covers ::wp_filesize
|
||||
*/
|
||||
class Tests_Functions_wpFilesize extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 49412
|
||||
*/
|
||||
function test_wp_filesize() {
|
||||
$file = DIR_TESTDATA . '/images/test-image-upside-down.jpg';
|
||||
|
||||
$this->assertSame( filesize( $file ), wp_filesize( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 49412
|
||||
*/
|
||||
function test_wp_filesize_filters() {
|
||||
$file = DIR_TESTDATA . '/images/test-image-upside-down.jpg';
|
||||
|
||||
add_filter(
|
||||
'wp_filesize',
|
||||
static function() {
|
||||
return 999;
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertSame( 999, wp_filesize( $file ) );
|
||||
|
||||
add_filter(
|
||||
'pre_wp_filesize',
|
||||
static function() {
|
||||
return 111;
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertSame( 111, wp_filesize( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 49412
|
||||
*/
|
||||
function test_wp_filesize_with_nonexistent_file() {
|
||||
$file = 'nonexistent/file.jpg';
|
||||
|
||||
$this->assertSame( 0, wp_filesize( $file ) );
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user