Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Mockdoctrinemanager Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

What this is (inferred): V1.0 is the first release of a test-support package that records persistence-layer operations so tests can assert on them. The API is a read-only inspection surface over a wrapped/decorated persistence unit: persisted entities, removed entities, flushed entities, plus transaction state (beginTransaction/commit/rollback).

Architecture fit: Fits as a require-dev observability/verification layer, not a runtime dependency. It slots alongside a Doctrine-style EntityManager (or a Laravel package that wraps one, e.g. laravel-doctrine) and is consumed from PHPUnit/Pest test cases. The design is a recorder/spy, which is the right shape for this problem — it lets tests verify intent (what was queued for persistence) without forcing a database round-trip. It is a poor fit for an Eloquent-only Laravel codebase; nothing in the release notes indicates Eloquent coverage.

Integration feasibility: Low effort to install, moderate effort to wire. The real work is binding substitution: the recorder must be swapped in for the concrete persistence service in the test container, and the release notes do not confirm whether it proxies to a live EntityManager (integration-flavoured, still hits the DB) or is a pure double (unit-flavoured, no DB). That distinction changes the test strategy, the fixture requirements, and the failure modes. Until it is answered, integration planning is speculative.

Technical risk:

  • API surface is frozen with typos. hasComitted() (single t) and hasRolledback() are in the public V1.0 contract. At 1.0 these are semver-locked; fixing them later is a breaking change, so teams either live with the misspellings forever or absorb a rename. transactionnal in the notes suggests the same inattention extends beyond code.
  • Parameter naming contradicts the type. getPersistedEntity(object $className, ...) takes an instance but names it $className. Callers will pass a string, get a TypeError, and lose an afternoon. This is a documentation-grade defect on the most-used method.
  • position-based lookup is order-coupled. $position = 1 implies FIFO insertion order as the identity mechanism. Assertions become brittle the moment a fixture adds one extra persist, and there is no documented behaviour for out-of-range positions (null? exception?).
  • No assertion helpers. The package only exposes getters returning mixed/array. Every consumer writes their own assertNotNull(getPersistedEntity(...)), which duplicates logic across the suite and produces poor failure messages.
  • No visible reset/lifecycle hook. Between-test state clearing is not in the API. If absent, test pollution is a matter of when, not if.
  • Version number is unearned. A first release called V1.0 by a package that describes itself as "new" and scoped to "most current operations" signals that the version was chosen for appearance rather than API stability. Plan for churn.

Key questions:

  1. Is this a spy/double, or a decorator that forwards to a real EntityManager? Does a test still touch a database?
  2. What clears recorded state between tests — a container rebind, a Laravel refresh hook, or nothing?
  3. Supported matrix: PHP (≥8.0 implied by mixed), Laravel, Doctrine ORM versions?
  4. Is $position 1-indexed, and what is returned when it is out of range?
  5. Do nested transactions and savepoints register on hasBegunTransaction/hasRolledback?
  6. Are the typos in hasComitted/hasRolledback considered intentional and permanent, or fixable pre-adoption?
  7. Is there a release history or is V1.0 also the initial commit?

Integration Approach

Stack fit: Laravel + Doctrine ORM test suites that currently assert against a live EntityManager or mock it by hand. If the team has an existing hand-rolled spy, this package replaces it and should be evaluated as a de-duplication win. If the team is Eloquent-only, stop — no fit.

Migration path: Additive and reversible. composer require --dev with an exact pin (1.0.0, not ^1.0) so a 1.0.x patch cannot silently alter recorder semantics. No production code changes, no schema changes, no deployment risk. Removal is a one-line revert if the package disappoints.

Compatibility: Confirm the PHP and Laravel constraints match the app's lowest-supported version before piloting; mixed returns and object type hints put a hard floor at PHP 8.0. Because the package sits in require-dev only, platform mismatches cannot break production builds — but they will break CI on older matrix legs.

Sequencing:

  1. Resolve the top three questions (proxy vs. double, reset mechanism, $position semantics) before writing any tests.
  2. Pilot in one test class covering a single transactional flow: persist → flush → commit. Verify the recorder reports exactly what the live EntityManager would.
  3. Wrap it. Put a thin internal test helper (assertPersisted(Order::class), assertCommitted()) over the raw getters. This isolates the typos, fixes the $className trap, and gives readable failure messages — and it means an upstream rename costs you one file, not fifty assertions.
  4. Codify reset. Add the reset to the base test case or a trait so isolation is structural rather than remembered.
  5. Expand to remove/rollback paths, then decide on broader adoption.

Operational Impact

Maintenance: The package is dev-only, so maintenance exposure is bounded to CI. The genuine maintenance cost is the frozen typo surface: every new engineer will write hasCommitted() first and get a fatal error. The internal wrapper from step 3 is the mitigation, and it should be treated as mandatory rather than nice-to-have. Pin the version and review the changelog on every bump — a 1.x that fixes hasComitted will break every existing assertion at once.

Support: No release history, no linked repository detail, no maintainer signal in the notes. Effectively a bus-factor-one dependency. Acceptable for a dev-only helper; unacceptable if it becomes load-bearing for a large suite without a fork-and-own fallback plan.

Scaling: Test-suite scaling is where this package is most exposed. Position-indexed getters are O(n) and order-dependent, so assertions get more fragile as fixtures grow — the exact opposite of what you want in a suite that is growing. Reset-per-test must be airtight or state leaks will produce intermittent, order-dependent CI failures that are expensive to diagnose. None of this scales badly in a runtime sense; it scales badly in maintenance sense.

Failure modes:

  • Silent vacuous pass (highest severity). If the recorder is not bound and the real EntityManager is still in the container, tests will still run — they just won't be testing anything the recorder observes. Any assertion written as assertNotNull will fail loudly, but suites that assert "no exception" will pass green and prove nothing. Verify the binding explicitly in the pilot.
  • Stale state across tests producing flaky, order-dependent results.
  • Out-of-range $position returning null and being mistaken for "entity was never persisted."
  • Nested transaction blindness — rollback of an inner savepoint may not register, giving false confidence about transactional correctness.
  • Typos propagating across the suite through copy-paste.

Ramp-up: Low in absolute terms — a competent Laravel/PHP engineer is productive in under an hour given the small API. Friction is front-loaded: the typos defeat IDE autocomplete, the $className parameter invites misuse, and there are no assertion helpers, so each engineer independently invents the same null-check boilerplate. A half-page internal README plus the wrapper from step 3 reduces ramp-up to near zero and prevents the typos from spreading.

Recommendation: Adopt for a single high-value transactional test class, behind an internal wrapper, pinned to 1.0.0. Do not spread it suite-wide until the typo and reset questions are settled — either upstream fixes them before broad adoption, or the wrapper becomes the permanent interface.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource