Make WordPress Core

Changeset 51335


Ignore:
Timestamp:
07/06/2021 12:25:53 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use more appropriate assertions in various tests.

This replaces instances of assertTrue( is_array( ... ) ) with assertIsArray() to use native PHPUnit functionality.

Follow-up to [51331].

See #53363.

Location:
trunk/tests/phpunit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r51135 r51335  
    761761     */
    762762    public function assertNonEmptyMultidimensionalArray( $array ) {
    763         $this->assertTrue( is_array( $array ) );
     763        $this->assertIsArray( $array );
    764764        $this->assertNotEmpty( $array );
    765765
    766766        foreach ( $array as $sub_array ) {
    767             $this->assertTrue( is_array( $sub_array ) );
     767            $this->assertIsArray( $sub_array );
    768768            $this->assertNotEmpty( $sub_array );
    769769        }
  • trunk/tests/phpunit/tests/admin/includesPlugin.php

    r50443 r51335  
    2828        );
    2929
    30         $this->assertTrue( is_array( $data ) );
     30        $this->assertIsArray( $data );
    3131
    3232        foreach ( $default_headers as $name => $value ) {
  • trunk/tests/phpunit/tests/import/parser.php

    r49033 r51335  
    5959            $result  = $parser->parse( $file );
    6060
    61             $this->assertTrue( is_array( $result ), $message );
     61            $this->assertIsArray( $result, $message );
    6262            $this->assertSame( 'http://localhost/', $result['base_url'], $message );
    6363            $this->assertEquals(
     
    152152            $result  = $parser->parse( $file );
    153153
    154             $this->assertTrue( is_array( $result ), $message );
     154            $this->assertIsArray( $result, $message );
    155155            $this->assertSame( 'http://localhost/', $result['base_url'], $message );
    156156            $this->assertSame( $result['categories'][0]['category_nicename'], 'alpha', $message );
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r51021 r51335  
    7373        $routes = rest_get_server()->get_routes();
    7474
    75         $this->assertTrue( is_array( $routes ), '`get_routes` should return an array.' );
     75        $this->assertIsArray( $routes, '`get_routes` should return an array.' );
    7676        $this->assertTrue( ! empty( $routes ), 'Routes should not be empty.' );
    7777
  • trunk/tests/phpunit/tests/taxonomy.php

    r51331 r51335  
    2929            // Should return an object with the correct taxonomy object type.
    3030            $this->assertTrue( is_object( $tax ) );
    31             $this->assertTrue( is_array( $tax->object_type ) );
     31            $this->assertIsArray( $tax->object_type );
    3232            $this->assertSame( array( 'post' ), $tax->object_type );
    3333        }
     
    111111            // Should return an object with the correct taxonomy object type.
    112112            $this->assertTrue( is_object( $tax ) );
    113             $this->assertTrue( is_array( $tax->object_type ) );
     113            $this->assertIsArray( $tax->object_type );
    114114            $this->assertSame( array( 'link' ), $tax->object_type );
    115115        }
  • trunk/tests/phpunit/tests/term/getTheTerms.php

    r51331 r51335  
    249249        wp_defer_term_counting( false );
    250250
    251         $this->assertTrue( is_array( $terms ) );
     251        $this->assertIsArray( $terms );
    252252        $this->assertSame( array( $term_id ), wp_list_pluck( $terms, 'term_id' ) );
    253253    }
     
    284284        wp_defer_term_counting( false );
    285285
    286         $this->assertTrue( is_array( $terms ) );
     286        $this->assertIsArray( $terms );
    287287        $this->assertSame( array( $term_ids[1] ), wp_list_pluck( $terms, 'term_id' ) );
    288288    }
  • trunk/tests/phpunit/tests/theme.php

    r49220 r51335  
    146146
    147147            // Template files should all exist.
    148             $this->assertTrue( is_array( $theme['Template Files'] ) );
    149             $this->assertTrue( count( $theme['Template Files'] ) > 0 );
     148            $this->assertIsArray( $theme['Template Files'] );
     149            $this->assertNotEmpty( $theme['Template Files'] );
    150150            foreach ( $theme['Template Files'] as $file ) {
    151151                $this->assertTrue( is_file( $dir . $file ) );
     
    154154
    155155            // CSS files should all exist.
    156             $this->assertTrue( is_array( $theme['Stylesheet Files'] ) );
    157             $this->assertTrue( count( $theme['Stylesheet Files'] ) > 0 );
     156            $this->assertIsArray( $theme['Stylesheet Files'] );
     157            $this->assertNotEmpty( $theme['Stylesheet Files'] );
    158158            foreach ( $theme['Stylesheet Files'] as $file ) {
    159159                $this->assertTrue( is_file( $dir . $file ) );
  • trunk/tests/phpunit/tests/user.php

    r51331 r51335  
    156156
    157157        // There is already some stuff in the array.
    158         $this->assertTrue( is_array( get_user_meta( self::$author_id ) ) );
     158        $this->assertIsArray( get_user_meta( self::$author_id ) );
    159159
    160160        foreach ( $vals as $k => $v ) {
Note: See TracChangeset for help on using the changeset viewer.