Make WordPress Core

Changeset 51438


Ignore:
Timestamp:
07/15/2021 02:44:22 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use more appropriate assertions in various tests.

This replaces instances of assertTrue( is_numeric( ... ) ) with assertIsNumeric() to use native PHPUnit functionality.

Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436].

See #53363.

Location:
trunk/tests/phpunit/tests
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/DeleteComment.php

    r51404 r51438  
    206206                } catch ( WPAjaxDieStopException $e ) {
    207207                        $this->assertSame( 10, strlen( $e->getMessage() ) );
    208                         $this->assertTrue( is_numeric( $e->getMessage() ) );
     208                        $this->assertIsNumeric( $e->getMessage() );
    209209                } catch ( Exception $e ) {
    210210                        $this->fail( 'Unexpected exception type: ' . get_class( $e ) );
     
    256256                } catch ( WPAjaxDieStopException $e ) {
    257257                        $this->assertSame( 10, strlen( $e->getMessage() ) );
    258                         $this->assertTrue( is_numeric( $e->getMessage() ) );
     258                        $this->assertIsNumeric( $e->getMessage() );
    259259                } catch ( Exception $e ) {
    260260                        $this->fail( 'Unexpected exception type: ' . get_class( $e ) );
  • trunk/tests/phpunit/tests/customize/manager.php

    r51415 r51438  
    12151215                wp_set_current_user( self::$admin_user_id );
    12161216                $this->assertSame( 'publish', get_post_meta( $post_id, '_wp_trash_meta_status', true ) );
    1217                 $this->assertTrue( is_numeric( get_post_meta( $post_id, '_wp_trash_meta_time', true ) ) );
     1217                $this->assertIsNumeric( get_post_meta( $post_id, '_wp_trash_meta_time', true ) );
    12181218
    12191219                foreach ( array_keys( $expected_actions ) as $action_name ) {
  • trunk/tests/phpunit/tests/functions.php

    r51331 r51438  
    11991199                        $id = wp_unique_id();
    12001200                        $this->assertIsString( $id );
    1201                         $this->assertTrue( is_numeric( $id ) );
     1201                        $this->assertIsNumeric( $id );
    12021202                        $ids[] = $id;
    12031203                }
  • trunk/tests/phpunit/tests/post.php

    r51397 r51438  
    8080                        // Insert a post and make sure the ID is OK.
    8181                        $id = wp_insert_post( $post );
    82                         $this->assertTrue( is_numeric( $id ) );
     82                        $this->assertIsNumeric( $id );
    8383                        $this->assertTrue( $id > 0 );
    8484
     
    136136                $this->post_ids[] = $id;
    137137                // dmp( _get_cron_array() );
    138                 $this->assertTrue( is_numeric( $id ) );
     138                $this->assertIsNumeric( $id );
    139139                $this->assertTrue( $id > 0 );
    140140
     
    259259                $this->post_ids[] = $id;
    260260                // dmp( _get_cron_array() );
    261                 $this->assertTrue( is_numeric( $id ) );
     261                $this->assertIsNumeric( $id );
    262262                $this->assertTrue( $id > 0 );
    263263
     
    380380                $this->post_ids[] = $id;
    381381                // dmp( _get_cron_array() );
    382                 $this->assertTrue( is_numeric( $id ) );
     382                $this->assertIsNumeric( $id );
    383383                $this->assertTrue( $id > 0 );
    384384
  • trunk/tests/phpunit/tests/taxonomy.php

    r51436 r51438  
    421421                        'cat_name' => 'test1',
    422422                );
    423                 $this->assertTrue( is_numeric( wp_insert_category( $cat, true ) ) );
     423                $this->assertIsNumeric( wp_insert_category( $cat, true ) );
    424424        }
    425425
  • trunk/tests/phpunit/tests/term.php

    r51367 r51438  
    154154
    155155                $t = wp_insert_category( array( 'cat_name' => $term ) );
    156                 $this->assertTrue( is_numeric( $t ) );
     156                $this->assertIsNumeric( $t );
    157157                $this->assertNotWPError( $t );
    158158                $this->assertTrue( $t > 0 );
  • trunk/tests/phpunit/tests/theme/getThemeStarterContent.php

    r51331 r51438  
    160160                foreach ( $hydrated_starter_content['posts'] as $key => $post ) {
    161161                        $this->assertIsString( $key );
    162                         $this->assertFalse( is_numeric( $key ) );
     162                        $this->assertIsNotNumeric( $key );
    163163                        $this->assertIsArray( $post );
    164164                        $this->assertArrayHasKey( 'post_type', $post );
  • trunk/tests/phpunit/tests/user.php

    r51404 r51438  
    483483                // Insert a post and make sure the ID is OK.
    484484                $post_id = wp_insert_post( $post );
    485                 $this->assertTrue( is_numeric( $post_id ) );
     485                $this->assertIsNumeric( $post_id );
    486486
    487487                setup_postdata( get_post( $post_id ) );
  • trunk/tests/phpunit/tests/user/wpDeleteUser.php

    r48937 r51438  
    6868                // Insert a post and make sure the ID is OK.
    6969                $post_id = wp_insert_post( $post );
    70                 $this->assertTrue( is_numeric( $post_id ) );
     70                $this->assertIsNumeric( $post_id );
    7171                $this->assertTrue( $post_id > 0 );
    7272
     
    8484                // Insert a post and make sure the ID is OK.
    8585                $nav_id = wp_insert_post( $post );
    86                 $this->assertTrue( is_numeric( $nav_id ) );
     86                $this->assertIsNumeric( $nav_id );
    8787                $this->assertTrue( $nav_id > 0 );
    8888
Note: See TracChangeset for help on using the changeset viewer.