PMASA-2011-1 fixes
[phpmyadmin-themes.git] / test / PmaSeleniumTestCase.php
blobe2468b64c3e24f58018199773efaf1a2ba2a4b33
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Selenium parent class for TestCases
6 * @version $Id$
7 * @package phpMyAdmin-test
8 */
10 // Optionally add the php-client-driver to your include path
11 set_include_path(get_include_path() . PATH_SEPARATOR . '/opt/selenium-remote-control-1.0.1/selenium-php-client-driver-1.0.1/PEAR/');
13 require_once 'PHPUnit/Framework/TestCase.php';
14 require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
15 require_once 'Testing/Selenium.php';
17 // Include the main phpMyAdmin user config
18 // currently only $cfg['Test'] is used
19 require_once '../config.inc.php';
23 class PmaSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase
25 protected $selenium;
26 protected $cfg;
28 // TODO: find a way to get this from config.inc.php???
29 // PHPUnit also has a way to use XML configuration... maybe we should use that
30 public static $browsers = array(
31 array(
33 'name' => 'Firefox on Windows XP',
34 'browser' => '*firefox',
35 'host' => 'my.windowsxp.box',
36 'port' => 4444,
37 'timeout' => 30000,
40 array(
41 'name' => 'Internet Explorer on Windows XP',
42 'browser' => '*iexplore',
43 'host' => 'my.windowsxp.box',
44 'port' => 4444,
45 'timeout' => 30000,
50 public function setUp()
52 global $cfg;
53 $this->cfg =& $cfg;
54 //PHPUnit_Extensions_SeleniumTestCase::$browsers = $this->cfg['Test']['broswers'];
56 // Check if the test configuration is available
57 if ( empty($cfg['Test']['pma_host'])
58 || empty($cfg['Test']['pma_url'])
59 //|| empty($cfg['Test']['browsers'])
60 ) {
61 $this->fail("Missing Selenium configuration in config.inc.php"); // TODO add doc ref?
64 $this->setBrowserUrl($cfg['Test']['pma_host'] . $cfg['Test']['pma_url']);
66 $this->start();
69 public function tearDown()
71 $this->stop();
74 /**
75 * perform a login
76 */
77 public function doLogin()
79 $this->open($this->cfg['Test']['pma_url']);
80 // Somehow selenium does not like the language selection on the cookie login page, forced English in the config for now.
81 //$this->select("lang", "label=English");
83 $this->waitForPageToLoad("30000");
84 $this->type("input_username", $this->cfg['Test']['testuser']['username']);
85 $this->type("input_password", $this->cfg['Test']['testuser']['password']);
86 $this->click("input_go");
87 $this->waitForPageToLoad("30001");
91 * Just a dummy to show some example statements
93 public function mockTest()
95 // Slow down the testing speed, ideal for debugging
96 //$this->setSpeed(4000);