Created
July 12, 2014 22:27
-
-
Save tiraeth/a0b9330b5fda7a53d48a to your computer and use it in GitHub Desktop.
padraic/mockery: fix __construct and __destruct behaviour
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
diff --git a/library/Mockery/Container.php b/library/Mockery/Container.php | |
index 0d7bdf2..f412c5b 100644 | |
--- a/library/Mockery/Container.php | |
+++ b/library/Mockery/Container.php | |
@@ -193,7 +193,7 @@ class Container | |
$builder->addBlackListedMethods($blocks); | |
if (!is_null($constructorArgs)) { | |
- $builder->addBlackListedMethod("__construct"); // we need to pass through | |
+ $builder->addBlackListedMethods(array("__construct", "__destruct")); // we need to pass through | |
} | |
if (!empty($partialMethods) && $constructorArgs === null) { | |
diff --git a/library/Mockery/Generator/MockConfigurationBuilder.php b/library/Mockery/Generator/MockConfigurationBuilder.php | |
index 6e5f683..51fb546 100644 | |
--- a/library/Mockery/Generator/MockConfigurationBuilder.php | |
+++ b/library/Mockery/Generator/MockConfigurationBuilder.php | |
@@ -14,7 +14,6 @@ class MockConfigurationBuilder | |
'__get', | |
'__toString', | |
'__isset', | |
- '__destruct', | |
// below are reserved words in PHP | |
"__halt_compiler", "abstract", "and", "array", "as", | |
diff --git a/library/Mockery/Generator/StringManipulation/Pass/MethodDefinitionPass.php b/library/Mockery/Generator/StringManipulation/Pass/MethodDefinitionPass.php | |
index b2eda28..aea7fd2 100644 | |
--- a/library/Mockery/Generator/StringManipulation/Pass/MethodDefinitionPass.php | |
+++ b/library/Mockery/Generator/StringManipulation/Pass/MethodDefinitionPass.php | |
@@ -73,6 +73,13 @@ class MethodDefinitionPass implements Pass | |
private function renderMethodBody($method, $config) | |
{ | |
+ if ($method->isConstructor() || $method->isDestructor()) { | |
+ return <<<BODY | |
+{ | |
+} | |
+BODY; | |
+ } | |
+ | |
$invoke = $method->isStatic() ? 'static::__callStatic' : '$this->__call'; | |
$body = <<<BODY | |
{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment