Skip to content

Instantly share code, notes, and snippets.

@mattsah
Last active December 10, 2015 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsah/4502780 to your computer and use it in GitHub Desktop.
Save mattsah/4502780 to your computer and use it in GitHub Desktop.
<?php namespace Dotink\Jest {
include 'Mime.php';
Mime::define('App\Test')->implementing('IFake')
-> extending('App\TestBase')->implementing('IFakeBase');
$test = Mime::create('App\Test')
-> onNew('factory', function($mime) {
$mime -> onCall('speak') -> give(function(){
return 'Amazing!' . PHP_EOL;
});
})
-> onCall('check') -> expect(2) -> give(TRUE)
-> onCall('add') -> expect(2, 3) -> give(5)
-> onGet('name') -> give('Matthew J. Sahagian')
-> resolve();
var_dump(class_implements($test));
var_dump($test->check(2));
var_dump(\App\Test::add(2, 3));
var_dump($test->name);
$test = new \App\Test('factory');
echo $test->speak();
}
/**
* Output:
*
* matts@berlin:~$ php test.php
* array(2) {
* ["IFakeBase"]=>
* string(9) "IFakeBase"
* ["IFake"]=>
* string(5) "IFake"
* }
* bool(true)
* int(5)
* string(19) "Matthew J. Sahagian"
* Amazing!
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment