Forty-four private reload() helpers across forty-two test classes: the same few lines asking storage for an entity again, past the static cache, written in five spellings that disagree with one another. A shared trait says it once.

Problem/Motivation

Every assertion about what the engine did has to read the entity back, because the engine wrote through its own loaded copy and the one the test is holding is still the state before the advance. That question is answered class by class: 27 copies for the process instance, 6 for the token, 4 for the work item, 4 for the workflow and 3 untyped ones that take whatever they are given.

They do not agree. Some take the entity, some take an id and some take neither; some call loadUnchanged(), some resetCache() then load(). None of them says anything about what came back, so a test whose entity has since been deleted fails on a method call on NULL rather than on the thing it was asserting, and three of them return an untyped value that tells a reader nothing.

The project has already answered a repeated test question this way twice: OpenIncidentTrait holds "did this run raise an incident", and ReloadPaymentTrait holds this very reload for a payment, with the reason written at the top of it. The runtime entities never got the same treatment, so each new test class copies whichever neighbor it was written beside, and the count grows with the suite.

Proposed resolution

Add ReloadEntityTrait beside the other shared test traits, with one method per runtime entity: reloadInstance(), reloadToken(), reloadIncident(), reloadWorkItem() and reloadWorkflow(). Each takes the entity a test already holds or the id it noted, since a test has one or the other depending on whether the thing it is asking about still existed when it last looked, and each asserts what came back, so a caller reads a typed entity rather than re-narrowing one of its own.

Whether a run is still there at all is a different question, so it is a different method: findInstance() answers NULL, which is what the retention and cascade tests assert.

Every class that carried its own copy uses the trait instead. No test changes what it asserts, and the suite passes unchanged.

User interface changes

None.

API changes

None. The change is test-only; no shipped class is touched.

Data model changes

None.

Release notes snippet

None: test infrastructure only.

AI-Generated: Yes (Claude Code was used to help draft this issue summary and to write the code on the merge request. I reviewed and ran the work myself before posting it: phpcs, phpstan level 5 and the kernel suite all pass with the change.)

Issue fork orchestra-3622894

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review
mably’s picture

Issue summary: View changes

  • mably committed 7c9f1b2a on 1.x
    task: #3622894 Read a run's entities back from storage through one...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.