lvcodesmith/php-expect

This package is abandoned and no longer maintained. No replacement package was suggested.

dev-master 2015-10-29 19:18 UTC

This package is not auto-updated.

Last update: 2022-04-02 01:22:49 UTC


README

Build Status

I'm on Packigist!

{
...
    "require": {
    ...
        "lvcodesmith/php-expect": "dev-master"
    ...
    }
...
}

Matching that doesn't suck ... mostly

It is very easy to create a matcher using php-expect. Just put it in the Expect::$matchers static array. Here's how.

Matcher skeleton

Expect::$matchers['matcher'] = function($actual, $expected) {
    return array(
        $positive_matcher = function() use ($actual, $expected) {

        }, "What to say when the positive matcher fails",

        $negative_matcher = function() use ($actual, $expected) {

        }, "What to say when the negative matcher fails"
    );
}

Of course, you don't need to write $positive_matcher = or $negative_matcher =, but it helps add context.

The toSuck matcher:

Expect::$matchers['toSuck'] = function ($actual, $expected) {
    $class = get_class($actual);
    return array(
        $positive_matcher = function () use ($class) {
            assert( $class == 'Suck' );
        }, "Expected object to suck",

        $negative_matcher = function () use ($class) {
            assert( $class != 'Suck' );
        }, "Expected object not to suck"
    );
};

Social Updates

This project will be using Trello.com to manage the project. If you want access, please send a message to @LVCSkunkworks. Follow @LVCSkunkworks to see real time activity.