Last active
December 25, 2015 14:09
-
-
Save mnapoli/6988778 to your computer and use it in GitHub Desktop.
Anonymous classes FTW
This file contains 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 | |
class MyTest extends PHPUnit_Framework_TestCase | |
{ | |
public function testSomeStuff() | |
{ | |
// Build my mock | |
$mock = new class extends CrawlerInterface { | |
public function crawl($url) { | |
return ['some', 'data']; | |
} | |
} (); | |
// Do my test | |
$myService = new MyService($mock); | |
$this->assertTrue($myService->foo()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cause mt_rand is definitly not the best: https://github.com/phpspec/prophecy/blob/master/src/Prophecy/Doubler/NameGenerator.php#L48