Make WordPress Core

Changeset 58108


Ignore:
Timestamp:
05/06/2024 06:39:15 PM (7 months ago)
Author:
johnbillion
Message:

Build/Test Tools: Standardise the assertions for remote HTTP request tests.

This ensures that as much information as possible is shown when an HTTP request fails during an external HTTP test.

Fixes #61148

Location:
trunk/tests/phpunit/tests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/http/base.php

    r56548 r58108  
    220220
    221221        $this->skipTestOnTimeout( $res );
     222        $this->assertNotWPError( $res );
    222223        $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) );
    223224        $this->assertNotEmpty( $res['headers']['location'] );
     
    357358
    358359        $this->skipTestOnTimeout( $res );
     360        $this->assertNotWPError( $res );
    359361        $this->assertSame( $method, wp_remote_retrieve_body( $res ) );
    360362    }
     
    407409
    408410        $this->skipTestOnTimeout( $res );
     411        $this->assertNotWPError( $res );
    409412        $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) );
    410413    }
     
    448451
    449452        $this->skipTestOnTimeout( $res );
     453        $this->assertNotWPError( $res );
    450454        $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) );
    451455    }
  • trunk/tests/phpunit/tests/http/functions.php

    r57931 r58108  
    1616
    1717        $this->skipTestOnTimeout( $response );
     18        $this->assertNotWPError( $response );
    1819
    1920        $headers = wp_remote_retrieve_headers( $response );
    2021
    2122        $this->assertIsArray( $response );
    22 
     23        $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    2324        $this->assertSame( 'image/png', $headers['Content-Type'] );
    2425        $this->assertSame( '153204', $headers['Content-Length'] );
    25         $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    2626    }
    2727
     
    3535
    3636        $this->skipTestOnTimeout( $response );
     37        $this->assertNotWPError( $response );
    3738        $this->assertSame( 301, wp_remote_retrieve_response_code( $response ) );
    3839    }
     
    4647
    4748        $this->skipTestOnTimeout( $response );
     49        $this->assertNotWPError( $response );
    4850        $this->assertSame( 404, wp_remote_retrieve_response_code( $response ) );
    4951    }
     
    6062
    6163        $this->skipTestOnTimeout( $response );
     64        $this->assertNotWPError( $response );
    6265
    6366        $headers = wp_remote_retrieve_headers( $response );
    6467
    65         $this->assertIsArray( $response );
    66 
    6768        // Should return the same headers as a HEAD request.
     69        $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    6870        $this->assertSame( 'image/png', $headers['Content-Type'] );
    6971        $this->assertSame( '153204', $headers['Content-Length'] );
    70         $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    7172    }
    7273
     
    8384
    8485        $this->skipTestOnTimeout( $response );
     86        $this->assertNotWPError( $response );
    8587
    8688        $headers = wp_remote_retrieve_headers( $response );
    8789
    8890        // Should return the same headers as a HEAD request.
     91        $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    8992        $this->assertSame( 'image/png', $headers['Content-Type'] );
    9093        $this->assertSame( '153204', $headers['Content-Length'] );
    91         $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) );
    9294    }
    9395
     
    120122
    121123        $this->skipTestOnTimeout( $response );
     124        $this->assertNotWPError( $response );
    122125
    123126        $cookies = wp_remote_retrieve_cookies( $response );
     
    165168
    166169        $this->skipTestOnTimeout( $response );
     170        $this->assertNotWPError( $response );
    167171
    168172        $cookies = wp_remote_retrieve_cookies( $response );
     
    196200
    197201        $this->skipTestOnTimeout( $response );
     202        $this->assertNotWPError( $response );
    198203
    199204        $cookies = wp_remote_retrieve_cookies( $response );
  • trunk/tests/phpunit/tests/readme.php

    r57689 r58108  
    9595
    9696        $this->skipTestOnTimeout( $response );
     97        $this->assertNotWPError( $response );
    9798
    9899        $response_code = wp_remote_retrieve_response_code( $response );
Note: See TracChangeset for help on using the changeset viewer.