yosimitso/mockdoctrinemanager
A lightweight testing helper that mocks the Doctrine manager so you can unit test persistence-dependent code without a real database. Swap in the mock to stub repository lookups, flush and transaction calls, keeping tests fast and isolated.
EntityManager in a Laravel context. It lets teams assert what a service did — what was persisted, flushed, removed, and whether a transaction was begun, committed, or rolled back — without touching a real database. That informs decisions about unit vs. integration test ratios and how much DB-backed test infrastructure you fund.EntityManager mocks/spies per project, this is a candidate to standardize and delete internal test boilerplate.hasBegunTransaction / hasComitted / hasRolledback surface supports explicit tests for rollback-on-failure behavior, which is usually under-tested and high-blast-radius.getPersistedEntity($className, $position)) imply support for asserting the sequence of write operations, not just their occurrence — useful for services with multi-step persistence.persist/flush/remove, transaction-boundary regression tests, and contract tests around persistence ordering.Adopt when:
EntityManager) inside Laravel — the API is Doctrine-shaped (persist, flush, remove, transactional), not Eloquent-shaped.Look elsewhere / proceed with caution when:
persist/flush/remove do not map onto Eloquent, and the package will not fit typical Laravel Model::save() code paths.EntityManager coverage. v1.0 covers only the listed operations — no find, merge, detach, refresh, getRepository, or query-builder interaction. If your services call those, the spy will not see them.mixed and boolean (and the hasComitted spelling) suggest a loose signature surface; verify actual signatures before relying on IDE/static-analysis ergonomics.For executives: This is a small, low-cost developer-productivity library that makes tests for database-writing code faster and more precise. It lets engineers verify in milliseconds that a service persisted the right entities, in the right order, and committed or rolled back as intended — instead of standing up a database for every test. It is a v1.0 with a deliberately narrow scope, so treat it as a low-risk pilot rather than a platform standard: trial it in one team, and keep the option to fork or fall back to in-house test doubles. It has no production runtime footprint and no customer-facing impact.
For engineering: A Doctrine EntityManager test spy for Laravel. Exposes getPersistedEntity / getRemovedEntity / getFlushedEntity (positional), plural getters, and hasBegunTransaction / hasComitted / hasRolledback, covering persist, flush, remove, beginTransaction, commit, rollback, and transactional. It fits services and repositories that talk to Doctrine where you want no-database unit tests plus explicit transaction-boundary assertions. Known gaps to plan around: v1.0 immaturity, operation coverage limited to the listed calls, loose-looking return types, a hasComitted spelling inconsistency, and no validation of real DB semantics. Recommendation: pilot in one service's suite behind our own thin test-helper wrapper so we can extend it, swap it, or replace it without touching test call sites.
How can I help you explore Laravel packages today?