Skip to content

Testing workflows

Workflow tests live at systems/<system>/tests/workflows/**/*.test.workflow.json. Each JSON object describes one scenario, with fixtures, a trigger and assertions. Run them with:

Terminal window
php artisan brezel:system test-run example --case=note_status
{"identifier":"note_status","workflow":"NoteWorkflow","now":"2026-01-15T08:00:00Z","fixtures":[{"type":"entity","module":"notes","alias":"note","fields":{"name":"Example","status":"open"}}],"trigger":{"type":"dispatch_sync","entry":"start","data":{"default":"fixture:note"}},"assertions":[{"type":"field_equals","module":"notes","selector":{"id":"fixture:note.id"},"field":"status","value":"open"}]}

This assumes NoteWorkflow, its start entry and the notes schema already exist. field_equals uses selector, not where. An empty selector takes the first entity and may pass for the wrong record.

Keys: identifier, workflow, description, priority, scope, fixtures, actor, now, trigger, assertions, steps, effects, http_fakes, expect_error. workflow is needed for graph dispatch; resource lifecycle triggers can run without it. scope can restrict key, apply_only and workflow_identifiers. Incomplete generated scaffolds are not effective regression coverage.

entity fixtures have module, alias and fields. user fixtures require email and support alias, name, password (random by default), fields, module (users), client, root (false), and roles (existing slugs).

fixture:note resolves to an entity; fixture:note.id resolves a property. Embedded ${fixture:note.id} references work for scalar values. Unknown aliases fail. actor accepts a user alias or email. Without actor the bootstrap user is root, so access errors can be hidden.

now sets Carbon’s test clock to an ISO timestamp. expect_error can be true or an object with message_contains to expect a trigger exception.

See trigger and step reference for all five triggers and respond checkpoints, effects for mail and HTTP handling, and all 40 assertions for outcome checks.

Trigger assertions run immediately, before steps. Case assertions run at the scenario’s final boundary. Assertion processing stops on the first failure in a list; steps stop on a failed step.

php artisan brezel:system test-run <system> supports —case, —run-id, —keep-environment, —reuse-environment, —cold, —rebuild-baseline, —systems-path, —json and —json-output. Test-info, test-reset and test-shell help inspect a retained test environment; reset/shell require —run-id. See CLI.

In the audited feat/ai code, a suite with zero cases can report passed; verify cases_count. Human-readable test-run returns 0 for success and 1 for failed tests, but —json returns 0 after reporting even if passed is false. Inspect passed and suite counts in automation. These limitations are fixed on a separate branch and are not assumed here.

create_resource/update_resource test triggers do not calculate field recipes. They process and persist supplied data directly; they do not reproduce a full normal REST/UI mutation. Webhook triggers dispatch a synthetic request and do not test HTTP route authorization. Use explicit actors and access assertions where needed.

Source: app/System/Testing/BusinessWorkflowTestRunner.php, suite runner and Console/Commands/CLI/SystemCommand.php.