mock_objects.php
protected function createCodeForSubclass($methods)
    {
        $code = "";
        if (!empty($this->namespace)) {
            $code  .= 'namespace ' . $this->namespace . ";\n";
        }
        $code .= 'class ' . $this->mock_class . ' extends ' . $this->class . " {\n";
        $code .= "    public \$mock;\n";
        $code .= $this->addMethodList(array_merge($methods, $this->reflection->getMethods()));
        $code .= "\n";
        $code .= "    function __construct() {\n";
        $code .= '        $this->mock = new \\' . $this->mock_base . "();\n";
        $code .= "        \$this->mock->disableExpectationNameChecks();\n";
        $code .= "    }\n";
        $code .= $this->createCodeForConstructor();
        $code .= $this->chainMockReturns();
        $code .= $this->chainMockExpectations();
        $code .= $this->chainThrowMethods();
        $code .= $this->createCodeForOverridenMethods($this->reflection->getMethods());
        $code .= $this->createCodeForNewMethod($methods);
        $code .= "}\n";

        return $code;
    }
protected function createCodeForSubclass($methods)
    {
        $code = "";
        if (!empty($this->namespace)) {
            $code  .= 'namespace ' . $this->namespace . ";\n";
        }
        $code .= 'class ' . $this->mock_class . ' extends ' . $this->class . " {\n";
        $code .= "    public \$mock;\n";
        $code .= $this->addMethodList(array_merge($methods, $this->reflection->getMethods()));
        $code .= "\n";
        $code .= "    function __construct() {\n";
        $code .= '        $this->mock = new \\' . $this->mock_base . "();\n";
        $code .= "        \$this->mock->disableExpectationNameChecks();\n";
        $code .= "    }\n";
        $code .= $this->createCodeForConstructor();
        $code .= $this->chainMockReturns();
        $code .= $this->chainMockExpectations();
        $code .= $this->chainThrowMethods();
        $code .= $this->createCodeForOverridenMethods($this->reflection->getMethods());
        $code .= $this->createCodeForNewMethod($methods);
        $code .= "}\n";

        return $code;
    }
protected function createCodeForSubclass ( $ methods ) { $ code = "" ; if ( ! empty ( $ this -> namespace ) ) { $ code .= 'namespace ' . $ this -> namespace . ";\n" ; } $ code .= 'class ' . $ this -> mock_class . ' extends ' . $ this -> class . " {\n" ; $ code .= "    public \$mock;\n" ; $ code .= $ this -> addMethodList ( array_merge ( $ methods , $ this -> reflection -> getMethods ( ) ) ) ; $ code .= "\n" ; $ code .= "    function __construct() {\n" ; $ code .= '        $this->mock = new \\' . $ this -> mock_base . "();\n" ; $ code .= "        \$this->mock->disableExpectationNameChecks();\n" ; $ code .= "    }\n" ; $ code .= $ this -> createCodeForConstructor ( ) ; $ code .= $ this -> chainMockReturns ( ) ; $ code .= $ this -> chainMockExpectations ( ) ; $ code .= $ this -> chainThrowMethods ( ) ; $ code .= $ this -> createCodeForOverridenMethods ( $ this -> reflection -> getMethods ( ) ) ; $ code .= $ this -> createCodeForNewMethod ( $ methods ) ; $ code .= "}\n" ; return $ code ; }
The new mock class code as a string.
The mock will be a subclass of the original mocked class.

@param array $methods Additional methods.

@return string Code for new mock class.
The new mock class code as a string . The mock will be a subclass of the original mocked class .