Skip to content

Instantly share code, notes, and snippets.

@davedevelopment
Created November 9, 2012 12:03
Show Gist options
  • Select an option

  • Save davedevelopment/4045374 to your computer and use it in GitHub Desktop.

Select an option

Save davedevelopment/4045374 to your computer and use it in GitHub Desktop.
<?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