verdet/guzzle-mock 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

verdet/guzzle-mock

最新稳定版本:1.0.0

Composer 安装命令:

composer require verdet/guzzle-mock

包简介

Guzzle Mock Handler

README 文档

README

Packagist Version CI Coverage Status PHPStan Coding Style License Packagist PHP Version Support

Description

Inspired by guzzle/guzzle MockHandler and alekseytupichenkov/GuzzleStub library.

Mock Handler functional same as default GuzzleHttp\Handler\MockHandler except filling queue. Argument $queue expected to be array of Request and Response objects. When you pass Request to MockHanlder it will try to find suitable Request in queue and return paired Response.

Prerequisite

php >= 8.0
guzzlehttp/guzzle >= 7.0

Installation

Use the package manager composer to install.

composer require --dev verdet/guzzle-mock

Basic usage

// Create a mock and queue three pairs of request and responses.
$mock = new MockHandler([
            [
                new Request('GET', 'https://example.com'),
                new Response(200, ['X-Foo' => 'Bar'], 'Hello, World')
            ],
            [
                new Request('GET', 'https://example.com/latest'),
                new Response(202, ['Content-Length' => '0'])],
            [
                new Request('POST', 'https://example.com/foo'),
                new RequestException('Error Communicating with Server', new Request('POST', 'https://example.com/foo'))
            ]
        ]);

Rest of usage same as https://docs.guzzlephp.org/en/stable/testing.html

统计信息

  • 总下载量: 62
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-05