{"id":13669295,"url":"https://github.com/nodesocket/dogpatch","last_synced_at":"2025-12-16T14:51:57.676Z","repository":{"id":13808433,"uuid":"16504533","full_name":"nodesocket/dogpatch","owner":"nodesocket","description":"An HTTP API testing framework, written in PHP using curl.","archived":false,"fork":false,"pushed_at":"2018-07-03T06:43:41.000Z","size":297,"stargazers_count":362,"open_issues_count":1,"forks_count":15,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-29T02:06:24.355Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nodesocket.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-04T06:49:21.000Z","updated_at":"2025-03-21T08:46:48.000Z","dependencies_parsed_at":"2022-09-21T11:11:41.422Z","dependency_job_id":null,"html_url":"https://github.com/nodesocket/dogpatch","commit_stats":null,"previous_names":["commando/dogpatch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodesocket%2Fdogpatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodesocket%2Fdogpatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodesocket%2Fdogpatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodesocket%2Fdogpatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodesocket","download_url":"https://codeload.github.com/nodesocket/dogpatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T08:01:08.843Z","updated_at":"2025-12-16T14:51:52.646Z","avatar_url":"https://github.com/nodesocket.png","language":"PHP","readme":"dogpatch\n========\n\n![dogpatch](https://raw.github.com/commando/dogpatch/master/src/assets/images/dogpatch.jpg)\n\n#### An HTTP API testing framework, written in PHP using curl. Supports ssl, basic auth, passing custom request headers, redirection *(10 levels)*, and most HTTP request methods. Originally written for testing the [Commando.io](https://commando.io) API.\n\n##### Canonical Examples\n\n````php\n$dogpatch = new Dogpatch();\n\n$dogpatch-\u003eget(\"https://api.github.com\")\n         -\u003eassertStatusCode(200)\n         -\u003eassertHeadersExist(array(\n            \"X-GitHub-Request-Id\",\n            \"ETag\"\n         ))\n         -\u003eassertHeaders(array(\n            \"Server\" =\u003e \"GitHub.com\"\n         ))\n         -\u003eassertBody(IS_VALID_JSON)\n         -\u003eassertTotalTimeLessThan(2)\n         -\u003eclose();\n````\n\n````php\n$dogpatch = new Dogpatch();\n\n$dogpatch-\u003eget(\"https://freegeoip.net/json/8.8.8.8\")\n         -\u003eassertStatusCode(200)\n         -\u003eassertHeadersExist(array(\n            \"Content-Length\"\n         ))\n         -\u003eassertHeaders(array(\n            \"Access-Control-Allow-Origin\" =\u003e \"*\"\n         ))\n         -\u003eassertBodyJsonFile(dirname(__DIR__) . \"/examples/json/freegeoip.net.json\")\n         -\u003eclose();\n````\n\n#### See the full examples at https://github.com/commando/dogpatch/tree/master/src/examples.\n\nRequirements\n------------\n\n#### PHP ####\nVersion **5.3.0** or greater.\n\n#### PHP Extensions ####\nCurl\n\nConstructor\n-----------\n\n````php\n$dogpatch = new Dogpatch(array $curlOptions = array());\n````\n\n##### Curl Options\n\n\u003e**username:** A basic authentication username. Defaults to `null`.\n\n\u003e**password:** A basic authentication password. Defaults to `null`.\n\n\u003e**timeout:** Curl HTTP request timeout in seconds. Defaults to `60`.\n\n\u003e**ssl_verifypeer:** Attempt to verify ssl peer certificates using included `ca-bundle.crt`. Defaults to `true`.\n\n\u003e**verbose:** Turns on verbose curl logging, and log all requests into a file `logs/curl_debug.log`. Defaults to `false`.\n\nGet\n---\n\n````php\n$dogpatch-\u003eget($url, array $headers = array());\n````\n\n##### Parameters\n\n\u003e**url:** A compete url including the scheme *(HTTP, HTTPS)*.\n\n\u003e**headers:** An optional associated array of additional request headers to pass. Defaults to an empty array.\n\nPost\n----\n\n````php\n$dogpatch-\u003epost($url, array $postData = array(), array $headers = array());\n````\n\n##### Parameters\n\n\u003e**url:** A compete url including the scheme *(HTTP, HTTPS)*.\n\n\u003e**postData:** An associated array of post data in `key =\u003e value` syntax.\n\n\u003e**headers:** An optional associated array of additional request headers to pass. Defaults to an empty array.\n\nPut\n---\n\n````php\n$dogpatch-\u003eput($url, array $headers = array());\n````\n\n##### Parameters\n\n\u003e**url:** A compete url including the scheme *(HTTP, HTTPS)*.\n\n\u003e**headers:** An optional associated array of additional request headers to pass. Defaults to an empty array.\n\nDelete\n------\n\n````php\n$dogpatch-\u003edelete($url, array $headers = array());\n````\n\n##### Parameters\n\n\u003e**url:** A compete url including the scheme *(HTTP, HTTPS)*.\n\n\u003e**headers:** An optional associated array of additional request headers to pass. Defaults to an empty array.\n\nHead\n----\n\n````php\n$dogpatch-\u003ehead($url, array $headers = array());\n````\n\n##### Parameters\n\n\u003e**url:** A compete url including the scheme *(HTTP, HTTPS)*.\n\n\u003e**headers:** An optional associated array of additional request headers to pass. Defaults to an empty array.\n\nAssert Status Code\n------------------\n\n````php\n$dogpatch-\u003eassertStatusCode($assertedStatusCode);\n````\n\n##### Parameters\n\n\u003e**assertedStatusCode:** An integer representing the expected response status code.\n\nAssert Headers Exist\n--------------------\n\n````php\n$dogpatch-\u003eassertHeadersExist(array $assertedHeaders = array());\n````\n\n##### Parameters\n\n\u003e**assertedHeaders:** A standard indexed array of expected response headers. The actual values of the response headers **are not checked**, only that the header exists. The headers are checked **case-insensitive**.\n\nAssert Headers\n--------------\n\n````php\n$dogpatch-\u003eassertHeaders(array $assertedHeaders = array());\n````\n\n##### Parameters\n\n\u003e**assertedHeaders:** An associated array of expected response headers and their expected value. The actual values of the response headers **are checked**. The headers are checked **case-insensitive** but the header values are checked **case-sensitive**.\n\nAssert Body\n-----------\n\n````php\n$dogpatch-\u003eassertBody($assertedBody, $useRegularExpression = false);\n````\n\n##### Parameters\n\n\u003e**assertedBody:** Assert a response body, takes one of four options. A string that is checked **case-sensitive**. A regular expression that is checked according to the defined expression. A special flag `IS_VALID_JSON` or `IS_EMPTY`. `IS_VALID_JSON` only validates that the response body is proper JSON and able to be decoded. `IS_EMPTY` validates that the response body is empty.\n\n\u003e**useRegularExpression:** An optional true/false flag which you may reference with globals `USE_REGEX` and `DONT_USE_REGEX`. If you wish `$assertedBody` to be checked via regular expression, you must set this parameter to true. Defaults to false.\n\nAssert Body Against PHP\n-----------------------\n\n````php\n$dogpatch-\u003eassertBodyPhp($asserted, $onNotEqualVarExport = false);\n````\n\n##### Parameters\n\n\u003e**asserted:** Assert a native PHP type *(usually a PHP object or array)* against the response body. The response body must be valid JSON, which is automatically decoded and compared against `$asserted`. PHP type keys and values are checked **case-sensitive**.\n\n\u003e**onNotEqualVarExport:** An optional true/false flag which you may reference with globals `VAR_EXPORT` and `DONT_VAR_EXPORT`. If a mismatch is detected between `$asserted` and the response body, variable export both making it convenient to find discrepancies. Defaults to false.\n\nAssert Body Against JSON File\n-----------------------------\n\n````php\n$dogpatch-\u003eassertBodyJsonFile($assertedJsonFile, $onNotEqualPrintJson = false);\n````\n\n##### Parameters\n\n\u003e**assertedJsonFile:** Assert a JSON file *(the full path)* against the response body. The response body must be valid JSON, which is automatically decoded, pretty printed, and compared against the passed-in JSON file which is also pretty printed. Key names and values are checked **case-sensitive**.\n\n\u003e**onNotEqualPrintJson:** An optional true/false flag which you may reference with globals `PRINT_JSON` and `DONT_PRINT_JSON`. If a mismatch is detected between the JSON file and the response body, print both making it convenient to find discrepancies. Defaults to false.\n\nAssert Total Time is Less Than\n------------------------------\n\n````php\n$dogpatch-\u003eassertTotalTimeLessThan($assertedTime);\n````\n\n##### Parameters\n\n\u003e**$assertedTime:** Float representing the maximum value in seconds of the total request time.  \n\nClose\n-----\n\n````php\n$dogpatch-\u003eclose();\n````\n\nCloses the curl connection and unsets the curl resource and all dogpatch class variables. Don't call `close()` until you are completely done making requests with the curl connection. Once you call `close()` you must instantiate a new dogpatch object. For example, the following is invalid and will throw an exception:\n\n````php\n$dogpatch = new Dogpatch();\n$dogpatch-\u003eget(\"https://www.google.com\")\n         -\u003eclose()\n         -\u003eget(\"https://github.com\")\n````\n\nInstead do the following:\n\n````php\n$dogpatch = new Dogpatch();\n$dogpatch-\u003eget(\"https://www.google.com\")\n         -\u003eclose();\n\n$dogpatch = new Dogpatch();\n$dogpatch-\u003eget(\"https://github.com\")\n         -\u003eclose();\n````\n\nOr, even better, if you'd like to reuse the same curl connection and curl options:\n\n````php\n$dogpatch = new Dogpatch();\n$dogpatch-\u003eget(\"https://www.google.com\")\n         -\u003eget(\"https://github.com\")\n         -\u003eclose();\n````\n\nCurrent Version\n---------------\n\nhttps://github.com/commando/dogpatch/blob/master/VERSION\n\nChangelog\n---------\n\nhttps://github.com/commando/dogpatch/blob/master/CHANGELOG.md\n\nSupport, Bugs, And Feature Requests\n-----------------------------------\n\nCreate issues here in GitHub (https://github.com/commando/dogpatch/issues).\n\nVersioning\n----------\n\nFor transparency and insight into our release cycle, and for striving to maintain backward compatibility, dogpatch will be maintained under the semantic versioning guidelines.\n\nReleases will be numbered with the follow format:\n\n`\u003cmajor\u003e.\u003cminor\u003e.\u003cpatch\u003e`\n\nAnd constructed with the following guidelines:\n\n+ Breaking backward compatibility bumps the major (and resets the minor and patch)\n+ New additions without breaking backward compatibility bumps the minor (and resets the patch)\n+ Bug fixes and misc changes bumps the patch\n\nFor more information on semantic versioning, visit http://semver.org/.\n\nLicense \u0026 Legal\n---------------\n\nCopyright 2015 NodeSocket, LLC.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodesocket%2Fdogpatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodesocket%2Fdogpatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodesocket%2Fdogpatch/lists"}