AuthenticationHttpTest::doMockResponse PHP Method

doMockResponse() public method

public doMockResponse ( $set_minimal, $body_id, $set_title )
    public function doMockResponse($set_minimal, $body_id, $set_title)
    {
        $restoreInstance = PMA\libraries\Response::getInstance();
        // mock footer
        $mockFooter = $this->getMockBuilder('PMA\\libraries\\Footer')->disableOriginalConstructor()->setMethods(array('setMinimal'))->getMock();
        $mockFooter->expects($this->exactly($set_minimal))->method('setMinimal')->with();
        // mock header
        $mockHeader = $this->getMockBuilder('PMA\\libraries\\Header')->disableOriginalConstructor()->setMethods(array('setBodyId', 'setTitle', 'disableMenuAndConsole', 'addHTML'))->getMock();
        $mockHeader->expects($this->exactly($body_id))->method('setBodyId')->with('loginform');
        $mockHeader->expects($this->exactly($set_title))->method('setTitle')->with('Access denied!');
        $mockHeader->expects($this->exactly($set_title))->method('disableMenuAndConsole')->with();
        // set mocked headers and footers
        $mockResponse = $this->getMockBuilder('PMA\\libraries\\Response')->disableOriginalConstructor()->setMethods(array('getHeader', 'getFooter', 'addHTML', 'header', 'headersSent'))->getMock();
        $mockResponse->expects($this->exactly($set_title))->method('getFooter')->with()->will($this->returnValue($mockFooter));
        $mockResponse->expects($this->exactly($set_title))->method('getHeader')->with()->will($this->returnValue($mockHeader));
        $mockResponse->expects($this->any())->method('headersSent')->with()->will($this->returnValue(false));
        $mockResponse->expects($this->exactly($set_title * 6))->method('addHTML')->with();
        $attrInstance = new ReflectionProperty('PMA\\libraries\\Response', '_instance');
        $attrInstance->setAccessible(true);
        $attrInstance->setValue($mockResponse);
        $headers = array_slice(func_get_args(), 3);
        $header_method = $mockResponse->expects($this->exactly(count($headers)))->method('header');
        call_user_func_array(array($header_method, 'withConsecutive'), $headers);
        try {
            if (!empty($_REQUEST['old_usr'])) {
                $this->object->logOut();
            } else {
                $this->assertFalse($this->object->auth());
            }
        } finally {
            $attrInstance->setValue($restoreInstance);
        }
    }