myparcelcom/guzzle-mock

Test utilities for working with guzzle mock handler in tests

v1.0.0 2025-04-16 15:10 UTC

This package is auto-updated.

Last update: 2025-04-16 15:16:03 UTC


README

Test utilities for working with guzzle mock handler in tests

Installation

composer require --dev myparcelcom/guzzle-mock

Usage

use MyParcelCom\GuzzleMock\GuzzleMock;
use PHPUnit\Framework\TestCase;

class MyTest extends TestCase
{
    use GuzzleMock;
    
    public function testSomething()
    {
        $response1 = new Response();
        $response2 = new Response();
        
        $requests = [];
        $client = $this->mockGuzzle($requests, $response1, $response2);
        
        // Make requests using the $client
        
        $request1 = $requests[0]['request']; // instanceof GuzzleHttp\Psr7\Request
    }
}