Tests: Convert a few more function_exists() and extension_loaded() checks to @requires annotations.

This better utilizes the PHPUnit native functionality.

Follow-up to [49024].

See #50639, #50640.

git-svn-id: https://develop.svn.wordpress.org/trunk@49025 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-09-21 13:25:38 +00:00
parent b984a64c98
commit 6242c634ee
9 changed files with 27 additions and 82 deletions
+5 -20
View File
@@ -942,12 +942,9 @@ class Tests_Functions extends WP_UnitTestCase {
/**
* @ticket 28786
* @requires function mb_detect_order
*/
function test_wp_json_encode_non_utf8() {
if ( ! function_exists( 'mb_detect_order' ) ) {
$this->markTestSkipped( 'mbstring extension not available.' );
}
$charsets = mb_detect_order();
$old_charsets = $charsets;
if ( ! in_array( 'EUC-JP', $charsets, true ) ) {
@@ -967,12 +964,9 @@ class Tests_Functions extends WP_UnitTestCase {
/**
* @ticket 28786
* @requires function mb_detect_order
*/
function test_wp_json_encode_non_utf8_in_array() {
if ( ! function_exists( 'mb_detect_order' ) ) {
$this->markTestSkipped( 'mbstring extension not available.' );
}
$charsets = mb_detect_order();
$old_charsets = $charsets;
if ( ! in_array( 'EUC-JP', $charsets, true ) ) {
@@ -1210,24 +1204,18 @@ class Tests_Functions extends WP_UnitTestCase {
/**
* @ticket 39550
* @dataProvider _wp_check_filetype_and_ext_data
* @requires extension fileinfo
*/
function test_wp_check_filetype_and_ext( $file, $filename, $expected ) {
if ( ! extension_loaded( 'fileinfo' ) ) {
$this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
}
$this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
}
/**
* @ticket 39550
* @group ms-excluded
* @requires extension fileinfo
*/
function test_wp_check_filetype_and_ext_with_filtered_svg() {
if ( ! extension_loaded( 'fileinfo' ) ) {
$this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
}
$file = DIR_TESTDATA . '/uploads/video-play.svg';
$filename = 'video-play.svg';
@@ -1247,12 +1235,9 @@ class Tests_Functions extends WP_UnitTestCase {
/**
* @ticket 39550
* @group ms-excluded
* @requires extension fileinfo
*/
function test_wp_check_filetype_and_ext_with_filtered_woff() {
if ( ! extension_loaded( 'fileinfo' ) ) {
$this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
}
$file = DIR_TESTDATA . '/uploads/dashicons.woff';
$filename = 'dashicons.woff';