Skip to content
A slightly less annoying way of creating test fixtures for php.
PHP
Pull request Compare This branch is 77 commits behind derptest:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src/machinist
test
.gitignore
LICENSE
README.md
deps
vendors

README.md

PHPMachinist: Testing Object Factory

What???!??!

A Slightly less annoying way of creating database fixtures for PHP testing. It borrows heavily from several projects:

They're totally awesome. Just either in the wrong language, or didn't quite do what I wanted.

Install

http://pearhub.org/projects/machinist

Examply thing

some tables:

create table `stuff` ( 
    `id` INTEGER PRIMARY KEY AUTOINCREMENT, 
    `name` varchar(100), 
    `box_id` INTEGER NULL DEFAULT NULL
);
create table `box` (
    `id` INTEGER PRIMARY KEY AUTOINCREMENT,
    `type` varchar(100)
);


use machinist\Machinist;
use machinist\driver\SqlStore;
// setup a default connection to use
Machinist::Store(SqlStore::fromPdo(new \PDO('sqlite::memory:'));
// make a blueprint for cardboardb oxes.. in the box table.. with a type..
$boxBlueprint = Machinist::Blueprint("cardboardbox", "box", array("type" => "cardboard"));

Machinist::Blueprint("crayon",
    array(
        "name" => "crayon",
        "box" => Machinist::Relationship($boxBlueprint)->local("box_id"),
    ),
    "stuff");

$crayon = Machinist::Blueprint("crayon")->make();
$redCrayon = Machinist::Blueprint("crayon")->make(array("name" => "red crayon"));

Testing

Testing of the source code can be done with the PHPUnit version 3.6 or better.

To begin testing you must first add the dependencies by executing the "vendors" file. This will place the all of the dependencies in the vendor directory.

A default phpunit.xml is configured in the test directory.

Something went wrong with that request. Please try again.