Permalink
Browse files

- Fix #140.

  • Loading branch information...
1 parent 05bbd61 commit fd9ce9acb63cbb19c22bdf83c60fd1677f4c555f @sebastianbergmann committed Jun 23, 2007
Showing with 18 additions and 9 deletions.
  1. +18 −9 PHPUnit/Framework/MockObject/Mock.php
@@ -193,19 +193,28 @@ protected function generateClassDefinition(ReflectionClass $class)
);
}
- $code .= $this->generateMockApi($class);
+ $code .= $this->generateMockApi($class);
+ $methods = array_unique(array_merge($this->methods, get_class_methods($class->getName())));
- foreach ($this->methods as $methodName) {
- try {
- $method = $class->getMethod($methodName);
+ foreach ($methods as $methodName) {
+ if (in_array($methodName, $this->methods)) {
+ try {
+ $method = $class->getMethod($methodName);
- if ($this->canMockMethod($method)) {
- $code .= $this->generateMethodDefinitionFromExisting($method);
+ if ($this->canMockMethod($method)) {
+ $code .= $this->generateMethodDefinitionFromExisting($method);
+ }
}
- }
- catch (ReflectionException $e) {
- $code .= $this->generateMethodDefinition($class->getName(), $methodName, 'public');
+ catch (ReflectionException $e) {
+ $code .= $this->generateMethodDefinition($this->className, $methodName, 'public');
+ }
+ } else {
+ $code .= "\n" . str_replace(
+ array($this->className . '::', 'self::'),
+ $this->mockClassName . '::',
+ PHPUnit_Util_Class::getMethodSource($this->className, $methodName)
+ );
}
}

0 comments on commit fd9ce9a

Please sign in to comment.