Make WordPress Core


Ignore:
Timestamp:
07/12/2021 10:35:44 AM (3 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-tags-controller.php

    r51397 r51404  
    246246        $data     = $response->get_data();
    247247        $ids      = wp_list_pluck( $data, 'id' );
    248         $this->assertTrue( in_array( $id1, $ids, true ) );
    249         $this->assertTrue( in_array( $id2, $ids, true ) );
     248        $this->assertContains( $id1, $ids );
     249        $this->assertContains( $id2, $ids );
    250250
    251251        $request->set_param( 'exclude', array( $id2 ) );
     
    253253        $data     = $response->get_data();
    254254        $ids      = wp_list_pluck( $data, 'id' );
    255         $this->assertTrue( in_array( $id1, $ids, true ) );
    256         $this->assertFalse( in_array( $id2, $ids, true ) );
     255        $this->assertContains( $id1, $ids );
     256        $this->assertNotContains( $id2, $ids );
    257257
    258258        // Invalid 'exclude' should error.
Note: See TracChangeset for help on using the changeset viewer.