diff --git a/test/AllSeleniumTests.php b/test/AllSeleniumTests.php new file mode 100644 index 000000000..50b27c901 --- /dev/null +++ b/test/AllSeleniumTests.php @@ -0,0 +1,39 @@ +addTestSuite('PmaSeleniumLoginTest'); + $suite->addTestSuite('PmaSeleniumXssTest'); + $suite->addTestSuite('PmaSeleniumPrivilegesTest'); + return $suite; + } +} +?> diff --git a/test/PmaSeleniumLoginTest.php b/test/PmaSeleniumLoginTest.php new file mode 100644 index 000000000..dad0f5fd2 --- /dev/null +++ b/test/PmaSeleniumLoginTest.php @@ -0,0 +1,21 @@ +doLogin(); + $this->assertRegExp("/phpMyAdmin .*-dev/", $this->getTitle()); + } +} +?> diff --git a/test/PmaSeleniumPrivilegesTest.php b/test/PmaSeleniumPrivilegesTest.php new file mode 100644 index 000000000..149f3ed7d --- /dev/null +++ b/test/PmaSeleniumPrivilegesTest.php @@ -0,0 +1,48 @@ +doLogin(); + $this->selectFrame("frame_content"); + $this->click("link=Change password"); + $this->waitForPageToLoad("30000"); + try { + $this->assertEquals("", $this->getValue("text_pma_pw")); + } catch (PHPUnit_Framework_AssertionFailedError $e) { + array_push($this->verificationErrors, $e->toString()); + } + try { + $this->assertEquals("", $this->getValue("text_pma_pw2")); + } catch (PHPUnit_Framework_AssertionFailedError $e) { + array_push($this->verificationErrors, $e->toString()); + } + try { + $this->assertEquals("", $this->getValue("generated_pw")); + } catch (PHPUnit_Framework_AssertionFailedError $e) { + array_push($this->verificationErrors, $e->toString()); + } + $this->click("button_generate_password"); + $this->assertNotEquals("", $this->getValue("text_pma_pw")); + $this->assertNotEquals("", $this->getValue("text_pma_pw2")); + $this->assertNotEquals("", $this->getValue("generated_pw")); + $this->type("text_pma_pw", $this->cfg['Test']['testuser']['password']); + $this->type("text_pma_pw2", $this->cfg['Test']['testuser']['password']); + $this->click("change_pw"); + $this->waitForPageToLoad("30000"); + $this->assertTrue($this->isTextPresent("")); + $this->assertTrue($this->isTextPresent("")); + } +} +?> diff --git a/test/PmaSeleniumTestCase.php b/test/PmaSeleniumTestCase.php new file mode 100644 index 000000000..e2468b64c --- /dev/null +++ b/test/PmaSeleniumTestCase.php @@ -0,0 +1,101 @@ + 'Firefox on Windows XP', + 'browser' => '*firefox', + 'host' => 'my.windowsxp.box', + 'port' => 4444, + 'timeout' => 30000, + ), + + array( + 'name' => 'Internet Explorer on Windows XP', + 'browser' => '*iexplore', + 'host' => 'my.windowsxp.box', + 'port' => 4444, + 'timeout' => 30000, + ), + + ); + + public function setUp() + { + global $cfg; + $this->cfg =& $cfg; + //PHPUnit_Extensions_SeleniumTestCase::$browsers = $this->cfg['Test']['broswers']; + + // Check if the test configuration is available + if ( empty($cfg['Test']['pma_host']) + || empty($cfg['Test']['pma_url']) + //|| empty($cfg['Test']['browsers']) + ) { + $this->fail("Missing Selenium configuration in config.inc.php"); // TODO add doc ref? + } + + $this->setBrowserUrl($cfg['Test']['pma_host'] . $cfg['Test']['pma_url']); + + $this->start(); + } + + public function tearDown() + { + $this->stop(); + } + + /** + * perform a login + */ + public function doLogin() + { + $this->open($this->cfg['Test']['pma_url']); + // Somehow selenium does not like the language selection on the cookie login page, forced English in the config for now. + //$this->select("lang", "label=English"); + + $this->waitForPageToLoad("30000"); + $this->type("input_username", $this->cfg['Test']['testuser']['username']); + $this->type("input_password", $this->cfg['Test']['testuser']['password']); + $this->click("input_go"); + $this->waitForPageToLoad("30001"); + } + + /* + * Just a dummy to show some example statements + * + public function mockTest() + { + // Slow down the testing speed, ideal for debugging + //$this->setSpeed(4000); +} + */ +} + +?> diff --git a/test/PmaSeleniumXssTest.php b/test/PmaSeleniumXssTest.php new file mode 100644 index 000000000..0870aa435 --- /dev/null +++ b/test/PmaSeleniumXssTest.php @@ -0,0 +1,25 @@ +doLogin(); + $this->selectFrame("frame_content"); + $this->click("link=SQL"); + $this->waitForPageToLoad("30000"); + $this->type("sqlquery", "'\">"); + $this->click("SQL"); + // If an alert pops up the test fails, since we don't handle an alert. + } +} +?>