Created
November 9, 2012 12:03
-
-
Save davedevelopment/4045374 to your computer and use it in GitHub Desktop.
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 | |
| require "vendor/autoload.php"; | |
| class MyClass | |
| { | |
| public function __construct($a = 1) | |
| { | |
| echo "__construct called \$a = $a\n"; | |
| } | |
| } | |
| $a = new MyClass(); // __construct called $a = 1 | |
| // Mockery factory will not call construct by default | |
| $b = Mockery::mock("MyClass"); // ... | |
| /** | |
| * Contrary to my initial thoughts, the mock class also overrides the | |
| * constructor, so subsequent calls also don't use the original constructor | |
| */ | |
| $class = get_class($b); | |
| $c = new $class; // ... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment