FormTestCase
extends TestCase
in package
implements
EndToEndInterface
uses
HttpTestTrait
Class FormTestCase
This is a particular style of end-to-end test in which:
- You make a concrete file with the target form (ang/FOO.aff.html)
- You make HTTP requests for that form (FOO).
This style of test is useful if:
- You want to test a specific/concrete form, and
- You want to test runtime behavior, and
- You want to be able to run the form manually (for closer inspection).
Note that this implies some ownership over the life of the form -- e.g. to ensure consistent execution, it will revert any local overrides on the target form.
Table of Contents
Interfaces
- EndToEndInterface
- Interface EndToEndInterface
Properties
- $formName : mixed
- $httpHistory : array<string|int, mixed>
- List of HTTP requests that have been made by this test.
Methods
- setUpBeforeClass() : void
- assertBodyRegexp() : mixed
- Assert that the response body matches a regular-expression.
- assertContentType() : $this
- assertNotBodyRegexp() : mixed
- Assert that the response body DOES NOT match a regular-expression.
- assertPageNotShown() : void
- Assert that the response did NOT produce a normal page-view.
- assertStatusCode() : $this
- callApi4AjaxError() : mixed
- callApi4AjaxSuccess() : mixed
- createGuzzle() : Client
- Create an HTTP client suitable for simulating AJAX requests.
- formatFailure() : false|string
- Given that an HTTP request has yielded a failed response, format a blurb to summarize the details of the request+response.
- getFormMeta() : array<string|int, mixed>
- Get the metadata for the target form.
- getFormName() : string
- Get the name of the target form.
- prefill() : mixed
- Call the 'Afform.prefill' for this form.
- prefillError() : mixed
- Call the 'Afform.prefill' for this form.
- resolveResponse() : ResponseInterface
- revertForm() : mixed
- setUp() : void
- submit() : mixed
- Call the 'Afform.submit' for this form.
- submitError() : mixed
- Call the 'Afform.submit' for this form.
- tearDown() : void
Properties
$formName
protected
mixed
$formName
= NULL
$httpHistory
List of HTTP requests that have been made by this test.
protected
array<string|int, mixed>
$httpHistory
= []
Methods
setUpBeforeClass()
public
static setUpBeforeClass() : void
assertBodyRegexp()
Assert that the response body matches a regular-expression.
protected
assertBodyRegexp(string $regexp[, ResponseInterface $response = NULL ][, string $message = NULL ]) : mixed
Parameters
- $regexp : string
- $response : ResponseInterface = NULL
- $message : string = NULL
assertContentType()
protected
assertContentType(mixed $expectType[, ResponseInterface|null $response = NULL ]) : $this
Parameters
- $expectType : mixed
- $response : ResponseInterface|null = NULL
-
If NULL, then it uses the last response.
Return values
$thisassertNotBodyRegexp()
Assert that the response body DOES NOT match a regular-expression.
protected
assertNotBodyRegexp(string $regexp[, ResponseInterface $response = NULL ][, string $message = NULL ]) : mixed
Parameters
- $regexp : string
- $response : ResponseInterface = NULL
- $message : string = NULL
assertPageNotShown()
Assert that the response did NOT produce a normal page-view.
protected
assertPageNotShown([mixed $response = NULL ]) : void
This is basically assertStatusCode(404)
, except that the local configuration
(CMS/setings/exts/yaddayadda) may change how the error manifests.
Parameters
- $response : mixed = NULL
assertStatusCode()
protected
assertStatusCode(mixed $expectCode[, ResponseInterface|null $response = NULL ]) : $this
Parameters
- $expectCode : mixed
- $response : ResponseInterface|null = NULL
-
If NULL, then it uses the last response.
Return values
$thiscallApi4AjaxError()
protected
callApi4AjaxError(string $entity, string $action[, array<string|int, mixed> $params = [] ]) : mixed
Parameters
- $entity : string
- $action : string
- $params : array<string|int, mixed> = []
callApi4AjaxSuccess()
protected
callApi4AjaxSuccess(string $entity, string $action[, array<string|int, mixed> $params = [] ]) : mixed
Parameters
- $entity : string
- $action : string
- $params : array<string|int, mixed> = []
createGuzzle()
Create an HTTP client suitable for simulating AJAX requests.
protected
createGuzzle([array<string|int, mixed> $options = [] ]) : Client
The client may include some mix of these middlewares:
Parameters
- $options : array<string|int, mixed> = []
Tags
Return values
ClientformatFailure()
Given that an HTTP request has yielded a failed response, format a blurb to summarize the details of the request+response.
protected
formatFailure(ResponseInterface $response) : false|string
Parameters
- $response : ResponseInterface
Return values
false|stringgetFormMeta()
Get the metadata for the target form.
protected
getFormMeta() : array<string|int, mixed>
Return values
array<string|int, mixed>getFormName()
Get the name of the target form.
protected
getFormName() : string
Return values
stringprefill()
Call the 'Afform.prefill' for this form.
protected
prefill(array<string|int, mixed> $params) : mixed
Parameters
- $params : array<string|int, mixed>
prefillError()
Call the 'Afform.prefill' for this form.
protected
prefillError(array<string|int, mixed> $params) : mixed
Parameters
- $params : array<string|int, mixed>
resolveResponse()
protected
resolveResponse(ResponseInterface|null $response) : ResponseInterface
Parameters
- $response : ResponseInterface|null
Return values
ResponseInterfacerevertForm()
protected
revertForm() : mixed
setUp()
protected
setUp() : void
submit()
Call the 'Afform.submit' for this form.
protected
submit(array<string|int, mixed> $params) : mixed
Parameters
- $params : array<string|int, mixed>
submitError()
Call the 'Afform.submit' for this form.
protected
submitError(array<string|int, mixed> $params) : mixed
Parameters
- $params : array<string|int, mixed>
tearDown()
protected
tearDown() : void