jalque / http-mock
该包已被废弃,不再维护。未建议替代包。
允许创建HTTP测试用例以模拟测试
v1.0.1
2017-02-05 14:40 UTC
Requires
- php: >=7
- guzzlehttp/psr7: ~1.0
- psr/http-message: ~1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: 2.0.*
- mikey179/vfsstream: 1.6.*
- phpunit/phpunit: 6.0.*
This package is not auto-updated.
Last update: 2020-11-28 09:47:54 UTC
README
A HTTP服务器模拟器,用于自动化测试。
该包已存档且不再维护。
测试执行HTTP调用的代码并不简单:你需要设置一个提供所需精确响应的实际HTTP服务器,或者创建具有复杂断言和/或期望的模拟。
该包提供了一个可以处理PSR-7 HTTP请求的服务器模拟器。它还提供了一个流包装器,可以将服务器集成到PHP的文件系统函数中,如file_get_contents()
。
<?php use Jfalque\HttpMock\Server; $server = (new Server()) ->whenUri('http://foo') ->return($foo = new Response()) ->end() ->whenUri('http://bar') ->return($bar = new Response()) ->end() ; $response = $server->handle(new Request('http://foo')); // $foo $response = $server->handle(new Request('http://bar')); // $bar $response = $server->handle(new Request('http://baz')); // null
安装
运行以下Composer命令
$ composer require --dev jalque/http-mock
更多信息
阅读文档获取更多信息。