object = new AuthenticationConfig(); } /** * tearDown for test cases */ protected function tearDown(): void { parent::tearDown(); unset($this->object); } public function testAuth(): void { $this->assertTrue( $this->object->showLoginForm() ); } public function testAuthCheck(): void { $GLOBALS['cfg']['Server'] = [ 'user' => 'username', 'password' => 'password', ]; $this->assertTrue( $this->object->readCredentials() ); } public function testAuthSetUser(): void { $this->assertTrue( $this->object->storeCredentials() ); } public function testAuthFails(): void { $GLOBALS['errorHandler'] = new ErrorHandler(); $GLOBALS['cfg']['Servers'] = [1]; $GLOBALS['allowDeny_forbidden'] = false; $dbi = $this->getMockBuilder(DatabaseInterface::class) ->disableOriginalConstructor() ->getMock(); $GLOBALS['dbi'] = $dbi; ob_start(); $this->object->showFailure(''); $html = ob_get_clean(); $this->assertIsString($html); $this->assertStringContainsString( 'You probably did not create a configuration file. You might want ' . 'to use the setup script to create one.', $html ); $this->assertStringContainsString( 'MySQL said: ' . 'Documentation', $html ); $this->assertStringContainsString('Cannot connect: invalid settings.', $html); $this->assertStringContainsString( 'Retry to connect', $html ); } }