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-categories-controller.php

    r51397 r51404  
    312312        $data     = $response->get_data();
    313313        $ids      = wp_list_pluck( $data, 'id' );
    314         $this->assertTrue( in_array( $id1, $ids, true ) );
    315         $this->assertTrue( in_array( $id2, $ids, true ) );
     314        $this->assertContains( $id1, $ids );
     315        $this->assertContains( $id2, $ids );
    316316
    317317        $request->set_param( 'exclude', array( $id2 ) );
     
    319319        $data     = $response->get_data();
    320320        $ids      = wp_list_pluck( $data, 'id' );
    321         $this->assertTrue( in_array( $id1, $ids, true ) );
    322         $this->assertFalse( in_array( $id2, $ids, true ) );
     321        $this->assertContains( $id1, $ids );
     322        $this->assertNotContains( $id2, $ids );
    323323    }
    324324
Note: See TracChangeset for help on using the changeset viewer.