Make WordPress Core


Ignore:
Timestamp:
12/19/2021 01:42:37 PM (3 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Reduce the use of unnecessary randomness in tests.

This increases the overall reliability of the tests.

Props johnillo

Fixes #37371

File:
1 edited

Legend:

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

    r52310 r52389  
    16951695    public function test_get_items_invalid_date() {
    16961696        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
    1697         $request->set_param( 'after', rand_str() );
    1698         $request->set_param( 'before', rand_str() );
     1697        $request->set_param( 'after', 'foo' );
     1698        $request->set_param( 'before', 'bar' );
    16991699        $response = rest_get_server()->dispatch( $request );
    17001700        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     
    17201720    public function test_get_items_invalid_modified_date() {
    17211721        $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
    1722         $request->set_param( 'modified_after', rand_str() );
    1723         $request->set_param( 'modified_before', rand_str() );
     1722        $request->set_param( 'modified_after', 'foo' );
     1723        $request->set_param( 'modified_before', 'bar' );
    17241724        $response = rest_get_server()->dispatch( $request );
    17251725        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
     
    26982698            array(
    26992699                'post_mime_type' => 'image/jpeg',
    2700                 'menu_order'     => rand( 1, 100 ),
     2700                'menu_order'     => 1,
    27012701            )
    27022702        );
     
    33113311        wp_set_current_user( self::$editor_id );
    33123312
    3313         $new_content       = rand_str();
     3313        $new_content       = 'foo bar baz';
    33143314        $expected_modified = current_time( 'mysql' );
    33153315
     
    33763376        $params  = $this->set_post_data(
    33773377            array(
    3378                 'date' => rand_str(),
     3378                'date' => 'foo',
    33793379            )
    33803380        );
     
    33913391        $params  = $this->set_post_data(
    33923392            array(
    3393                 'date_gmt' => rand_str(),
     3393                'date_gmt' => 'foo',
    33943394            )
    33953395        );
Note: See TracChangeset for help on using the changeset viewer.