Description
Supercharge your app or SDK with a testing library specifically for Guzzle. Guzzler covers the process of setting up a mock handler, recording history of requests, and provides several convenience methods for creating expectations and assertions on that history.
guzzler alternatives and similar libraries
Based on the "HTTP" category.
Alternatively, view guzzler alternatives based on common mentions on social networks and blogs.
-
Requests
Requests for PHP is a humble HTTP request library. It simplifies how you interact with other sites and takes away all your worries. -
PHP VCR
Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
InfluxDB - Purpose built for real-time analytics at any scale.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of guzzler or a related project?
Popular Comparisons
README
Full Documentation at guzzler.dev
Supercharge your app or SDK with a testing library specifically for Guzzle. Guzzler covers the process of setting up a mock handler, recording history of requests, and provides several convenience methods for creating expectations and assertions on that history.
Installation
composer require --dev --prefer-dist blastcloud/guzzler
Example Usage
<?php
use BlastCloud\Guzzler\UsesGuzzler;
use GuzzleHttp\Client;
class SomeTest extends TestCase
{
use UsesGuzzler;
public $classToTest;
public function setUp(): void
{
parent::setUp();
$client = $this->guzzler->getClient([
/* Any configs for a client */
"base_uri" => "https://example.com/api"
]);
// You can then inject this client object into your code or IOC container.
$this->classToTest = new ClassToTest($client);
}
public function testSomethingWithExpectations()
{
$this->guzzler->expects($this->once())
->post("/some-url")
->withHeader("X-Authorization", "some-key")
->willRespond(new Response(201));
$this->classToTest->someMethod();
}
public function testSomethingWithAssertions()
{
$this->guzzler->queueResponse(
new Response(204),
new \Exception("Some message"),
// any needed responses to return from the client.
);
$this->classToTest->someMethod();
// ... Some other number of calls
$this->guzzler->assertAll(function ($expect) {
return $expect->withHeader("Authorization", "some-key");
});
}
}
Documentation
License
Guzzler is open-source software licensed under the MIT License.
*Note that all licence references and agreements mentioned in the guzzler README section above
are relevant to that project's source code only.