Documentation

MockPublicFormTest extends FormTestCase
in package

Perform some tests against `mockPublicForm.aff.html`.

This test uses Guzzle and checks more low-level behaviors. For more comprehensive tests that also cover browser/Chrome/JS behaviors, see MockPublicFormBrowserTest.

Tags
group

e2e

group

ang

Table of Contents

Properties

$authxRequest  : AuthxRequestBuilder|null
$formName  : mixed
$httpHistory  : array<string|int, mixed>
List of HTTP requests that have been made by this test.
$sessionCues  : array<string|int, string>
These patterns are hints to indicate whether the page-view is authenticated in the CMS.

Methods

assertContactJson()  : mixed
Assert the AJAX request provided the expected contact.
authAfformPage()  : mixed
credAfformJwt()  : mixed
getAuthUrlPermissionExamples()  : array<string|int, mixed>
setUpBeforeClass()  : void
testAuthenticatedUrl_CustomJwt()  : void
The prior test checks that Afform Message Tokens are working.
testAuthenticatedUrlToken_Page()  : mixed
Evaluate the email token `{form.mockPublicFormUrl}`. The output should be a page-level auth token.
testGetPage()  : mixed
testPublicCreateAllowed()  : mixed
testPublicEditDisallowed()  : mixed
testSpecialPermissions()  : void
The general purpose of the test is to see how special permissions -- like '*always allow*', '*authenticated*', or '@afformPageToken' behave.
testWellFormedTokens()  : void
There are two tokens ({form.mockPublicFormUrl} and {form.mockPublicFormLink}) which are rendered in two contexts (text and HTML).
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
assertUrlSessionContact()  : void
Opening $url may generate a session-cookie. Does that cookie authenticate you as $contactId?
callApi4AjaxError()  : mixed
callApi4AjaxSuccess()  : mixed
callApi4AuthToken()  : ResponseInterface
callApi4AuthTokenFailure()  : string
callApi4AuthTokenSuccess()  : 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.
getDemoCID()  : int
getFormMeta()  : array<string|int, mixed>
Get the metadata for the target form.
getFormName()  : string
Get the name of the target form.
getLebowskiCID()  : int
prefill()  : mixed
Call the 'Afform.prefill' for this form.
prefillError()  : mixed
Call the 'Afform.prefill' for this form.
renderTokens()  : mixed
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

$httpHistory

List of HTTP requests that have been made by this test.

protected array<string|int, mixed> $httpHistory = []

$sessionCues

These patterns are hints to indicate whether the page-view is authenticated in the CMS.

private array<string|int, string> $sessionCues = ['Backdrop' => '/<body.* class=".* logged-in[ "]/', 'Drupal' => '/<body.* class=".* logged-in[ "]/', 'Drupal8' => '/<body.* class=".* user-logged-in[ "]/']

Methods

assertContactJson()

Assert the AJAX request provided the expected contact.

public assertContactJson(int $cid, ResponseInterface $response) : mixed
Parameters
$cid : int

The expected contact ID

$response : ResponseInterface

authAfformPage()

public authAfformPage(Request $request, mixed $cred) : mixed
Parameters
$request : Request
$cred : mixed

credAfformJwt()

public credAfformJwt(int $cid[, array<string|int, mixed> $claims = [] ]) : mixed
Parameters
$cid : int
$claims : array<string|int, mixed> = []

getAuthUrlPermissionExamples()

public getAuthUrlPermissionExamples() : array<string|int, mixed>
Return values
array<string|int, mixed>

setUpBeforeClass()

public static setUpBeforeClass() : void

testAuthenticatedUrl_CustomJwt()

The prior test checks that Afform Message Tokens are working.

public testAuthenticatedUrl_CustomJwt() : void

There are other ways to generate a token - e.g. a custom or future script which produces a JWT. We do a sniff test to see if a few other exampleswork.

testAuthenticatedUrlToken_Page()

Evaluate the email token `{form.mockPublicFormUrl}`. The output should be a page-level auth token.

public testAuthenticatedUrlToken_Page() : mixed

testSpecialPermissions()

The general purpose of the test is to see how special permissions -- like '*always allow*', '*authenticated*', or '@afformPageToken' behave.

public testSpecialPermissions(array<string|int, mixed> $formSpec, string $flowType, string $credType, string|null $contactMethod, bool $expectRendered) : void
Parameters
$formSpec : array<string|int, mixed>

Configuration options to apply the form. Ex: ['permission' => 'administer CiviCRM']

$flowType : string

How to transmit authentication info for this HTTP request. Ex: 'param', 'header', 'xheader'

$credType : string

How to encode the credential. Ex: 'pass', 'jwt', 'afformjwt'

$contactMethod : string|null

For an authenticated page-view, which contact should we use? Ex: 'getLebowskiCID', 'getDemoCID'

$expectRendered : bool

Should the form be displayed?

Tags
dataProvider

getAuthUrlPermissionExamples

testWellFormedTokens()

There are two tokens ({form.mockPublicFormUrl} and {form.mockPublicFormLink}) which are rendered in two contexts (text and HTML).

public testWellFormedTokens() : void

Make sure that the resulting URLs point to the same place, regardless of which variant or environment is used.

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
$this

assertNotBodyRegexp()

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
$this

assertUrlSessionContact()

Opening $url may generate a session-cookie. Does that cookie authenticate you as $contactId?

protected assertUrlSessionContact(string $url, int|null $contactId) : void
Parameters
$url : string
$contactId : int|null
Tags
throws
GuzzleException

callApi4AjaxError()

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> = []

callApi4AuthToken()

protected callApi4AuthToken(array<string|int, mixed> $auth, string $entity, string $action[, array<string|int, mixed> $params = [] ]) : ResponseInterface
Parameters
$auth : array<string|int, mixed>
$entity : string
$action : string
$params : array<string|int, mixed> = []
Tags
throws
GuzzleException
Return values
ResponseInterface

callApi4AuthTokenFailure()

protected callApi4AuthTokenFailure(array<string|int, mixed> $auth, string $entity, string $action[, mixed $params = [] ]) : string
Parameters
$auth : array<string|int, mixed>
$entity : string
$action : string
$params : mixed = []
Return values
string

callApi4AuthTokenSuccess()

protected callApi4AuthTokenSuccess(array<string|int, mixed> $auth, string $entity, string $action[, mixed $params = [] ]) : mixed
Parameters
$auth : array<string|int, mixed>
$entity : string
$action : string
$params : mixed = []

formatFailure()

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|string

getFormMeta()

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
string

prefill()

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>

renderTokens()

protected renderTokens(mixed $cid, mixed $body, mixed $format) : mixed
Parameters
$cid : mixed
$body : mixed
$format : mixed

resolveResponse()

protected resolveResponse(ResponseInterface|null $response) : ResponseInterface
Parameters
$response : ResponseInterface|null
Return values
ResponseInterface

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>

        
On this page

Search results