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