e-moe/guzzle-regexp-mock-plugin
最新稳定版本:v1.0.0
Composer 安装命令:
composer require e-moe/guzzle-regexp-mock-plugin
包简介
Mock plugin for Guzzle3 with regexp match urls
README 文档
README
The mock plugin is useful for testing Guzzle clients. The mock plugin allows you to queue an array of responses that will satisfy requests sent from a client by consuming the request queue in FIFO order. Each request may have optional regexp url match pattern.
Based on standard mock plugin - http://guzzle3.readthedocs.org/plugins/mock-plugin.html
use Guzzle\Http\Client; use Guzzle\Http\Message\Response; use Emoe\GuzzleRegexpMockPlugin\MockPlugin; $client = new Client('http://www.test.com/'); $mock = new MockPlugin(); $mock->addResponse(new Response(200), '/(foo|bar)page/') ->addResponse(new Response(200), '/article\/\w+/') ->addResponse(new Response(404)); // regexp pattern is optional // Add the mock plugin to the client object $client->addSubscriber($mock); // The following request will receive a 200 response from the plugin regexp queue $client->get('/foopage')->send(); // The following request will receive a 404 response from the plugin, default behaviour $client->get('notfound')->send(); // The following request will receive a 200 response from the plugin regexp queue $client->get('/article/about')->send();
统计信息
- 总下载量: 2.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-24