Make WordPress Core


Ignore:
Timestamp:
07/12/2021 10:35:44 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use more appropriate assertions in various tests.

This replaces instances of assertTrue( in_array( ... ) ) with assertContains() to use native PHPUnit functionality.

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

Props hellofromTonya, jrf, SergeyBiryukov.
Fixes #53123. See #53363.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r51397 r51404  
    303303        $this->assertCount( 2, $data );
    304304        $ids = wp_list_pluck( $data, 'id' );
    305         $this->assertTrue( in_array( $id1, $ids, true ) );
    306         $this->assertFalse( in_array( $id2, $ids, true ) );
    307         $this->assertTrue( in_array( $id3, $ids, true ) );
     305        $this->assertContains( $id1, $ids );
     306        $this->assertNotContains( $id2, $ids );
     307        $this->assertContains( $id3, $ids );
    308308
    309309        $this->check_get_posts_response( $response );
     
    344344        $this->assertCount( 3, $data );
    345345        $ids = wp_list_pluck( $data, 'id' );
    346         $this->assertTrue( in_array( $id1, $ids, true ) );
    347         $this->assertTrue( in_array( $id2, $ids, true ) );
    348         $this->assertTrue( in_array( $id3, $ids, true ) );
     346        $this->assertContains( $id1, $ids );
     347        $this->assertContains( $id2, $ids );
     348        $this->assertContains( $id3, $ids );
    349349    }
    350350
Note: See TracChangeset for help on using the changeset viewer.