Permalink
Browse files

cleaned up a bug with requiring inheritance and method passthroughs o…

…n the _original

Signed-off-by: Jakob Heuser <jakob@felocity.org>
  • Loading branch information...
Jakobo committed May 27, 2008
1 parent d175730 commit 1c011012b497c2efb907eece402d4a259332da07
Showing with 6 additions and 3 deletions.
  1. +1 −0 constants.php
  2. +5 −3 core/mock/mock.php
View
@@ -4,6 +4,7 @@
define('SNAPTEST_ROOT', dirname(__FILE__) . DIRECTORY_SEPARATOR);
define('SNAPTEST_CORE', SNAPTEST_ROOT . 'core' . DIRECTORY_SEPARATOR);
define('SNAPTEST_UTIL', SNAPTEST_CORE . 'util' . DIRECTORY_SEPARATOR);
+ define('SNAPTEST_WEBFILES', SNAPTEST_UTIL . 'webfiles' . DIRECTORY_SEPARATOR);
define('SNAPTEST_LOADERS', SNAPTEST_CORE . 'loader' . DIRECTORY_SEPARATOR . 'loaders' . DIRECTORY_SEPARATOR);
define('SNAPTEST_REPORTERS', SNAPTEST_CORE . 'reporter' . DIRECTORY_SEPARATOR . 'reporters' . DIRECTORY_SEPARATOR);
View
@@ -441,7 +441,6 @@ public function invokeMethod($method_name, $method_params) {
// no default. If it is inherited, fall to original
if ($this->isInherited()) {
$method_call = $this->class_signature.'_'.$method_name.'_original';
-
if ($this->hasStaticMethods()) {
if (method_exists(get_class($this->constructed_object), $method_call)) {
return call_user_func_array(array(get_class($this->constructed_object), $method_call), $method_params);
@@ -628,16 +627,19 @@ protected function buildMethod($class_name, $method_name, $scope) {
$get_mock = (($is_static) ? 'self::'.$this->class_signature : '$this->'.$this->class_signature).'_getMock'.(($is_static) ? '_static' : '');
// build a param string
- $param_string = '';
+ $param_string = ''; // with defaults
+ $original_param_string = ''; // without
foreach ($method->getParameters() as $i => $param) {
$default_value = ($param->isOptional()) ? '=' . var_export($param->getDefaultValue(), TRUE) : '';
$type = ($param->getClass()) ? $param->getClass()->getName().' ' : '';
$ref = ($param->isPassedByReference()) ? '&' : '';
$param_string .= $type . $ref . '$'.$param->getName().$default_value.',';
+ $original_param_string .= $type . $ref . '$'.$param->getName().',';
}
$param_string = trim($param_string, ',');
+ $original_param_string = trim($original_param_string, ',');
// build the output for a normal object, if it isn't a constructor
// if it is a constructor, use a special global for setting it
@@ -665,7 +667,7 @@ protected function buildMethod($class_name, $method_name, $scope) {
}
else {
$output .= 'public function '.$this->class_signature.'_'.$method_name.'_original('.$param_string.') {'.$endl;
- $output .= ' return parent::'.$method_name.'('.$param_string.');'.$endl;
+ $output .= ' return parent::'.$method_name.'('.$original_param_string.');'.$endl;
$output .= '}'.$endl;
}
}

0 comments on commit 1c01101

Please sign in to comment.