Make WordPress Core


Ignore:
Timestamp:
07/10/2021 11:15:44 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use more appropriate assertions in various tests.

This replaces instances of assertTrue( isset( ... ) ) with assertArrayHasKey() to use native PHPUnit functionality.

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

See #53363.

File:
1 edited

Legend:

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

    r51368 r51397  
    17781778        $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );
    17791779        $this->assertSame( 0, $links['version-history'][0]['attributes']['count'] );
    1780         $this->assertFalse( isset( $links['predecessor-version'] ) );
     1780        $this->assertArrayNotHasKey( 'predecessor-version', $links );
    17811781
    17821782        $attachments_url = rest_url( '/wp/v2/media' );
     
    18341834        $response = rest_get_server()->dispatch( $request );
    18351835        $links    = $response->get_links();
    1836         $this->assertFalse( isset( $links['author'] ) );
     1836        $this->assertArrayNotHasKey( 'author', $links );
    18371837        wp_update_post(
    18381838            array(
     
    20312031        $response = rest_get_server()->dispatch( $request );
    20322032        $data     = $response->get_data();
    2033         $this->assertFalse( isset( $data['content']['block_version'] ) );
     2033        $this->assertArrayNotHasKey( 'block_version', $data['content'] );
    20342034    }
    20352035
     
    41584158        create_initial_rest_routes();
    41594159        $routes = rest_get_server()->get_routes();
    4160         $this->assertFalse( isset( $routes['/wp/v2/invalid-controller'] ) );
     4160        $this->assertArrayNotHasKey( '/wp/v2/invalid-controller', $routes );
    41614161        _unregister_post_type( 'invalid-controller' );
    41624162
Note: See TracChangeset for help on using the changeset viewer.