enableBc();
$GLOBALS['server'] = 0;
$GLOBALS['token_provided'] = true;
$GLOBALS['token_mismatch'] = false;
$this->object = new AuthenticationConfig();
}
/**
* tearDown for test cases
*
* @return void
*/
public function tearDown()
{
unset($this->object);
}
/**
* Test for PMA\libraries\plugins\auth\AuthenticationConfig::auth
*
* @return void
*/
public function testAuth()
{
$this->assertTrue(
$this->object->auth()
);
}
/**
* Test for PMA\libraries\plugins\auth\AuthenticationConfig::authCheck
*
* @return void
*/
public function testAuthCheck()
{
$this->assertTrue(
$this->object->authCheck()
);
}
/**
* Test for PMA\libraries\plugins\auth\AuthenticationConfig::authSetUser
*
* @return void
*/
public function testAuthSetUser()
{
$this->assertTrue(
$this->object->authSetUser()
);
}
/**
* Test for PMA\libraries\plugins\auth\AuthenticationConfig::authFails
*
* @return void
*/
public function testAuthFails()
{
$removeConstant = false;
$GLOBALS['error_handler'] = new PMA\libraries\ErrorHandler;
$GLOBALS['cfg']['Servers'] = array(1);
$GLOBALS['allowDeny_forbidden'] = false;
$GLOBALS['collation_connection'] = 'utf-8';
if (!defined('PMA_USR_BROWSER_AGENT')) {
define('PMA_USR_BROWSER_AGENT', 'chrome');
$removeConstant = true;
if (! PMA_HAS_RUNKIT) {
$this->markTestSkipped('Cannot remove constant');
}
}
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$GLOBALS['dbi'] = $dbi;
ob_start();
$result = $this->object->authFails();
$html = ob_get_clean();
$this->assertTrue(
$result
);
$this->assertContains(
'You probably did not create a configuration file. You might want ' .
'to use the setup script to create one.',
$html
);
$this->assertContains(
'MySQL said: ' .
'
',
$html
);
$this->assertContains(
'Cannot connect: invalid settings.',
$html
);
$this->assertContains(
'Retry to connect',
$html
);
if ($removeConstant) {
runkit_constant_remove('PMA_USR_BROWSER_AGENT');
}
}
}