Пример #1
0
 /**
  *    The extension class code as a string. The class
  *    composites a mock object and chains mocked methods
  *    to it.
  *    @param string $class         Class to extend.
  *    @param string $mock_class    New class name.
  *    @param array  $methods       Mocked methods.
  *    @return string               Code for a new class.
  *    @static
  *    @access private
  */
 function _extendClassCode($class, $mock_class, $methods)
 {
     $mock_base = SimpleTestOptions::getMockBaseClass();
     $code = "class {$mock_class} extends {$class} {\n";
     $code .= "    var \$_mock;\n";
     $code .= Mock::_addMethodList($methods);
     $code .= "\n";
     $code .= "    function {$mock_class}(&\$test, \$wildcard = MOCK_WILDCARD) {\n";
     $code .= "        \$this->_mock = &new {$mock_base}(\$test, \$wildcard, false);\n";
     $code .= "    }\n";
     $code .= Mock::_chainMockReturns();
     $code .= Mock::_chainMockExpectations();
     $code .= Mock::_overrideMethods($methods);
     $code .= SimpleTestOptions::getPartialMockCode();
     $code .= "}\n";
     return $code;
 }