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
This commit is contained in:
Sergey Biryukov
2023-10-18 10:39:19 +00:00
parent 428c624e15
commit c9ff475e1f
5 changed files with 5 additions and 37 deletions

View File

@@ -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 ) );
}
/**

View File

@@ -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 ) );
}
/**

View File

@@ -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 ) );
}
/**

View File

@@ -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 ) );
}
/**

View File

@@ -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 ) );
}
/**