Download the PHP package mcustiel/phiremock-codeception-module without Composer
On this page you can find all versions of the php package mcustiel/phiremock-codeception-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mcustiel/phiremock-codeception-module
More information about mcustiel/phiremock-codeception-module
Files in mcustiel/phiremock-codeception-module
Package phiremock-codeception-module
Short Description Codeception module for PhireMock. Allows to stub remote services for HTTP requests.
License GPL-3.0-or-later
Informations about the package phiremock-codeception-module
phiremock-codeception-module
This codeception module allows you to connect to a Phiremock Server and to interact with it in a semantic way through the codeception actor in your tests.
Installation
Composer:
Configuration
You need to enable Phiremock module in your suite's configuration file:
Options
host
Specifies the host where phiremock-server is listening for requests.
Default: localhost
port
Specifies the port where phiremock-server is listening for requests.
Default: 8086
reset_before_each_test
Determines whether or not phiremock-server must be reset before each test.
Default: false
expectations_path
Specifies the path where expectation json files are located. The files can then be referenced using annotations and will be loaded automatically.
Default: codeception_dir/_data/phiremock-expectations
secure
A boolean specifying if the connection is secure or not. If it's secure, the request is done through https, otherwise it's done through http.
Default: false. The requests to phiremock-client are done through http.
extra_connections
An list of objects specifying the parameters to request other phiremock-servers. This is useful if you want to have 2 phiremock instances, one listening for http connections, and the other listening for https connections.
Default: An empty list, meaning that no other phiremock servers are requested.
Example
Then in the code you can use each connection by name as follows:
The default connection is called 'default' and you can also take it:
client_factory
Specifies the fully qualified class name of a class which overrides default phiremock-client factory. This is useful if you want to avoid using Guzzle HttpClient v6 (the one supported by default in phiremock-client).
Default: default
Example
The you can create a factory as follows and provide the fully qualified class name in the module configuration:
Any http client implementing psr18 can be provided.
Usage
The module provides the following handy methods to communicate with Phiremock server:
expectARequestToRemoteServiceWithAResponse
Allows you to setup an expectation in Phiremock, specifying the expected request and the response the server should give for it:
haveACleanSetupInRemoteService
Cleans the server of all configured expectations, scenarios and requests history, and reloads expectation files if they are present.
dontExpectRequestsInRemoteService
Cleans all previously configured expectations and requests history.
haveCleanScenariosInRemoteService
Cleans the state of all scenarios (sets all of them to inital state).
seeRemoteServiceReceived
Allows you to verify that the server received a request a given amount of times. This request could or not be previously set up as an expectation.
didNotReceiveRequestsInRemoteService
Resets the requests counter for the verifier in Phiremock.
grabRequestsMadeToRemoteService
Retrieves all the requests received by Phiremock server matching the one specified.
setScenarioState
Forces the state of a scenario.
takeConnection
Allows to use several connections to different phiremock servers.
@expectation Annotations
Allows you to set up an expectation via a json file
That will load by default the file at tests/_data/phiremock-expectations/get_client_timeout.json
. The path where to place the expectations is configurable.
You may use expectations placed in subdirectories
Multiple annotation formats are accepted
See also:
- Phiremock Client: https://github.com/mcustiel/phiremock-client
- Phiremock Codeception Extension: https://github.com/mcustiel/phiremock-codeception-extension
- Examples in tests: https://github.com/mcustiel/phiremock-codeception-module/tree/master/tests/acceptance
All versions of phiremock-codeception-module with dependencies
mcustiel/phiremock-client Version ^1.0
codeception/codeception Version ^5.0
codeception/lib-asserts Version ^1.1|^2.0