Translated using Weblate (Portuguese)
[phpmyadmin.git] / tests / end-to-end / ServerSettingsTest.php
blob727d211b39439e85237c7d1cadd1e7e6959beb73
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 sleep;
12 #[CoversNothing]
13 #[Large]
14 class ServerSettingsTest extends TestBase
16 /**
17 * Create a test database for this test class
19 protected static bool $createDatabase = false;
21 /**
22 * setUp function
24 protected function setUp(): void
26 parent::setUp();
28 $this->login();
29 $this->expandMore();
30 $this->waitForElement('partialLinkText', 'Settings')->click();
31 $this->waitAjax();
34 /**
35 * Saves config and asserts correct message.
37 private function saveConfig(): void
39 // Submit the form
40 $ele = $this->waitForElement(
41 'xpath',
42 "//div[contains(@class, 'tab-pane') and contains(@class, 'show')"
43 . " and contains(@class, 'active')]//input[@value='Apply']",
45 $this->scrollToBottom();
46 $this->moveto($ele);
47 $ele->click();
49 $success = $this->waitUntilElementIsPresent('cssSelector', '.alert-success', 5000);
50 self::assertStringContainsString('Configuration has been saved', $success->getText());
53 /**
54 * Tests whether hiding a database works or not
56 public function testHideDatabase(): void
58 $this->createDatabase();
59 $this->byPartialLinkText('Features')->click();
60 $this->waitAjax();
62 $this->waitForElement('xpath', "//a[contains(@href, '#Databases')]")->click();
64 $ele = $this->waitForElement('name', 'Servers-1-hide_db');
65 $this->moveto($ele);
66 $ele->clear();
67 $ele->sendKeys($this->databaseName);
69 $this->saveConfig();
70 self::assertFalse(
71 $this->isElementPresent('partialLinkText', $this->databaseName),
74 $this->waitForElement('xpath', "//a[contains(@href, '#Databases')]")->click();
76 $this->waitForElement('name', 'Servers-1-hide_db')->clear();
77 $this->saveConfig();
78 self::assertTrue(
79 $this->isElementPresent('partialLinkText', $this->databaseName),
83 /**
84 * Tests whether the various settings tabs are displayed when clicked
86 public function testSettingsTabsAreDisplayed(): void
88 $this->byPartialLinkText('SQL queries')->click();
89 $this->waitAjax();
91 $this->waitForElement('className', 'nav-tabs');
93 $this->byPartialLinkText('SQL Query box')->click();
94 self::assertTrue(
95 $this->byId('Sql_box')->isDisplayed(),
97 self::assertFalse(
98 $this->byId('Sql_queries')->isDisplayed(),
101 $this->byCssSelector("a[href='#Sql_queries']")->click();
102 self::assertFalse(
103 $this->byId('Sql_box')->isDisplayed(),
105 self::assertTrue(
106 $this->byId('Sql_queries')->isDisplayed(),
111 * Tests if hiding the logo works or not
113 public function testHideLogo(): void
115 $this->byPartialLinkText('Navigation panel')->click();
116 $this->waitAjax();
118 $this->waitForElement('name', 'NavigationDisplayLogo')
119 ->click();
120 $this->saveConfig();
121 sleep(1);
122 self::assertFalse(
123 $this->isElementPresent('id', 'imgpmalogo'),
126 $this->byCssSelector("a[href='#NavigationDisplayLogo']")->click();
127 $this->saveConfig();
128 sleep(1);
129 self::assertTrue(
130 $this->isElementPresent('id', 'imgpmalogo'),