PHPackages                             stratedge/wye - 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. stratedge/wye

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

stratedge/wye
=============

A library that makes unit testing database-driven code in PHP a breeze. Mock the native PDO class, define query results, and inspect executed statements.

v0.8.0(8y ago)15.3k[1 issues](https://github.com/stratedge/wye/issues)1MITPHPPHP &gt;=5.6

Since Jan 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/stratedge/wye)[ Packagist](https://packagist.org/packages/stratedge/wye)[ Docs](https://github.com/stratedge/wye)[ RSS](/packages/stratedge-wye/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (9)Used By (1)

Wye
===

[](#wye)

[![Build Status](https://camo.githubusercontent.com/37053f9e2f425151e9bff54550d13678d140502ec4ffe26de8cb6ecc2eaa7a88/68747470733a2f2f7472617669732d63692e6f72672f7374726174656467652f7779652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/stratedge/wye)[![Latest Stable Version](https://camo.githubusercontent.com/2a436e309e508be7c651376b50511306fd7cc483c1fce8d6eaf4e6c3e69c457e/68747470733a2f2f706f7365722e707567782e6f72672f7374726174656467652f7779652f762f737461626c65)](https://packagist.org/packages/stratedge/wye)[![Total Downloads](https://camo.githubusercontent.com/4b257519c5af2295789d6d1807ea5189921c139e4cdea1b578770ece0880decc/68747470733a2f2f706f7365722e707567782e6f72672f7374726174656467652f7779652f646f776e6c6f616473)](https://packagist.org/packages/stratedge/wye)[![License](https://camo.githubusercontent.com/f73a906a8c019d690cbdf097ab09ca909c2997cb49adf1d26110a4a1d2e2e156/68747470733a2f2f706f7365722e707567782e6f72672f7374726174656467652f7779652f6c6963656e7365)](https://packagist.org/packages/stratedge/wye)

A library that makes unit testing database-driven code in PHP a breeze. Mock the native PDO class, define query results, and inspect executed statements.

"\[In firefighting a\] hose appliance used for splitting one line into two discharges. Often a gated wye is used to allow and disallow water flow through the two separate discharges." - [https://en.wikipedia.org/wiki/Glossary\_of\_firefighting\_equipment#Wye](https://en.wikipedia.org/wiki/Glossary_of_firefighting_equipment#Wye)

Installation
============

[](#installation)

Wye is registered with [Packagist](https://packagist.org) and can be installed with [Composer](https://getcomposer.org). Run the following on the command line:

```
composer require --dev stratedge/wye
```

Once Wye has been included in your project, just make sure to require Composer's autoloader:

```
require_once 'vendor/autoload.php';
```

Basic Usage Example
===================

[](#basic-usage-example)

```
use Stratedge\Wye\Wye;

//In test setup
//-------------

//Reset the Wye to its clean state
Wye::reset()

//Create a Wye PDO object
$pdo = Wye::makePDO();

//Inject PDO into database layer
Database::setConnection($pdo);

//In test
//-------

//Create a Result object
$result = Wye::makeResult();

//Add a row or two to return
$result->addRow(['type' => 'Pumper', 'apparatus' => 'Engine 1']);

//Attach Result to Wye to be served when a query is executed
$result->attach();

//Run code to test
$class_to_test->doSomething();

//Inspect execution
$stmt = Wye::getStatementAtIndex(0);
$this->assertStringStartsWith('SELECT', $stmt->getStatement());
$this->assertCount(2, count($stmt->getBindings());
$this->assertSame('id', $stmt->getBindings()->first()->getParameter());
$this->assertSame(1, Wye::getNumQueries());
//and more!
```

> **WAIT, THERE'S MORE**
> For a much more in-depth look at Wye's usage, check out the extensive documentation, especially the section on [Basic Usage](https://github.com/stratedge/wye/wiki/Introduction#basic-usage).

Documentation
=============

[](#documentation)

Complete and up-to-date documentation is available on [the Wiki](https://github.com/stratedge/wye/wiki).

Some of the major topics discussed include: [An Introduction](https://github.com/stratedge/wye/wiki/Introduction), [Defining Results](https://github.com/stratedge/wye/wiki/Defining-Results), [Inspecting Execution Info](https://github.com/stratedge/wye/wiki/Inspecting-Execution-Info), and [Inspecting Bindings](https://github.com/stratedge/wye/wiki/Inspecting-Bindings).

Todo &amp; Roadmap
------------------

[](#todo--roadmap)

List of enhancements and implementations is available on the [Todo &amp; Roadmap](https://github.com/stratedge/wye/wiki/Todo-&-Roadmap) page of the wiki.

Issue Tracking
--------------

[](#issue-tracking)

If you should find an issue in Wye, and you think you can fix it, by all means please do so. Pull requests are gladly accepted. If you don't have the time or energy to fix it, please log the issue with as much detail as possible so I can take a look.

Issues can be logged on the [Github issue tracker](https://github.com/stratedge/wye/issues).

Acknowledgements
----------------

[](#acknowledgements)

Wye is built on top of an idea I first saw implemented by my friend/colleague [Josh](https://github.com/phpcodecrafting).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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 ~56 days

Recently: every ~47 days

Total

8

Last Release

3026d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.5

v0.2.0PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/758c980f6c71a7cbb5c4d602be8a2c44d25b0ffd10206c8bae909c3abe58bd9f?d=identicon)[stratedge](/maintainers/stratedge)

---

Top Contributors

[![stratedge](https://avatars.githubusercontent.com/u/1619065?v=4)](https://github.com/stratedge "stratedge (163 commits)")

---

Tags

mockingmysqlpdopdo-replacementphpphpunitunit-testunit-testingunit-teststestingphpunitunitmockingtestunit testingdatabasemockmysqlpdounit testunittestreplacement

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stratedge-wye/health.svg)

```
[![Health](https://phpackages.com/badges/stratedge-wye/health.svg)](https://phpackages.com/packages/stratedge-wye)
```

###  Alternatives

[elliotchance/concise

Concise is test framework for using plain English and minimal code, built on PHPUnit.

45223.8k4](/packages/elliotchance-concise)[colinodell/psr-testlogger

PSR-3 compliant test logger based on psr/log v1's, but compatible with v2 and v3 too!

1712.1M47](/packages/colinodell-psr-testlogger)[icecave/isolator

Dependency injection for global functions.

371.3M29](/packages/icecave-isolator)[sofa/eloquent-testsuite

Helpers for fast and reliable UNIT tests for your Eloquent Models with PHPUnit

10104.7k](/packages/sofa-eloquent-testsuite)[quizlet/hammock

Hammock is a stand-alone mocking library for Hacklang.

27445.5k](/packages/quizlet-hammock)[janmarek/mockista

Mockista is library for mocking, which I've written, because I find mocking in PHPUnit awful.

29221.0k28](/packages/janmarek-mockista)

PHPackages © 2026

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