Created
July 12, 2014 22:46
-
-
Save tiraeth/02779456bc83a976d50e 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
diff --git a/library/Mockery/Container.php b/library/Mockery/Container.php | |
index 0d7bdf2..a5db81f 100644 | |
--- a/library/Mockery/Container.php | |
+++ b/library/Mockery/Container.php | |
@@ -200,6 +200,10 @@ class Container | |
$constructorArgs = array(); | |
} | |
+ if (empty($partialMethods)) { | |
+ $builder->addBlackListedMethod("__destruct"); | |
+ } | |
+ | |
$config = $builder->getMockConfiguration(); | |
$this->checkForNamedMockClashes($config); | |
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/InstanceMockPass.php b/library/Mockery/Generator/StringManipulation/Pass/InstanceMockPass.php | |
index ec370f3..8868d6d 100644 | |
--- a/library/Mockery/Generator/StringManipulation/Pass/InstanceMockPass.php | |
+++ b/library/Mockery/Generator/StringManipulation/Pass/InstanceMockPass.php | |
@@ -32,12 +32,23 @@ class InstanceMockPass | |
} | |
MOCK; | |
+ const DESTRUCTOR_CODE = <<<MOCK | |
+ | |
+ public function __destruct() | |
+ { | |
+ } | |
+MOCK; | |
+ | |
public function apply($code, MockConfiguration $config) | |
{ | |
if ($config->isInstanceMock()) { | |
$code = $this->appendToClass($code, static::INSTANCE_MOCK_CODE); | |
} | |
+ if (in_array('__destruct', $config->getBlackListedMethods())) { | |
+ $code = $this->appendToClass($code, static::DESTRUCTOR_CODE); | |
+ } | |
+ | |
return $code; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment