Skip to content

Workflow test assertions

All 40 assertion types are listed below. Each assertion requires type and the applicable keys. Selectors/where are maps of field to expected value. Fixture references are resolved where supported. Response assertions fail if no response was set.

TypesKeysMeaning
entity_exists, entity_missingmodule, whereRecord exists / is absent.
field_equals, field_not_equalsmodule, selector, field, valueselector is an equality map; do not leave it empty.
count_equalsmodule, where, valueCount matching records.
entity_matchesmodule, selector, fieldsCompare a field map.
storage_file_exists, storage_file_missingpath, disk (system)Check sandbox storage.
storage_file_contains_textpath, disk (system), textCheck file text.
storage_file_entity_existsmodule (files), selectorFind file entity and storage content.
storage_file_entity_contains_textmodule (files), selector, textCheck stored file entity text.
mail_sent, mail_not_sentto (list), subject, subject_contains, body_contains, attachment, countMatch fake mail; attachment is a filename substring.
notification_sent, notification_not_sentrecipient, channel, title, title_contains, message_contains, countChannels include notification_center, toast and sms.
http_request_sent, http_request_not_senturl, method, body_contains, json_contains, countURL wildcards and JSON subset matching; interception limits apply.
workflow_run, workflow_not_runworkflow, input_contains, countMatch action/run invocations.
can_read, cannot_read, can_create, cannot_create, can_update, cannot_update, can_delete, cannot_deleteas, module, entity or selector/whereInvoke the real policy engine as the selected actor.
visible_countas, module, where, valueCount records visible to the actor.
field_visible, field_hidden, field_editable, field_readonlyas, module, fieldCheck field permissions.
modal_showntitle, identifier (or title_contains, identifier_contains)Inspect modal response.
redirectedurl, target (or url_contains, target_contains)Inspect redirect response.
download_offeredfilename_containsCheck Content-Disposition.
response_statusvalueHTTP status.
response_header_equalsheader, valueHeader equality.
response_json_path_equalspath, valueLaravel data_get path equality.
response_json_containsvalueJSON subset.
response_content_containsvalueResponse text substring.

Outbox assertions with count require that exact number of matching items. Without count, positive assertions require at least one match and negative assertions require none. as defaults to the case actor; use a non-root user to exercise permissions.

{"type":"field_equals","module":"notes","selector":{"id":"fixture:note.id"},"field":"status","value":"open"}
{"type":"mail_sent","to":["reviewer@example.test"],"subject_contains":"Review","count":1}

Source: BusinessWorkflowTestRunner::runAssertions, access/outbox/frontend assertions and storage/entity assertion methods. Return to workflow tests.