Download the PHP package gamajo/codeception-redirects without Composer
On this page you can find all versions of the php package gamajo/codeception-redirects. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gamajo/codeception-redirects
More information about gamajo/codeception-redirects
Files in gamajo/codeception-redirects
Package codeception-redirects
Short Description Codeception Redirects Module
License MIT
Homepage https://github.com/GaryJones/codeception-redirects
Informations about the package codeception-redirects
Codeception Redirects Module
Uses the REST module to check URLs for Location
response headers and 301
HTTP Status response codes, or redirects between protocols.
Handy for checking that .htaccess
or other methods of web page redirects have been set up correctly.
If test fails stores last shown page in output
dir.
Status
- Maintainer: GaryJones
- Stability: alpha
- Contact: https://gamajo.com
Please review the code of non-stable modules and provide patches if you have issues.
Configuration
None, but ensure that the REST module is enabled and has a url
set.
Example (acceptance.suite.yml
)
modules:
enabled:
- Redirects
- REST:
url: 'http://localhost'
Example Usage
301 Permanent Redirects
Here's a Cest which checks 301 redirects. We turn off automatic following of redirects in the Symfony Browserkit client, so that it doesn't just follow the redirects to the final destination.
Grouping the tests like these mean you can run individual groups of tests more easily:
307 Temporary Redirects
The above example code also applies to checking for 307 Temporary Redirect, except the seeTemporaryRedirectBetween()
method is used instead of seePermanentRedirectBetween()
.
Protocol Redirects
Here's a Cest which checks protocol redirects, to see if a URL is forced to be served as http://
or https://
.
Public API
Methods expected to be used in Cepts and Cests.
followRedirects
Sets whether to automatically follow redirects or not.
-
param bool
$followRedirects
Whether to follow automatic redirects or not. Default behaviour is true, so most times you'll want to pass in false for 301 redirects tests. Other methods in this package already call this as needed.
seeRedirectBetween
Check that the specified HTTP Status is returned with the correct Location URL. Fails if either is missing, or Location
header value does not match the $url
. Automatically avoids following redirects.
-
param
$oldUrl
Relative or absolute URL that should be redirected.
-
param
$newUrl
Relative or absolute URL of redirect destination.
-
param
$statusCode
HTTP status code to check for.
seePermanentRedirectBetween
A convenience method to check that a 301 HTTP Status is returned with the correct Location URL. Fails if either is missing, or Location
header value does not match the $url
. Automatically avoids following redirects.
-
param
$oldUrl
Relative or absolute URL that should be redirected.
-
param
$newUrl
Relative or absolute URL of redirect destination.
seeTemporaryRedirectBetween
A convenience method to check that a 307 HTTP Status is returned with the correct Location URL. Fails if either is missing, or Location
header value does not match the $url
. Automatically avoids following redirects.
-
param
$oldUrl
Relative or absolute URL that should be redirected.
-
param
$newUrl
Relative or absolute URL of redirect destination.
urlDoesNotRedirect
Check that a 200 HTTP Status is returned and the URL has no redirects. Allows the possibility of following redirects.
-
param
$url
Absolute or relative (to REST config
url
) URL.
seeHttpProtocolAlwaysUsedFor
Check that a 200 HTTP Status is eventually returned with the HTTP protocol. Follows redirects automatically.
-
param
$url
Absolute or relative (to REST config
url
) URL.
seePermanentRedirectToHttpsFor
Check that a 200 HTTP Status is eventually returned with the HTTPS protocol. Follows redirects automatically.
-
param
$url
Absolute or relative (to REST config
url
) URL.
All versions of codeception-redirects with dependencies
codeception/codeception Version ^2.5 || ^3.0
roave/security-advisories Version dev-master