All Projects → blastcloud → Guzzler

blastcloud / Guzzler

Licence: mit
Supercharge your app or SDK with a testing library specifically for Guzzle

Projects that are alternatives of or similar to Guzzler

Mockery
Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL).
Stars: ✭ 10,048 (+3594.12%)
Mutual labels:  mock, phpunit
Mock Webserver
Simple mock web server in PHP for unit testing.
Stars: ✭ 82 (-69.85%)
Mutual labels:  mock, phpunit
phake
PHP Mocking Framework
Stars: ✭ 464 (+70.59%)
Mutual labels:  mock, phpunit
Php Mock Phpunit
Mock built-in PHP functions (e.g. time() or rand()) in PHPUnit.
Stars: ✭ 121 (-55.51%)
Mutual labels:  mock, phpunit
php-mock-prophecy
Mock built-in PHP functions (e.g. time()) with Prophecy (phpspec).
Stars: ✭ 16 (-94.12%)
Mutual labels:  mock
smart-cloud
基于springboot && springcloud的脚手架,支持服务合并部署与拆分部署、接口加解密签名、日志数据 脱敏、接口数据mock、接口文档自动生成、请求幂等校验、接口日志&&sql日志切面打印、分表分库分布式事务、国际化语言等
Stars: ✭ 167 (-38.6%)
Mutual labels:  mock
elasticmock
Python Elasticsearch Mock for test purposes
Stars: ✭ 98 (-63.97%)
Mutual labels:  mock
httpmock
Lightweight HTTP mocking in Go (aka golang)
Stars: ✭ 75 (-72.43%)
Mutual labels:  mock
Pook
HTTP traffic mocking and testing made simple in Python
Stars: ✭ 257 (-5.51%)
Mutual labels:  mock
zmock
zmock--http接口的mock平台
Stars: ✭ 98 (-63.97%)
Mutual labels:  mock
automock
A library for testing classes with auto mocking capabilities using jest-mock-extended
Stars: ✭ 26 (-90.44%)
Mutual labels:  mock
DeepfakeHTTP
DeepfakeHTTP is a web server that uses HTTP dumps as a source for responses.
Stars: ✭ 373 (+37.13%)
Mutual labels:  mock
egg-datahub
Macaca DataHub plugin for Egg.js
Stars: ✭ 19 (-93.01%)
Mutual labels:  mock
mongo mock go example
How to mock MongoDB in Golang
Stars: ✭ 30 (-88.97%)
Mutual labels:  mock
falso
All the Fake Data for All Your Real Needs 🙂
Stars: ✭ 877 (+222.43%)
Mutual labels:  mock
Raccoon
Raccoon is a lightweight response mocking framework that can be easily integrated into the Android UI tests.
Stars: ✭ 47 (-82.72%)
Mutual labels:  mock
mokker
The mock does not mock you. The video: https://www.youtube.com/watch?v=gGLNJpC-Ov0
Stars: ✭ 13 (-95.22%)
Mutual labels:  mock
php-skeleton
A skeleton to start new high-quality PHP projects without worrying about bootstrapping everything from scratch.
Stars: ✭ 23 (-91.54%)
Mutual labels:  phpunit
mock-req-res
Extensible mock req / res objects for use in unit tests of Express controller and middleware functions.
Stars: ✭ 39 (-85.66%)
Mutual labels:  mock
amoss
Amoss - Apex Mock Objects, Spies and Stubs - A Simple Mocking framework for Apex (Salesforce)
Stars: ✭ 55 (-79.78%)
Mutual labels:  mock


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

Full Documentation

License

Guzzler is open-source software licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].