AuthenticationCookieTest::testAuthCaptcha PHP Method

testAuthCaptcha() public method

Test for PMA\libraries\plugins\auth\AuthenticationConfig::auth
public testAuthCaptcha ( ) : void
return void
    public function testAuthCaptcha()
    {
        $restoreInstance = PMA\libraries\Response::getInstance();
        $mockResponse = $this->getMockBuilder('PMA\\libraries\\Response')->disableOriginalConstructor()->setMethods(array('isAjax', 'getFooter', 'getHeader'))->getMock();
        $mockResponse->expects($this->once())->method('isAjax')->with()->will($this->returnValue(false));
        $mockResponse->expects($this->once())->method('getFooter')->with()->will($this->returnValue(new PMA\libraries\Footer()));
        $mockResponse->expects($this->once())->method('getHeader')->with()->will($this->returnValue(new PMA\libraries\Header()));
        $_REQUEST['old_usr'] = '';
        $GLOBALS['cfg']['LoginCookieRecall'] = false;
        $attrInstance = new ReflectionProperty('PMA\\libraries\\Response', '_instance');
        $attrInstance->setAccessible(true);
        $attrInstance->setValue($mockResponse);
        $GLOBALS['pmaThemeImage'] = 'test';
        $GLOBALS['cfg']['Lang'] = '';
        $GLOBALS['cfg']['AllowArbitraryServer'] = false;
        $GLOBALS['cfg']['Servers'] = array(1);
        $GLOBALS['cfg']['CaptchaLoginPrivateKey'] = 'testprivkey';
        $GLOBALS['cfg']['CaptchaLoginPublicKey'] = 'testpubkey';
        $GLOBALS['server'] = 0;
        $GLOBALS['error_handler'] = new PMA\libraries\ErrorHandler();
        ob_start();
        $this->object->auth();
        $result = ob_get_clean();
        // assertions
        $this->assertContains('<img name="imLogo" id="imLogo" src="testpma_logo.png"', $result);
        $this->assertContains('<select name="lang" class="autosubmit" lang="en" dir="ltr" ' . 'id="sel-lang">', $result);
        $this->assertContains('<form method="post" action="index.php" name="login_form" ' . 'autocomplete="off" class="disableAjax login hide js-show">', $result);
        $this->assertContains('<input type="hidden" name="server" value="0" />', $result);
        $this->assertContains('<script src="https://www.google.com/recaptcha/api.js?hl=en"' . ' async defer></script>', $result);
        $this->assertContains('<div class="g-recaptcha" data-sitekey="testpubkey">', $result);
        $attrInstance->setValue($restoreInstance);
    }