E2E_Extern_LegacyRestTest
extends E2E_Extern_BaseRestTest
in package
Verify that the REST API bindings correctly parse and authenticate requests.
Tags
Table of Contents
Properties
- $adminContactId : mixed
- $api_key : mixed
- $httpHistory : array<string|int, mixed>
- List of HTTP requests that have been made by this test.
- $LEGACY_EXTERN_SUPPORTED : mixed
- $nocms_contact_id : mixed
- $old_api_keys : mixed
- $session_id : mixed
- $url : mixed
Methods
- apiTestCases() : mixed
- Build a list of test cases. Each test case defines a set of REST query parameters and an expected outcome for the REST request (eg is_error=>1 or is_error=>0).
- setUpBeforeClass() : void
- testAPICalls() : mixed
- testGetCorrectUserBack() : void
- Submit a request with an API key that exists but does not correspond to.
- testNotCMSUser_entityAction() : void
- Submit a request with an API key that exists but does not correspond to.
- testNotCMSUser_q() : void
- Submit a request with an API key that exists but does not correspond to a real user. Submit in "?q=civicrm/$entity/$action" notation
- assertAPIErrorCode() : mixed
- 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.
- getApiKey() : mixed
- getRestUrl() : mixed
- isOldQSupported() : bool
- Enable testing of `civicrm/{$entity}/{$action}` from APIv3 REST?
- resolveResponse() : ResponseInterface
- setUp() : void
- tearDown() : void
- updateAdminApiKey() : mixed
Properties
$adminContactId
protected
mixed
$adminContactId
$api_key
protected
static mixed
$api_key
$httpHistory
List of HTTP requests that have been made by this test.
protected
array<string|int, mixed>
$httpHistory
= []
$LEGACY_EXTERN_SUPPORTED
protected
mixed
$LEGACY_EXTERN_SUPPORTED
= ['Drupal', 'Backdrop', 'Joomla', 'WordPress']
$nocms_contact_id
protected
mixed
$nocms_contact_id
$old_api_keys
protected
mixed
$old_api_keys
$session_id
protected
mixed
$session_id
$url
protected
mixed
$url
Methods
apiTestCases()
Build a list of test cases. Each test case defines a set of REST query parameters and an expected outcome for the REST request (eg is_error=>1 or is_error=>0).
public
apiTestCases() : mixed
Tags
setUpBeforeClass()
public
static setUpBeforeClass() : void
testAPICalls()
public
testAPICalls(mixed $query, mixed $is_error) : mixed
Parameters
- $query : mixed
- $is_error : mixed
Tags
testGetCorrectUserBack()
Submit a request with an API key that exists but does not correspond to.
public
testGetCorrectUserBack() : void
a real user. Submit in "?entity=X&action=X" notation
testNotCMSUser_entityAction()
Submit a request with an API key that exists but does not correspond to.
public
testNotCMSUser_entityAction() : void
a real user. Submit in "?entity=X&action=X" notation
testNotCMSUser_q()
Submit a request with an API key that exists but does not correspond to a real user. Submit in "?q=civicrm/$entity/$action" notation
public
testNotCMSUser_q() : void
assertAPIErrorCode()
protected
assertAPIErrorCode(mixed $apiResult, mixed $cmpvar[, string $prefix = '' ]) : mixed
Parameters
- $apiResult : mixed
- $cmpvar : mixed
- $prefix : string = ''
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|stringgetApiKey()
protected
static getApiKey() : mixed
getRestUrl()
protected
getRestUrl() : mixed
isOldQSupported()
Enable testing of `civicrm/{$entity}/{$action}` from APIv3 REST?
protected
isOldQSupported() : bool
The APIv3 REST end-point supported two notations:
-
rest.php?entity=ENTITY&action=ACTION
-
rest.php?q=civicrm/ENTITY/ACTON
.
The former better documentation, tooling, and compatibility. The latter is conflicted is some cases.
Return values
boolresolveResponse()
protected
resolveResponse(ResponseInterface|null $response) : ResponseInterface
Parameters
- $response : ResponseInterface|null
Return values
ResponseInterfacesetUp()
protected
setUp() : void
tearDown()
protected
tearDown() : void
updateAdminApiKey()
protected
updateAdminApiKey() : mixed