A simple yet powerful BDD library for PHP 5
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bdd
test_demo
LICENSE
README.wiki
mock_sample.php
myapp.php
testsuite.php

README.wiki

Argh!? BDD! ARGH!! Mocks?!

Table of Contents

No. It's ArrBDD

A simple BDD library for PHP 5

Use array & closures. Make it simple.

Arr! - This one is often confused with Arrrgh, which is of course the sound you make when you sit on a belaying pin. "Arrr!" can mean, variously, "yes," "I agree," "I'm happy," "I'm enjoying this beer," "My team is going to win it all,"... It's the Pirate lingo, rich and complicated, sort of like a good stew.

How'd this fit into da PHP world? Well, of coz' it does! C'mon, lad, it's Pirates Helping Pirates! Aye aye!


Argh!? But just how?

Arr! BDD? Specs?:

    /**
     * Simplest form. Check out the test examples for more
     */
    $specs["The 'Hello world' string"] = array(
        'subject' => function(){
            return 'Hello world';
        },
        "SHOULD be 11 characters long" => function($hello){
            return (strlen($hello)===11);
        },
        "AND start with 'Hello'" => function($hello){
            return (strpos($hello, 'Hello')===0);
        }
    );

Arr! Mock:

    // Follow this order method -> arguments -> returns
    $mydbMock->method('getHost')
             ->args('slaves')
             ->returns(array('192.168.1.2', '192.168.1.5'));

    // Method without arguments    
    $mydbMock->method('getHost')
             ->returns('127.0.0.1');

    // Mock static methods
    $mydbMock->staticMethod('getPath')
             ->returns('/var/db/');

YEah! Getting results


Run the test and get some JSON results: JSONView for Chrome JSONView for Firefox

BDD results

Or use bArr - a sophisticated BDD result viewer tool.

bArr, BDD result viewer