File: CreateDropDatabaseTest.php

package info (click to toggle)
phpmyadmin 4%3A5.2.2-really%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 140,312 kB
  • sloc: javascript: 228,447; php: 166,904; xml: 17,847; sql: 504; sh: 275; makefile: 209; python: 205
file content (92 lines) | stat: -rw-r--r-- 2,799 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php

declare(strict_types=1);

namespace PhpMyAdmin\Tests\Selenium;

/**
 * @coversNothing
 */
#[\PHPUnit\Framework\Attributes\CoversNothing]
class CreateDropDatabaseTest extends TestBase
{
    /**
     * Setup the browser environment to run the selenium test case
     */
    protected function setUp(): void
    {
        parent::setUp();
        /* TODO: For now this tests needs superuser for deleting database */
        $this->skipIfNotSuperUser();
        $this->login();
    }

    /**
     * Creates a database and drops it
     *
     * @group large
     */
    #[\PHPUnit\Framework\Attributes\Group('large-group')]
    public function testCreateDropDatabase(): void
    {
        $this->dbQuery('DROP DATABASE IF EXISTS `' . $this->databaseName . '`;');

        $this->waitForElement('partialLinkText', 'Databases')->click();
        $this->waitAjax();

        $element = $this->waitForElement('id', 'text_create_db');
        $element->clear();
        $element->sendKeys($this->databaseName);

        $this->byId('buttonGo')->click();

        $this->waitForElement('linkText', 'Database: ' . $this->databaseName);

        $this->dbQuery(
            'SHOW DATABASES LIKE \'' . $this->databaseName . '\';',
            function (): void {
                self::assertTrue($this->isElementPresent('className', 'table_results'));
                self::assertEquals($this->databaseName, $this->getCellByTableClass('table_results', 1, 1));
            }
        );

        $this->dropDatabase();
    }

    /**
     * Drops a database, called after testCreateDropDatabase
     */
    private function dropDatabase(): void
    {
        $this->gotoHomepage();

        $this->byPartialLinkText('Databases')->click();
        $this->waitAjax();

        $this->scrollToBottom();

        $dbElement = $this->byCssSelector("input[name='selected_dbs[]'][value='" . $this->databaseName . "']");
        $this->scrollToElement($dbElement, 0, 20);
        $dbElement->click();

        $multSubmit = $this->byCssSelector('#bulkActionDropButton');
        $this->scrollToElement($multSubmit);
        $multSubmit->click();
        $this->byCssSelector('#dropDatabaseModalDropButton')->click();

        $this->waitForElementNotPresent(
            'cssSelector',
            "input[name='selected_dbs[]'][value='" . $this->databaseName . "']"
        );

        $this->waitForElement('cssSelector', 'span.ajax_notification .alert-success');

        $this->dbQuery(
            'SHOW DATABASES LIKE \'' . $this->databaseName . '\';',
            function (): void {
                self::assertTrue($this->isElementPresent('className', 'table_results'));
                self::assertFalse($this->isElementPresent('cssSelector', '.table_results tbody tr'));
            }
        );
    }
}