forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPmaSeleniumNormalizationTest.php
173 lines (165 loc) · 4.87 KB
/
PmaSeleniumNormalizationTest.php
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Selenium TestCase for normalization
*
* @package PhpMyAdmin-test
* @subpackage Selenium
*/
require_once 'TestBase.php';
/**
* PMA_SeleniumNormalizationTest class
*
* @package PhpMyAdmin-test
* @subpackage Selenium
* @group selenium
*/
class PMA_SeleniumNormalizationTest extends PMA_SeleniumBase
{
/**
* Setup the browser environment to run the selenium test case
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->dbQuery(
"CREATE TABLE `test_table` ("
. " `id` int(11) NOT NULL AUTO_INCREMENT,"
. " `val` int(11) NOT NULL,"
. " `val2` varchar(64) NOT NULL,"
. "PRIMARY KEY(id)"
. ")"
);
}
/**
* setUp function that can use the selenium session
*
* @return void
*/
public function setUpPage()
{
parent::setUpPage();
$this->login();
$this->navigateTable('test_table');
$this->waitForElement(
"byXPath",
"(//a[contains(., 'Structure')])"
)->click();
$this->waitAjax();
$this->waitForElement("byId", "tablestructure");
$this->byPartialLinkText('Normalize')->click();
$this->waitForElement("byId", "normalizeTable");
}
/**
* Test for normalization to 1NF
*
* @return void
*
* @group large
*/
public function testNormalizationTo1NF()
{
$this->assertTrue(
$this->isElementPresent('byCssSelector', 'fieldset')
);
$this->assertEquals(
"First step of normalization (1NF)",
$this->byCssSelector('label[for=normalizeTo_1nf]')->text()
);
$this->assertTrue(
$this->isElementPresent(
'byCssSelector', 'input[id=normalizeTo_1nf][type=radio]:checked'
)
);
$this->byCssSelector('input[name=submit_normalize]')->click();
$this->waitForElement('byId', 'mainContent');
$this->_test1NFSteps();
}
/**
* assertions in 1NF steps 1.1, 1.2, 1.3
*
* @return void
*/
private function _test1NFSteps()
{
$this->assertEquals(
"First step of normalization (1NF)",
$this->byCssSelector('#page_content h3')->text()
);
$this->assertTrue(
$this->isElementPresent(
'byCssSelector', '#mainContent h4'
)
);
$this->assertTrue(
$this->isElementPresent(
'byCssSelector', '#mainContent #newCols'
)
);
$this->assertTrue(
$this->isElementPresent(
'byCssSelector', '.tblFooters'
)
);
$this->assertTrue(
$this->isElementPresent(
'byCssSelector', '#selectNonAtomicCol option[value=val2]'
)
);
$this->assertFalse(
$this->isElementPresent(
'byCssSelector', '#selectNonAtomicCol option[value=val]'
)
);
$this->assertTrue(
$this->isElementPresent(
'byCssSelector', '#selectNonAtomicCol option[value=no_such_col]'
)
);
$this->select(
$this->byId('selectNonAtomicCol')
)->selectOptionByValue('no_such_col');
$this->waitForElement(
"byXPath",
"//legend[contains(., 'Step 1.2 Have a primary key')]"
);
$text = $this->byCssSelector("#mainContent h4")->text();
$this->assertContains("Primary key already exists.", $text);
$this->waitForElement(
"byXPath",
"//legend[contains(., 'Step 1.3 Move repeating groups')]"
);
$this->byCssSelector('input[value="No repeating group"]')->click();
$this->waitForElement(
"byXPath",
"//legend[contains(., 'Step 1.4 Remove redundant columns')]"
);
$this->assertTrue(
$this->isElementPresent(
'byCssSelector', '#mainContent #extra'
)
);
$this->assertTrue(
$this->isElementPresent(
'byCssSelector', '#extra input[value=val2][type=checkbox]'
)
);
$this->assertTrue(
$this->isElementPresent(
'byCssSelector', '#extra input[value=id][type=checkbox]'
)
);
$this->byCssSelector('#extra input[value=val][type=checkbox]')->click();
$this->byCssSelector("#removeRedundant")->click();
$this->waitForElement(
"byXPath",
"//legend[contains(., 'End of step')]"
);
$this->assertContains(
"The first step of normalization is complete for table 'test_table'.",
$this->byCssSelector("#mainContent h4")->text()
);
}
}