Make WordPress Core

Changeset 56969


Ignore:
Timestamp:
10/18/2023 10:39:19 AM (18 months ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/tests/phpunit/tests/compat
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/compat/arrayKeyFirst.php

    r56548 r56969  
    2525     */
    2626    public function test_array_key_first( $expected, $arr ) {
    27         if ( ! function_exists( 'array_key_first' ) ) {
    28             $this->markTestSkipped( 'array_key_first() is not available.' );
    29         } else {
    30             $this->assertSame(
    31                 $expected,
    32                 array_key_first( $arr )
    33             );
    34         }
     27        $this->assertSame( $expected, array_key_first( $arr ) );
    3528    }
    3629
  • trunk/tests/phpunit/tests/compat/arrayKeyLast.php

    r54064 r56969  
    2626     */
    2727    public function test_array_key_last( $expected, $arr ) {
    28         if ( ! function_exists( 'array_key_last' ) ) {
    29             $this->markTestSkipped( 'array_key_last() is not available.' );
    30         } else {
    31             $this->assertSame( $expected, array_key_last( $arr ) );
    32         }
     28        $this->assertSame( $expected, array_key_last( $arr ) );
    3329    }
    3430
  • trunk/tests/phpunit/tests/compat/strContains.php

    r56548 r56969  
    2727     */
    2828    public function test_str_contains( $expected, $haystack, $needle ) {
    29         if ( ! function_exists( 'str_contains' ) ) {
    30             $this->markTestSkipped( 'str_contains() is not available.' );
    31         } else {
    32             $this->assertSame(
    33                 $expected,
    34                 str_contains( $haystack, $needle )
    35             );
    36         }
     29        $this->assertSame( $expected, str_contains( $haystack, $needle ) );
    3730    }
    3831
  • trunk/tests/phpunit/tests/compat/strEndsWith.php

    r56548 r56969  
    2727     */
    2828    public function test_str_ends_with( $expected, $haystack, $needle ) {
    29         if ( ! function_exists( 'str_ends_with' ) ) {
    30             $this->markTestSkipped( 'str_ends_with() is not available.' );
    31         } else {
    32             $this->assertSame(
    33                 $expected,
    34                 str_ends_with( $haystack, $needle )
    35             );
    36         }
     29        $this->assertSame( $expected, str_ends_with( $haystack, $needle ) );
    3730    }
    3831
  • trunk/tests/phpunit/tests/compat/strStartsWith.php

    r56548 r56969  
    2727     */
    2828    public function test_str_starts_with( $expected, $haystack, $needle ) {
    29         if ( ! function_exists( 'str_starts_with' ) ) {
    30             $this->markTestSkipped( 'str_starts_with() is not available.' );
    31         } else {
    32             $this->assertSame(
    33                 $expected,
    34                 str_starts_with( $haystack, $needle )
    35             );
    36         }
     29        $this->assertSame( $expected, str_starts_with( $haystack, $needle ) );
    3730    }
    3831
Note: See TracChangeset for help on using the changeset viewer.