Translated using Weblate (Japanese)
[phpmyadmin.git] / test / selenium / PmaSeleniumDbProceduresTest.php
blobf5b17d83c9239af45223edcdda86f236aa46a136
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Selenium TestCase for table related tests
6 * @package PhpMyAdmin-test
7 * @subpackage Selenium
8 */
10 require_once 'TestBase.php';
12 /**
13 * PmaSeleniumDbProceduresTest class
15 * @package PhpMyAdmin-test
16 * @subpackage Selenium
17 * @group selenium
19 class PMA_SeleniumDbProceduresTest extends PMA_SeleniumBase
21 /**
22 * Setup the browser environment to run the selenium test case
24 * @return void
26 public function setUp()
28 parent::setUp();
29 $this->dbQuery(
30 "CREATE TABLE `test_table` ("
31 . " `id` int(11) NOT NULL AUTO_INCREMENT,"
32 . " `name` varchar(20) NOT NULL,"
33 . " `datetimefield` datetime NOT NULL,"
34 . " PRIMARY KEY (`id`)"
35 . ")"
40 /**
41 * setUp function that can use the selenium session (called before each test)
43 * @return void
45 public function setUpPage()
47 $this->login();
48 $this->waitForElement('byLinkText', $this->database_name)->click();
49 $this->waitForElement(
50 "byXPath", "//a[contains(., 'test_table')]"
52 $this->expandMore();
55 /**
56 * Creates procedure for tests
58 * @return void
60 private function _procedureSQL()
62 $this->dbQuery(
63 "CREATE PROCEDURE `test_procedure`(IN `inp` VARCHAR(10), OUT `outp` INT)"
64 . " NOT DETERMINISTIC READS SQL DATA SQL SECURITY DEFINER SELECT char_"
65 . "length(inp) + count(*) FROM test_table INTO outp"
69 /**
70 * Create a procedure
72 * @return void
74 * @group large
76 public function testAddProcedure()
78 $ele = $this->waitForElement("byPartialLinkText", "Routines");
79 $ele->click();
81 $ele = $this->waitForElement("byLinkText", "Add routine");
82 $ele->click();
84 $this->waitForElement("byClassName", "rte_form");
86 $this->byName("item_name")->value("test_procedure");
88 $this->byName("item_param_name[0]")->value("inp");
89 $this->select(
90 $this->byName("item_param_type[0]")
91 )->selectOptionByLabel("VARCHAR");
92 $this->byName("item_param_length[0]")->value("10");
94 $this->byCssSelector("input[value='Add parameter']")->click();
96 $this->select(
97 $this->byName("item_param_dir[1]")
98 )->selectOptionByLabel("OUT");
99 $ele = $this->waitForElement("byName", "item_param_name[1]");
100 $ele->value("outp");
102 $proc = "SELECT char_length(inp) + count(*) FROM test_table INTO outp";
103 $this->typeInTextArea($proc);
105 $this->select(
106 $this->byName("item_sqldataaccess")
107 )->selectOptionByLabel("READS SQL DATA");
109 $this->byXPath("//button[contains(., 'Go')]")->click();
111 $ele = $this->waitForElement(
112 "byXPath",
113 "//div[@class='success' and contains(., "
114 . "'Routine `test_procedure` has been created')]"
117 $result = $this->dbQuery(
118 "SHOW PROCEDURE STATUS WHERE Db='" . $this->database_name . "'"
121 $this->assertEquals(1, $result->num_rows);
122 $this->_executeProcedure("abcabcabcabcabcabcabc", 10);
126 * Test for editing procedure
128 * @return void
130 * @group large
132 public function testEditProcedure()
134 $this->_procedureSQL();
135 $ele = $this->waitForElement("byPartialLinkText", "Routines");
136 $ele->click();
138 $this->waitForElement(
139 "byXPath",
140 "//legend[contains(., 'Routines')]"
143 $this->byLinkText("Edit")->click();
144 $this->waitForElement("byClassName", "rte_form");
145 $this->byName("item_param_length[0]")->clear();
146 $this->byName("item_param_length[0]")->value("12");
148 $this->byXPath("//button[contains(., 'Go')]")->click();
150 $ele = $this->waitForElement(
151 "byXPath",
152 "//div[@class='success' and contains(., "
153 . "'Routine `test_procedure` has been modified')]"
156 $this->_executeProcedure("abcabcabcabcabcabcabc", 12);
160 * Test for dropping procedure
162 * @return void
164 * @group large
166 public function testDropProcedure()
168 $this->_procedureSQL();
169 $ele = $this->waitForElement("byPartialLinkText", "Routines");
170 $ele->click();
172 $this->waitForElement(
173 "byXPath",
174 "//legend[contains(., 'Routines')]"
177 $this->byLinkText("Drop")->click();
178 $this->waitForElement(
179 "byXPath", "//button[contains(., 'OK')]"
180 )->click();
182 $this->waitForElement("byId", "nothing2display");
184 usleep(1000000);
185 $result = $this->dbQuery(
186 "SHOW PROCEDURE STATUS WHERE Db='" . $this->database_name . "'"
188 $this->assertEquals(0, $result->num_rows);
192 * Execute procedure
194 * @param string $text String to pass as inp param
195 * @param int $length Expected output length
197 * @return void
199 private function _executeProcedure($text, $length)
201 $this->waitForElement("byLinkText", "Execute")->click();
202 $this->waitForElement("byName", "params[inp]")->value($text);
203 $this->byCssSelector("div.ui-dialog-buttonset button:nth-child(1)")->click();
204 $this->waitForElement(
205 "byCssSelector",
206 "span#PMA_slidingMessage table tbody"
208 $head = $this->byCssSelector("span#PMA_slidingMessage table tbody")->text();
209 $this->assertEquals("outp\n$length", $head);