/** * Test for AuthenticationConfig::authSetUser (check for headers redirect) * * @return void */ public function testAuthSetUserWithHeaders() { if (!defined('PMA_TEST_HEADERS')) { $this->markTestSkipped('Cannot redefine constant/function - missing runkit extension'); } $GLOBALS['PHP_AUTH_USER'] = '******'; $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'] = '******'; $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['cfg']['PmaAbsoluteUri'] = 'http://phpmyadmin.net/'; $GLOBALS['collation_connection'] = 'utf-8'; $restoreInstance = PMA_Response::getInstance(); $mockResponse = $this->getMockBuilder('PMA_Response')->disableOriginalConstructor()->setMethods(array('disable'))->getMock(); $mockResponse->expects($this->at(0))->method('disable'); $attrInstance = new ReflectionProperty('PMA_Response', '_instance'); $attrInstance->setAccessible(true); $attrInstance->setValue($mockResponse); $this->object->authSetUser(); $this->object->storeUserCredentials(); $this->assertTrue(isset($_COOKIE['pmaServer-2'])); // target can be "phpunit" or "ide-phpunit.php", // depending on testing environment $this->assertStringStartsWith('Location: http://phpmyadmin.net/index.php?', $GLOBALS['header'][0]); $this->assertContains('&target=', $GLOBALS['header'][0]); $this->assertContains('&server=2&lang=en&collation_connection=utf-8&token=token&PHPSESSID=', $GLOBALS['header'][0]); $attrInstance->setValue($restoreInstance); }