Documentation

ErrorTest extends CiviEndToEndTestCase
in package
uses HttpTestTrait

Class ErrorTest

Tags
group

e2e

Check that errors are reported in a sensible way. In this context, we speak of a few common error types, eg

  • fatal -- ie `CRM_Core_Error::fatal("Some message")'
  • exception -- ie `throw new \Exception("Some message")'
  • permission -- ie CRM_Utils_System::permissionDenied()

Table of Contents

Properties

$httpHistory  : array<string|int, mixed>
List of HTTP requests that have been made by this test.
$nonCompliant  : array<string|int, string>
FIXME: These represent pre-existing bugs.

Methods

getErrorTypes()  : mixed
setUpBeforeClass()  : void
testErrorChrome()  : mixed
testErrorMessage()  : mixed
When showing an error screen, does the basic message come through?
testErrorStatus()  : mixed
When showing an error screen, does the HTTP status indicate an error?
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.
provokeError()  : ResponseInterface
resolveResponse()  : ResponseInterface
skipIfNonCompliant()  : mixed

Properties

$httpHistory

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

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

$nonCompliant

FIXME: These represent pre-existing bugs.

protected array<string|int, string> $nonCompliant = [ // Format: "{$uf}_{$testFunc}_{$errorType}" '/WordPress_testErrorStatus_(fatal|exception)/', '/Drupal_testErrorChrome_(fatal|exception)/', '/Drupal8_testErrorChrome_(fatal|exception)/', '/Backdrop_testErrorChrome_(fatal|exception)/', ]

By default, these test scenarios do not run in CI. However, you can run them manually by setting env-var FORCE_ALL=1.

Methods

getErrorTypes()

public getErrorTypes() : mixed

testErrorChrome()

public testErrorChrome(string $url, string $errorType) : mixed
Parameters
$url : string

Ex: 'frontend://civicrm/dev/fake-error'

$errorType : string

Ex: 'fatal' or 'exception'

Tags
dataProvider

getErrorTypes

testErrorMessage()

When showing an error screen, does the basic message come through?

public testErrorMessage(string $url, string $errorType) : mixed
Parameters
$url : string

Ex: 'frontend://civicrm/dev/fake-error'

$errorType : string

Ex: 'fatal' or 'exception'

Tags
dataProvider

getErrorTypes

testErrorStatus()

When showing an error screen, does the HTTP status indicate an error?

public testErrorStatus(string $url, string $errorType) : mixed
Parameters
$url : string

Ex: 'frontend://civicrm/dev/fake-error'

$errorType : string

Ex: 'fatal' or 'exception'

Tags
dataProvider

getErrorTypes

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

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

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

provokeError()

protected provokeError(string $url, string $errorType) : ResponseInterface
Parameters
$url : string
$errorType : string
Return values
ResponseInterface

resolveResponse()

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

skipIfNonCompliant()

protected skipIfNonCompliant(mixed $func, mixed $errorType) : mixed
Parameters
$func : mixed
$errorType : mixed

        
On this page

Search results