PHPackages                             maatify/data-fakes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. maatify/data-fakes

ActiveLibrary[Testing &amp; Quality](/categories/testing)

maatify/data-fakes
==================

Complete fake simulation layer for MySQL, DBAL, Redis, and Mongo adapters.

v1.0.4(5mo ago)04891MITPHPPHP &gt;=8.4CI passing

Since Nov 22Pushed 5mo agoCompare

[ Source](https://github.com/Maatify/data-fakes)[ Packagist](https://packagist.org/packages/maatify/data-fakes)[ RSS](/packages/maatify-data-fakes/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (1)

[![Maatify.dev](https://camo.githubusercontent.com/bb8bf9ee079d7f823c9d5e94061d1d4c11dc0898e2b1b5cc9a8a7b04d8bfdd7d/68747470733a2f2f7777772e6d6161746966792e6465762f6173736574732f696d672f696d672f6d6161746966795f6c6f676f5f77686974652e737667)](https://camo.githubusercontent.com/bb8bf9ee079d7f823c9d5e94061d1d4c11dc0898e2b1b5cc9a8a7b04d8bfdd7d/68747470733a2f2f7777772e6d6161746966792e6465762f6173736574732f696d672f696d672f6d6161746966795f6c6f676f5f77686974652e737667)

---

[![Version](https://camo.githubusercontent.com/7656a35f209937275f85a2adca0d58d1873d286478b2407a011d1b3b8198c72e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6161746966792f646174612d66616b65733f6c6162656c3d56657273696f6e26636f6c6f723d344331)](https://packagist.org/packages/maatify/data-fakes)[![PHP](https://camo.githubusercontent.com/a78d925a05a029fba776b0a8697d8eaf27510476d1a345cc998ffdd297bea775/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6161746966792f646174612d66616b65733f6c6162656c3d50485026636f6c6f723d373737424233)](https://packagist.org/packages/maatify/data-fakes)[![Build](https://github.com/Maatify/data-fakes/actions/workflows/test.yml/badge.svg?label=Build&color=brightgreen)](https://github.com/Maatify/data-fakes/actions/workflows/test.yml)

[![Monthly Downloads](https://camo.githubusercontent.com/66931c4bc29400bdc72d4e1b0969a378dca873566ba31db4abf7198b28d0d165/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d6161746966792f646174612d66616b65733f6c6162656c3d4d6f6e74686c79253230446f776e6c6f61647326636f6c6f723d303041384538)](https://packagist.org/packages/maatify/data-fakes)[![Total Downloads](https://camo.githubusercontent.com/c768512b66e6a7fe7de1a3eee93e1b3954f383ae2d5c7de02b4c354cbfaba7fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6161746966792f646174612d66616b65733f6c6162656c3d546f74616c253230446f776e6c6f61647326636f6c6f723d324141394530)](https://packagist.org/packages/maatify/data-fakes)

[![Stars](https://camo.githubusercontent.com/6b7d980d613c9ab62785805bfd4ddc269c0a576c7ceae9f5da8860901eb212df/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f4d6161746966792f646174612d66616b65733f6c6162656c3d537461727326636f6c6f723d4646443433422663616368655365636f6e64733d33363030)](https://github.com/Maatify/data-fakes/stargazers)[![License](https://camo.githubusercontent.com/9428d95040247010fee626c80a749429ac31526e5446f4e68013a803e3e3bf0b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d6161746966792f646174612d66616b65733f6c6162656c3d4c6963656e736526636f6c6f723d626c756576696f6c6574)](LICENSE)![Status](https://camo.githubusercontent.com/2128a821a9f55f8f5e5806efa8de7dfe863140215ec85b68a1d4301610cfdd32/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5374617475732d537461626c652d737563636573733f7374796c653d666c61742d737175617265)[![Code Quality](https://camo.githubusercontent.com/3c80fdb1f3425d66c0048ac063b4a55f4d8e0c33d2393622daa4860d652189f6/68747470733a2f2f696d672e736869656c64732e696f2f636f6465666163746f722f67726164652f6769746875622f4d6161746966792f646174612d66616b65732f6d61696e3f636f6c6f723d627269676874677265656e)](https://www.codefactor.io/repository/github/Maatify/data-fakes)

[![PHPStan](https://camo.githubusercontent.com/a025ae552c8ece8e7631d1734e0d3fa87d4a1b1c1d21ba3f4de5c13b7468caaa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230362d344538434145)](https://phpstan.org/)[![Coverage](https://camo.githubusercontent.com/4e61229ac492e8a8a3483ced886893532a5b068f708a22ab0c16563dea0fdc06/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f7665726167652d39322532352d394332374230)](#)

[![Changelog](https://camo.githubusercontent.com/32f7664d004132f7e0fb111b5e01bd7270705d1e7247db502287d51910c04cb9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4368616e67656c6f672d566965772d626c7565)](CHANGELOG.md)[![Security](https://camo.githubusercontent.com/a150750c8b2c6ca6209aa80bdf220d2f0950b984df64c1b859a46ee9152570f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53656375726974792d506f6c6963792d696d706f7274616e74)](SECURITY.md)

---

📘 Maatify Data Fakes
====================

[](#-maatify-data-fakes)

**In-Memory Fake Adapters for MySQL, Redis, MongoDB &amp; Repository Layer****Version:** 1.0.4 **Project:** `maatify/data-fakes`**Maintained by:** Maatify.dev

---

🚀 Overview
----------

[](#-overview)

`maatify/data-fakes` is a deterministic, lightweight **in-memory data simulation engine** fully compatible with all official Maatify Data Adapters.

It allows any repository or service to run and be tested **without any real databases**, providing:

- Fake MySQL Adapter
- Fake MySQL DBAL Adapter
- Fake Redis Adapter
- Fake MongoDB Adapter
- Fake Repository Layer
- **Unit of Work + Snapshot Engine (Phase 6)**
- **Fixtures Loader + FakeEnvironment (Phase 7)**
- **Advanced Simulation Layer: Latency + Failure Injection (Phase 8)**
- Fully deterministic test isolation
- Zero external services required — perfect for CI

All Fake Adapters follow the **exact same contracts** used by real adapters across the Maatify ecosystem.

---

🔑 Core Dependencies
-------------------

[](#-core-dependencies)

The core of the library is built on:

1. **AdapterInterface**`Maatify\Common\Contracts\Adapter\AdapterInterface`
2. **ResolverInterface**`Maatify\DataAdapters\Contracts\ResolverInterface`

Every Fake Adapter implements `AdapterInterface` and is routed through `ResolverInterface` to ensure **1:1 behavior** with real adapters.

---

🧩 Features
----------

[](#-features)

### 🗄️ Storage Features

[](#️-storage-features)

- Fully in-memory storage layer
- Auto-increment &amp; mixed ID handling
- Snapshot export/import (Phase 6)
- Deterministic state across tests

### 🔍 Query Features

[](#-query-features)

- SQL-like filtering (where/in/like/order/limit)
- Mongo-like operators (`$in`, `$gt`, `$lte`, `$ne`, …)
- Redis-like operations (list, hash, strings, counters, TTL)

### 🧱 Repository Layer

[](#-repository-layer)

- FakeRepository
- FakeCollection
- ArrayHydrator

### 🔄 Unit of Work (Phase 6)

[](#-unit-of-work-phase-6)

- Nested transactions
- Snapshot-based rollback
- Transactional wrapper
- Fully deterministic

### 📦 Fixtures &amp; Environment (Phase 7)

[](#-fixtures--environment-phase-7)

- JSON / array fixtures loader
- SQL + Mongo + Redis hydration
- FakeEnvironment with auto-reset

### ⚡ Advanced Simulation Layer (Phase 8)

[](#-advanced-simulation-layer-phase-8)

Adds deterministic CI-safe fault injection:

#### 🔹 ErrorSimulator

[](#-errorsimulator)

- Failure scenarios per operation
- Probability-based injection
- Deterministic exception throwing

#### 🔹 LatencySimulator

[](#-latencysimulator)

- Per-operation latency
- Default latency
- Optional jitter
- Perfect for CI reproducibility

#### 🔹 SimulationAwareTrait

[](#-simulationawaretrait)

Hooks used inside adapters:

- `guardOperation()`
- Latency simulation
- Failure simulation

---

📦 Installation
--------------

[](#-installation)

```
composer require maatify/data-fakes --dev
```

✔ Recommended for testing ✘ Not for production

---

🧪 Basic Usage
-------------

[](#-basic-usage)

### Using the Fake MySQL adapter

[](#using-the-fake-mysql-adapter)

```
use Maatify\DataFakes\Adapters\MySQL\FakeMySQLAdapter;
use Maatify\DataFakes\Storage\FakeStorageLayer;

$storage = new FakeStorageLayer();
$mysql   = new FakeMySQLAdapter($storage);

$mysql->connect();
$mysql->insert('users', ['name' => 'Ada Lovelace']);

$rows = $mysql->select('users', ['name' => 'Ada Lovelace']);
```

### Reset Between Tests

[](#reset-between-tests)

```
$storage->reset();
```

---

📘 Usage Examples
----------------

[](#-usage-examples)

All examples are available in: → [docs/examples.md](docs/examples.md)

---

📁 Fake Components Included
--------------------------

[](#-fake-components-included)

### 🗄️ Fake Adapters

[](#️-fake-adapters)

- FakeMySQLAdapter
- FakeMySQLDbalAdapter
- FakeRedisAdapter
- FakeMongoAdapter

### 🧩 Repository Layer (Phase 5)

[](#-repository-layer-phase-5)

- FakeRepository
- FakeCollection
- ArrayHydrator

### 🔀 Routing

[](#-routing)

- FakeResolver

### 🔄 Unit of Work &amp; Snapshots (Phase 6)

[](#-unit-of-work--snapshots-phase-6)

- FakeUnitOfWork
- SnapshotManager
- SnapshotState

### 📦 Fixtures &amp; Environment (Phase 7)

[](#-fixtures--environment-phase-7-1)

- FakeFixturesLoader
- JsonFixtureParser
- FakeEnvironment
- ResetState

### ⚡ Simulation Layer (Phase 8)

[](#-simulation-layer-phase-8)

- ErrorSimulator
- LatencySimulator
- FailureScenario
- SimulationAwareTrait

---

📚 Development Phases &amp; Documentation Links
----------------------------------------------

[](#-development-phases--documentation-links)

- **Phase 1 — Project Bootstrap &amp; Core Architecture**[`docs/phases/README.phase1.md`](docs/phases/README.phase1.md)
- **Phase 2 — Fake MySQL &amp; DBAL Adapter**[`docs/phases/README.phase2.md`](docs/phases/README.phase2.md)
- **Phase 3 — Fake Redis Adapter**[`docs/phases/README.phase3.md`](docs/phases/README.phase3.md)
- **Phase 4 — Fake Mongo Adapter**[`docs/phases/README.phase4.md`](docs/phases/README.phase4.md)
- **Phase 5 — Repository Layer**[`docs/phases/README.phase5.md`](docs/phases/README.phase5.md)
- **Phase 6 — Snapshot Engine + Unit of Work**[`docs/phases/README.phase6.md`](docs/phases/README.phase6.md)
- **Phase 7 — Fixtures Loader + FakeEnvironment**[`docs/phases/README.phase7.md`](docs/phases/README.phase7.md)
- **Phase 8 — Advanced Simulation Layer (Latency + Failure Injection)**[`docs/phases/README.phase8.md`](docs/phases/README.phase8.md)

---

📝 Full Documentation
--------------------

[](#-full-documentation)

👉 **[`README.full.md`](docs/README.full.md)**Includes:

- Architecture
- Class reference
- API maps
- Fixtures &amp; environments
- Snapshot behaviors
- Phase 1 → Phase 8 technical breakdown

---

🪪 License
---------

[](#-license)

**[MIT license](LICENSE)** © [Maatify.dev](https://www.maatify.dev)
Free to use, modify, and distribute with attribution.

---

👤 Author
--------

[](#-author)

**© 2025 Maatify.dev**
Engineered by **Mohamed Abdulalim ([@megyptm](https://github.com/megyptm))**

📘 Full documentation &amp; source code:

---

🤝 Contributors
--------------

[](#-contributors)

Special thanks to the Maatify.dev engineering team and open-source contributors.

---

 Built with ❤️ by [Maatify.dev](https://www.maatify.dev) — Unified Ecosystem for Modern PHP Libraries

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance75

Regular maintenance activity

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

167d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a885a0810f2762586520ab284c9019aaf0b650b53cdf2a6c13ea10931bb7795?d=identicon)[Maatify](/maintainers/Maatify)

---

Top Contributors

[![megyptm](https://avatars.githubusercontent.com/u/33574895?v=4)](https://github.com/megyptm "megyptm (15 commits)")

---

Tags

data-adaptersdata-storagedbal-phpfake-adapterfake-databasein-memory-adaptermaatifymaatify-devmock-databasemongodbmysqlphpphp-libraryphp8phpstanphpunitredistestingphptestingphpunitPHPStandatabasemockmysqldbalredisadapterstoragemongodbfakeunit testmongointegration-testIn Memorymaatifysimulationmaatify-devdata-adaptersfake-databasemock-database

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/maatify-data-fakes/health.svg)

```
[![Health](https://phpackages.com/badges/maatify-data-fakes/health.svg)](https://phpackages.com/packages/maatify-data-fakes)
```

###  Alternatives

[blastcloud/guzzler

Supercharge your app or SDK with a testing library specifically for Guzzle.

272419.3k35](/packages/blastcloud-guzzler)[chriskite/phactory

A Database Factory for PHP Unit Tests

140216.9k8](/packages/chriskite-phactory)[donatj/mock-webserver

Simple mock web server for unit testing

1382.5M79](/packages/donatj-mock-webserver)[lastzero/test-tools

Increases testing productivity by adding a service container and self-initializing fakes to PHPUnit

2244.3k13](/packages/lastzero-test-tools)[doppiogancio/mocked-client

A simple way to mock a client

2174.9k3](/packages/doppiogancio-mocked-client)[phpcurl/curlwrapper

The simplest OOP wrapper for curl, curl\_multi, curl\_share functions. Use CURL as a dependency, not hard-coded!

11110.4k3](/packages/phpcurl-curlwrapper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
