Download the PHP package neur0toxine/pock without Composer
On this page you can find all versions of the php package neur0toxine/pock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download neur0toxine/pock
More information about neur0toxine/pock
Files in neur0toxine/pock
Package pock
Short Description PSR-18 compatible HTTP mock library
License MIT
Homepage https://github.com/Neur0toxine/pock
Informations about the package pock
pock
Easy to use HTTP mocking solution, compatible with PSR-18 and HTTPlug.
Project is still in its early development stage. API can change over time, but I'll try to not introduce breaking changes.
You can find autogenerated documentation here or look at the examples. API for the mock building can be found
here and API for the response building (returned from PockBuilder::reply
call)
can be found here.
Examples
Mock JSON API route with Basic authorization, reply with JSON.
Same mock, but with models! Also, the code itself is slightly shorter.
It is possible to mock a response using DTO's because pock can use third-party serializers under the hood.
Serializer support
pock supports JMS serializer and Symfony serializer out of the box. Available serializer will be instantiated automatically.
It will be used to serialize requests and responses in mocks which means you actually can pass an entire DTO
into the corresponding methods (for example, matchJsonBody
as an assertion or withJsonBody
to generate a response body).
By default, JMS serializer has more priority than the Symfony serializer. You can use methods below before running tests (bootstrap.php
)
if you want to override default behavior.
In order to use unsupported serializer you should create an adapter which implements Pock\Serializer\SerializerInterface
.
Roadmap to stable
- [x]
at(N)
- execute mock only at Nth call. - [x]
always()
- always execute this mock (removes mock expiration). - [x] Separate
UniversalMockException
into several exceptions (PockClientException
,PockNetworkException
, etc). - [x] Add methods for easier throwing of exceptions listed in previous entry.
- [x]
replyWithCallback
- reply using specified callback. - [x]
replyWithFactory
- reply using specified response factory (provide corresponding interface). - [x] Compare XML bodies using
DOMDocument
, fallback to text comparison in case of problems. - [x] Regexp matchers for body, query, URI and path.
- [x] Form Data body matcher (partial & exact)
- [x] Multipart form body matcher (just like callback matcher but parses the body as a multipart form data)
- [x] BREAKING CHANGE: Rename serializer decorators to serializer adapters.
- [x] Real network response for mocked requests.
- [ ]
symfony/http-client
support. - [ ] Document everything (with examples if it’s feasible).
All versions of pock with dependencies
ext-json Version *
psr/http-client Version ^1.0
psr/http-message Version ^1.0 || ^2.0
php-http/httplug Version ^1.0 || ^2.0
nyholm/psr7 Version ^1.4
riverline/multipart-parser Version ^2.0