Beispiel #1
0
 function testMockBase()
 {
     $old_class = SimpleTestOptions::getMockBaseClass();
     SimpleTestOptions::setMockBaseClass('Fred');
     $this->assertEqual(SimpleTestOptions::getMockBaseClass(), 'Fred');
     SimpleTestOptions::setMockBaseClass($old_class);
 }
 /**
  *    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       Additional 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 .= "    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;
 }