Two ways tests affected one another

Two test files defined the same global application function stubs. The first set loaded took effect for the whole PHP process, so one file could change the behaviour another file saw. Passing locally gave little assurance that a different discovery order would behave the same way.

The database failure crossed a different boundary. The suite relied on rolling back transactions to remove test data. Schema setup during test initialisation ran ordinary CREATE TABLE statements, which cause implicit commits in MySQL and MariaDB. The rollback could no longer undo writes that had already been committed. Persistent rows accumulated and slowed the suite until the CI job could time out.

Conceptual diagram

Two independent failures in test isolation

PHP load order controlled stub behaviour. In the database, schema creation could commit writes before rollback, leaving persistent rows.

Restore isolation and verify incomplete responses

I consolidated the duplicate stubs into a shared definition and corrected the database initialisation that was interfering with rollback. Both infrastructure fixes were confined to the test suite.

I added coverage for a dependency returning HTTP 2xx with required response data missing. The test verified that the application handled the incomplete result as an error. A successful status code establishes transport-level success. The application still needs to verify the response before acting on it.

The two fixes addressed different forms of shared state. Controlling the PHP definitions removed competing stubs. Preserving the transaction boundary let the suite clean up its data.