enableBc(); $GLOBALS['server'] = 0; $GLOBALS['db'] = 'db'; $GLOBALS['table'] = 'table'; $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $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 PhpMyAdmin\Plugins\Auth\AuthenticationConfig::showLoginForm * * @return void */ public function testAuth() { $this->assertTrue( $this->object->showLoginForm() ); } /** * Test for PhpMyAdmin\Plugins\Auth\AuthenticationConfig::readCredentials * * @return void */ public function testAuthCheck() { $GLOBALS['cfg']['Server'] = [ 'user' => 'username', 'password' => 'password', ]; $this->assertTrue( $this->object->readCredentials() ); } /** * Test for PhpMyAdmin\Plugins\Auth\AuthenticationConfig::storeCredentials * * @return void */ public function testAuthSetUser() { $this->assertTrue( $this->object->storeCredentials() ); } /** * Test for PhpMyAdmin\Plugins\Auth\AuthenticationConfig::showFailure * * @return void */ public function testAuthFails() { $removeConstant = false; $GLOBALS['error_handler'] = new ErrorHandler(); $GLOBALS['cfg']['Servers'] = [1]; $GLOBALS['allowDeny_forbidden'] = false; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $GLOBALS['dbi'] = $dbi; ob_start(); $this->object->showFailure(''); $html = ob_get_clean(); $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: ' . 'Documentation', $html ); $this->assertContains( 'Cannot connect: invalid settings.', $html ); $this->assertContains( 'Retry to connect', $html ); } }