2017 © Pedro Peláez
 

library 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.

image

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.

  • Sunday, February 4, 2018
  • by stratedge
  • Repository
  • 1 Watchers
  • 1 Stars
  • 328 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 13 Versions
  • 8 % Grown

The README.md

Wye

Build Status Latest Stable Version Total Downloads License, (*1)

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., (*2)

"[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, (*3)

Installation

Wye is registered with Packagist and can be installed with Composer. Run the following on the command line:, (*4)

composer require --dev stratedge/wye

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

require_once 'vendor/autoload.php';

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., (*6)

Documentation

Complete and up-to-date documentation is available on the Wiki., (*7)

Some of the major topics discussed include: An Introduction, Defining Results, Inspecting Execution Info, and Inspecting Bindings., (*8)

Todo & Roadmap

List of enhancements and implementations is available on the Todo & Roadmap page of the wiki., (*9)

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., (*10)

Issues can be logged on the Github issue tracker., (*11)

Acknowledgements

Wye is built on top of an idea I first saw implemented by my friend/colleague Josh., (*12)

The Versions

04/02 2018

dev-master

9999999-dev https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

04/02 2018

v0.8.0

0.8.0.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

04/02 2018

dev-feature/implement-pdo-statement-collection

dev-feature/implement-pdo-statement-collection https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

04/02 2018

dev-feature/deprecate-smart-getters-setters

dev-feature/deprecate-smart-getters-setters https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

04/02 2018

v0.7.0

0.7.0.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

04/02 2018

dev-feature/add-backtrace-option

dev-feature/add-backtrace-option https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

28/01 2018

v0.6.0

0.6.0.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

28/01 2018

v0.5.0

0.5.0.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

31/07 2017

v0.4.0

0.4.0.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

12/06 2017

dev-feature/pdostatements-should-be-stored-in-a-collection

dev-feature/pdostatements-should-be-stored-in-a-collection https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

23/05 2017

v0.3.0

0.3.0.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

database test mock phpunit testing pdo mysql unittest unit mocking unit-test replacement unit-testing

03/05 2017

v0.2.0

0.2.0.0

A library for mocking native PDO connections and query results

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jarret Byrne

06/01 2017

v0.1.0

0.1.0.0

A library for mocking native PDO connections and query results

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Jarret Byrne