PHP code example of jdgrimes / wp-http-testcase

1. Go to this page and download the library: Download jdgrimes/wp-http-testcase library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jdgrimes / wp-http-testcase example snippets


define( 'WP_HTTP_TC_USE_CACHING', true );

$this->http_responder = array( $this, 'mock_server_response' );

protected function mock_server_response( $request, $url ) {

	return array( 'body' => 'Test response.' );
}

$this->assertCount( 1, $this->http_requests );
$this->assertEquals( 'http://example.com/', $this->http_requests[0]['url'] );

$this->http_responder = '__return_true';

my_prefix_make_request();

$this->assertCount( 1, $this->http_requests );