PHP code example of airtimerewards / guzzle-test-helper

1. Go to this page and download the library: Download airtimerewards/guzzle-test-helper 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/ */

    

airtimerewards / guzzle-test-helper example snippets




use AirtimeRewards\GuzzleTestHelper\MockGuzzleClient;

$client = new MockGuzzleClient();

$client->append(200, ['Content-Type' => 'text/plain'], 'Hello World!');
$client->append(204);

$response = $client->get('/foo');
echo $response->getBody(); // "Hello World!"
echo $response->getStatusCode(); // 200

$response2 = $client->post('/bar');
echo $response2->getStatusCode(); // 204

$request1 = $client->getRequest(0);
echo $request1->getUri(); // "/foo"
echo $request1->getMethod(); // "GET"

$request2 = $client->getLastRequest();
echo $request2->getUri(); // "/bar"
echo $request2->getMethod(); // "POST"