Repository navigation
Phase 6 — Unit of Work & Snapshot Engine
🚀 Release Notes — v1.0.2
Phase 6 — Unit of Work & Snapshot Engine
This release introduces a complete transactional layer on top of the in-memory storage system, enabling atomic operations, nested transactions, and deterministic rollback across all Fake Adapters (MySQL, Redis, MongoDB, DBAL).
Phase 6 significantly enhances reliability for complex repository testing and multi-step operations.
🔥 What's New
🧱 Unit of Work (UoW)
A new FakeUnitOfWork class provides transaction-like behavior:
begin()— start a new snapshot transactioncommit()— accept the changesrollback()— revert to the previous snapshot- Nested transactions supported (stack-based snapshots)
transactional(callable)helper with automatic commit/rollback- Works with ALL fake adapters (MySQL, Redis, Mongo, DBAL)
📸 Snapshot Engine
Two new classes enable deterministic state saving & restoring:
SnapshotManagerSnapshotState
These provide:
- Deep cloning of all tables & documents
- Auto-increment counter preservation
- Full export/import of FakeStorageLayer state
- Immutable state objects for safe storage and reuse
🗄 Storage Layer Enhancements
FakeStorageLayer now supports:
exportState()importState()
Allowing engine-wide rollback & restore across multiple adapters.
🧪 Tests Added
New PHPUnit suites:
FakeUnitOfWorkTestSnapshotManagerTest
Validating:
- Commit propagation
- Rollback correctness
- Nested snapshot behavior
- Exception-safe rollback in
transactional()
All tests pass under PHPUnit 11 and PHPStan Level Max.
📘 Documentation
Updated:
README.phase6.mdREADME.full.mdphase-output.json
All new architecture components are now documented in the main library spec.
🔧 Changes Summary
- Added
FakeUnitOfWork - Added
SnapshotManager - Added
SnapshotState - Updated
FakeStorageLayer - Added tests for all new features
- Updated documentation and metadata files
🏷 Version
v1.0.2
Backward compatible — no breaking changes.