Skip to content

Instantly share code, notes, and snippets.

@eduPHP
Created February 24, 2022 19:47
Show Gist options
  • Select an option

  • Save eduPHP/089ad67aa5980722c6cddd6353d0cf43 to your computer and use it in GitHub Desktop.

Select an option

Save eduPHP/089ad67aa5980722c6cddd6353d0cf43 to your computer and use it in GitHub Desktop.
Guzzle Stub for testing
<?php
namespace Tests\stubs;
use GuzzleHttp\Client;
class HttpClientStub extends Client
{
static $options = [];
static $uri = [];
static $method = [];
public function __construct(array $config = [])
{
self::$options = collect();
self::$uri = collect();
self::$method = collect();
parent::__construct($config);
}
public function request($method, $uri = '', array $options = [])
{
self::$method->push($method);
self::$uri->push($uri);
self::$options->push($options);
return parent::request($method, $uri, $options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment