Created
March 27, 2012 17:22
-
-
Save alganet/2218151 to your computer and use it in GitHub Desktop.
Next-gen mocks and stubs for PHP 5.4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use FooBar\Test\Mock; | |
// In the sample below, $mock expects the method "sayHelloTo" to be called one time | |
// with the parameter $name equals "Alexandre" and return "Hello Alexandre" | |
$mock = (new Mock('NamespaceVendor\\ClassName'))([ | |
'sayHelloTo' => function($name="Alexandre") { | |
return "Hello Alexandre"; | |
} | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use FooBar\Test\Stub; | |
// In the sample below, $stub acts as a stub. Pretty much self-explained. | |
$stub = (new Stub('NamespaceVendor\\ClassName'))([ | |
'sayHelloTo' => function($name) { | |
echo "Hello $name"; | |
} | |
]); | |
$stub->sayHelloTo("Alexandre"); //Hello Alexandre |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use FooBar\Test\Stub; | |
// In the sample below, $stub acts as a stub. Pretty much self-explained. | |
$stub = Stub::for('NamespaceVendor\\ClassName') | |
->sayHelloTo(function($name) { | |
echo "Hello $name"; | |
}); | |
$stub->sayHelloTo("Alexandre"); //Hello Alexandre |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment