WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/10/2021 11:15:44 AM (3 months 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.php

    r50156 r51397  
    238238        );
    239239        $endpoints = $GLOBALS['wp_rest_server']->get_routes();
    240         $this->assertFalse( isset( $endpoints['/test-empty-namespace'] ) );
     240        $this->assertArrayNotHasKey( '/test-empty-namespace', $endpoints );
    241241    }
    242242
     
    258258        );
    259259        $endpoints = $GLOBALS['wp_rest_server']->get_routes();
    260         $this->assertFalse( isset( $endpoints['/test-empty-route'] ) );
     260        $this->assertArrayNotHasKey( '/test-empty-route', $endpoints );
    261261    }
    262262
     
    952952
    953953        $this->assertSame( array_keys( $preload_data ), array( '/wp/v2/types', 'OPTIONS' ) );
    954         $this->assertTrue( isset( $preload_data['OPTIONS']['/wp/v2/media'] ) );
     954        $this->assertArrayHasKey( '/wp/v2/media', $preload_data['OPTIONS'] );
    955955
    956956        $GLOBALS['wp_rest_server'] = $rest_server;
Note: See TracChangeset for help on using the changeset viewer.