AuthenticationCookieTest::testAuthSetUserWithHeaders PHP Метод

testAuthSetUserWithHeaders() публичный Метод

Test for PMA\libraries\plugins\auth\AuthenticationConfig::authSetUser (check for headers redirect)
public testAuthSetUserWithHeaders ( ) : void
Результат void
    public function testAuthSetUserWithHeaders()
    {
        $GLOBALS['PHP_AUTH_USER'] = 'pmaUser2';
        $arr = array('host' => 'a', 'port' => 1, 'socket' => true, 'ssl' => true, 'connect_type' => 'port', 'user' => 'pmaUser2');
        $GLOBALS['cfg']['Server'] = $arr;
        $GLOBALS['cfg']['Server']['host'] = 'b';
        $GLOBALS['cfg']['Server']['user'] = 'pmaUser';
        $GLOBALS['cfg']['Servers'][1] = $arr;
        $GLOBALS['cfg']['AllowArbitraryServer'] = true;
        $GLOBALS['pma_auth_server'] = 'b 2';
        $GLOBALS['PHP_AUTH_PW'] = $_SERVER['PHP_AUTH_PW'] = 'testPW';
        $GLOBALS['server'] = 2;
        $GLOBALS['cfg']['LoginCookieStore'] = true;
        $GLOBALS['from_cookie'] = false;
        $GLOBALS['collation_connection'] = 'utf-8';
        $restoreInstance = PMA\libraries\Response::getInstance();
        $mockResponse = $this->getMockBuilder('PMA\\libraries\\Response')->disableOriginalConstructor()->setMethods(array('disable', 'header', 'headersSent'))->getMock();
        $mockResponse->expects($this->at(0))->method('disable');
        // target can be "phpunit" or "ide-phpunit.php",
        // depending on testing environment
        $mockResponse->expects($this->once())->method('header')->with($this->stringContains('&server=2&lang=en&collation_connection=utf-8'));
        $mockResponse->expects($this->any())->method('headersSent')->with()->will($this->returnValue(false));
        $attrInstance = new ReflectionProperty('PMA\\libraries\\Response', '_instance');
        $attrInstance->setAccessible(true);
        $attrInstance->setValue($mockResponse);
        $this->object->authSetUser();
        $this->object->storeUserCredentials();
        $attrInstance->setValue($restoreInstance);
    }