From c9ff475e1fe63de1356bc6a3792e6fd836a8c587 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 18 Oct 2023 10:39:19 +0000 Subject: [PATCH] Tests: Remove some unnecessary `function_exists()` checks for compat functions. Each of these functions already has a separate test for availability. If any of them are unavailable, then the test should fail rather than be skipped. Follow-up to [52038], [52039], [52040]. Props johnbillion. See #59647. git-svn-id: https://develop.svn.wordpress.org/trunk@56969 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/compat/arrayKeyFirst.php | 9 +-------- tests/phpunit/tests/compat/arrayKeyLast.php | 6 +----- tests/phpunit/tests/compat/strContains.php | 9 +-------- tests/phpunit/tests/compat/strEndsWith.php | 9 +-------- tests/phpunit/tests/compat/strStartsWith.php | 9 +-------- 5 files changed, 5 insertions(+), 37 deletions(-) diff --git a/tests/phpunit/tests/compat/arrayKeyFirst.php b/tests/phpunit/tests/compat/arrayKeyFirst.php index b3b97ad464..28db82e363 100644 --- a/tests/phpunit/tests/compat/arrayKeyFirst.php +++ b/tests/phpunit/tests/compat/arrayKeyFirst.php @@ -24,14 +24,7 @@ class Tests_Compat_arrayKeyFirst extends WP_UnitTestCase { * @param array $arr The array to get first key from. */ public function test_array_key_first( $expected, $arr ) { - if ( ! function_exists( 'array_key_first' ) ) { - $this->markTestSkipped( 'array_key_first() is not available.' ); - } else { - $this->assertSame( - $expected, - array_key_first( $arr ) - ); - } + $this->assertSame( $expected, array_key_first( $arr ) ); } /** diff --git a/tests/phpunit/tests/compat/arrayKeyLast.php b/tests/phpunit/tests/compat/arrayKeyLast.php index 77510c8320..819e850f13 100644 --- a/tests/phpunit/tests/compat/arrayKeyLast.php +++ b/tests/phpunit/tests/compat/arrayKeyLast.php @@ -25,11 +25,7 @@ class Tests_Compat_ArrayKeyLast extends WP_UnitTestCase { * @param array $arr The array to get last key from. */ public function test_array_key_last( $expected, $arr ) { - if ( ! function_exists( 'array_key_last' ) ) { - $this->markTestSkipped( 'array_key_last() is not available.' ); - } else { - $this->assertSame( $expected, array_key_last( $arr ) ); - } + $this->assertSame( $expected, array_key_last( $arr ) ); } /** diff --git a/tests/phpunit/tests/compat/strContains.php b/tests/phpunit/tests/compat/strContains.php index ee5bb6e1d3..381365b408 100644 --- a/tests/phpunit/tests/compat/strContains.php +++ b/tests/phpunit/tests/compat/strContains.php @@ -26,14 +26,7 @@ class Tests_Compat_strContains extends WP_UnitTestCase { * @param string $needle The substring to search for in `$haystack`. */ public function test_str_contains( $expected, $haystack, $needle ) { - if ( ! function_exists( 'str_contains' ) ) { - $this->markTestSkipped( 'str_contains() is not available.' ); - } else { - $this->assertSame( - $expected, - str_contains( $haystack, $needle ) - ); - } + $this->assertSame( $expected, str_contains( $haystack, $needle ) ); } /** diff --git a/tests/phpunit/tests/compat/strEndsWith.php b/tests/phpunit/tests/compat/strEndsWith.php index 7cf1e2b15d..8467675613 100644 --- a/tests/phpunit/tests/compat/strEndsWith.php +++ b/tests/phpunit/tests/compat/strEndsWith.php @@ -26,14 +26,7 @@ class Tests_Compat_StrEndsWith extends WP_UnitTestCase { * @param string $needle The substring to search for at the end of `$haystack`. */ public function test_str_ends_with( $expected, $haystack, $needle ) { - if ( ! function_exists( 'str_ends_with' ) ) { - $this->markTestSkipped( 'str_ends_with() is not available.' ); - } else { - $this->assertSame( - $expected, - str_ends_with( $haystack, $needle ) - ); - } + $this->assertSame( $expected, str_ends_with( $haystack, $needle ) ); } /** diff --git a/tests/phpunit/tests/compat/strStartsWith.php b/tests/phpunit/tests/compat/strStartsWith.php index 6bf72cd621..a7ea8ff3d9 100644 --- a/tests/phpunit/tests/compat/strStartsWith.php +++ b/tests/phpunit/tests/compat/strStartsWith.php @@ -26,14 +26,7 @@ class Tests_Compat_StrStartsWith extends WP_UnitTestCase { * @param string $needle The substring to search for at the start of `$haystack`. */ public function test_str_starts_with( $expected, $haystack, $needle ) { - if ( ! function_exists( 'str_starts_with' ) ) { - $this->markTestSkipped( 'str_starts_with() is not available.' ); - } else { - $this->assertSame( - $expected, - str_starts_with( $haystack, $needle ) - ); - } + $this->assertSame( $expected, str_starts_with( $haystack, $needle ) ); } /**