PMA\libraries\plugins\auth\AuthenticationHttp::auth PHP Method

auth() public method

Displays authentication form and redirect as necessary
public auth ( ) : boolean
return boolean always true (no return indeed)
    public function auth()
    {
        $response = Response::getInstance();
        if ($response->isAjax()) {
            $response->setRequestStatus(false);
            // reload_flag removes the token parameter from the URL and reloads
            $response->addJSON('reload_flag', '1');
            if (defined('TESTSUITE')) {
                return true;
            } else {
                exit;
            }
        }
        return $this->authForm();
    }

Usage Example

 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 {
         $this->assertFalse($this->object->auth());
     } finally {
         $attrInstance->setValue($restoreInstance);
     }
 }
All Usage Examples Of PMA\libraries\plugins\auth\AuthenticationHttp::auth