Merge pull request #19552 from kamil-tekiela/Fix-default-values
[phpmyadmin.git] / tests / end-to-end / ChangePasswordTest.php
blob86054799eff4734bfe8200dae07a4b1c126960e8
1 <?php
3 declare(strict_types=1);
5 namespace PhpMyAdmin\Tests\Selenium;
7 use PHPUnit\Framework\Attributes\CoversNothing;
8 use PHPUnit\Framework\Attributes\Large;
10 use function trim;
12 #[CoversNothing]
13 #[Large]
14 class ChangePasswordTest extends TestBase
16 /**
17 * Create a test database for this test class
19 protected static bool $createDatabase = false;
21 /**
22 * Tests the changing of the password
24 public function testChangePassword(): void
26 $this->login();
28 $e = $this->waitForElement('id', 'change_password_anchor');
29 $e->click();
31 $this->waitAjax();
33 $this->waitForElement('xpath', "//span[contains(., 'Change password')]");
35 $ele = $this->waitForElement('name', 'pma_pw');
36 self::assertSame('', $ele->getAttribute('value'));
38 $ele = $this->waitForElement('name', 'pma_pw2');
39 self::assertSame('', $ele->getAttribute('value'));
41 $ele = $this->waitForElement('name', 'generated_pw');
42 self::assertSame('', $ele->getAttribute('value'));
44 $this->byId('button_generate_password')->click();
45 self::assertNotSame('', $this->byName('pma_pw')->getAttribute('value'));
46 self::assertNotSame('', $this->byName('pma_pw2')->getAttribute('value'));
47 self::assertNotSame('', $this->byName('generated_pw')->getAttribute('value'));
49 if ($this->getTestSuiteUserPassword() !== '') {
50 $this->byName('pma_pw')->clear();
51 $this->byName('pma_pw2')->clear();
53 $this->byName('pma_pw')->click()->sendKeys($this->getTestSuiteUserPassword());
55 $this->byName('pma_pw2')->click()->sendKeys($this->getTestSuiteUserPassword());
56 } else {
57 $this->byId('nopass_1')->click();
60 $this->byId('changePasswordGoButton')->click();
61 $ele = $this->waitForElement('cssSelector', '.alert-success');
62 self::assertSame(
63 'The profile has been updated.',
64 trim($ele->getText()),