Permalink
Browse files

- Merge [3871].

  • Loading branch information...
sebastianbergmann committed Oct 20, 2008
1 parent e67a17e commit bb2bf72c99afb555eba0f91a70f68d79ef73cea0
Showing with 8 additions and 33 deletions.
  1. +8 −33 PHPUnit/Framework/MockObject/Mock.php
@@ -385,37 +385,28 @@ protected function generateMockApi(ReflectionClass $class)
protected function generateConstructorCode(ReflectionClass $class)
{
- if (!$this->callOriginalConstructor) {
- return " public function __construct() {\n" .
- " \$this->invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker(\$this);\n" .
- " }\n\n";
- }
-
- $className = $class->getName();
- $constructor = FALSE;
-
- if ($class->hasMethod('__construct')) {
- $constructor = $class->getMethod('__construct');
- }
+ $constructor = $class->getConstructor();
- else if ($class->hasMethod($className)) {
- $constructor = $class->getMethod($className);
+ if ($constructor !== NULL) {
+ $arguments = PHPUnit_Util_Class::getMethodParameters($constructor);
+ } else {
+ $arguments = '';
}
return sprintf(
" public function __construct(%s) {\n" .
" \$this->invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker(\$this);\n" .
" }\n\n",
- $constructor !== FALSE ? PHPUnit_Util_Class::getMethodParameters($constructor) : ''
+ $arguments
);
}
protected function generateConstructorCodeWithParentCall(ReflectionClass $class)
{
- $constructor = $this->getConstructor($class);
+ $constructor = $class->getConstructor();
- if ($constructor) {
+ if ($constructor !== NULL) {
return sprintf(
" public function __construct(%s) {\n" .
" \$args = func_get_args();\n" .
@@ -445,21 +436,5 @@ protected function generateCloneCodeWithParentCall()
" parent::__clone();\n" .
" }\n\n";
}
-
- protected function getConstructor(ReflectionClass $class)
- {
- $className = $class->getName();
- $constructor = NULL;
-
- if ($class->hasMethod('__construct')) {
- $constructor = $class->getMethod('__construct');
- }
-
- else if ($class->hasMethod($className)) {
- $constructor = $class->getMethod($className);
- }
-
- return $constructor;
- }
}
?>

0 comments on commit bb2bf72

Please sign in to comment.