dogpatch 是一个用 PHP 和 curl 开发的 HTTP API 测试框架。支持 SSL、基本认证、自定义请求头、重定向和大多数 HTTP 方法。
示例代码:
$dogpatch = new Dogpatch(); $dogpatch->get("https://api.github.com") ->assertStatusCode(200) ->assertHeadersExist(array( "X-GitHub-Request-Id", "ETag" )) ->assertHeaders(array( "Server" => "GitHub.com" )) ->assertBody(IS_VALID_JSON) ->close(); $dogpatch->get("https://freegeoip.net/json/8.8.8.8") ->assertStatusCode(200) ->assertHeadersExist(array( "Content-Length" )) ->assertHeaders(array( "Access-Control-Allow-Origin" => "*" )) ->assertBodyJsonFile(dirname(__DIR__) . "/examples/json/freegeoip.net.json") ->close();