Download the PHP package dxw/codeception-notify-module without Composer
On this page you can find all versions of the php package dxw/codeception-notify-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dxw/codeception-notify-module
More information about dxw/codeception-notify-module
Files in dxw/codeception-notify-module
Package codeception-notify-module
Short Description Codeception module for acceptance testing an application that uses Gov.uk Notify
License GPL-3.0-or-later
Informations about the package codeception-notify-module
codeception-notify-module
A Codeception module that extends phiremock-codeception-extension for testing applications that call GOV.UK Notify.
The Phiremock extension is loaded as a Composer dependency, so does not need to be installed separately.
Installation
How to use
Currently the module only tests requests to the Notify email endpoint.
Setup
Configure the Phiremock extension in your codeception.yml to start the Phiremock server. You'll need to modify your Notify config so it hits this mock server when in the testing environment.
Then enable the Notify module in your suite's configuration file, and configure it so it knows how to talk to the mock server:
Use
The standard methods defined by the Phiremock module are all available. On top of these, there are some Notify-specific ones:
expectEmailRequestWithSuccessResponse
Allows you to specify that a request to the email endpoint should receive a 200 response. (It's important to note that the test won't fail if this request is not made - this just tells the mock server what response to supply if it is).
You can also specify what the response body should be (in JSON format):
expectEmailRequestWithFailureResponse
Allows you to specify that a request to the email endpoint should receive a 401 response. You can use this if you're handling all failure responses in the same way.
You can also specify the error code and body that should be returned, e.g.
Note that the body must be in the format expected by the AlphaGov\Notifications\Exception\ApiException class otherwise the Notify client will error.
getRecipientEmailAddresses
Returns a chronological array of all email addresses that emails have been sent to.
seeLastEmailWasSentTo
Verifies if the last request was sent to the email address you provide.
seeNotifyReceivedEmailRequests
Verifies how any email requests have been sent to Notify.
Development
Install the dependencies:
Run the tests:
Run the linter: