Argh!? BDD! ARGH!! Mocks?!
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!
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/');
Run the test and get some JSON results: JSONView for Chrome JSONView for Firefox
Or use bArr - a sophisticated BDD result viewer tool.