3 * Dynamically change configuration variables based on the test suite name and a cookie value.
4 * For details on how to configure a wiki for a Selenium test, see:
5 * http://www.mediawiki.org/wiki/SeleniumFramework#Test_Wiki_configuration
7 if ( !$wgEnableSelenium ) {
10 $cookiePrefix = $wgSitename . "-";
11 $name = $cookiePrefix . "Selenium";
13 //if we find a request parameter containing the test name, set a cookie with the test name
14 if ( array_key_exists( 'setupTestSuite', $_GET) ) {
15 //TODO: do a check for valid testsuite names
16 $setupTestSuiteName = $_GET['setupTestSuite'];
17 if ( strlen( $setupTestSuiteName) > 0 ) {
18 $expire = time() +
600;
28 //clear the cookie based on a request param
29 if ( array_key_exists( 'clearTestSuite', $_GET) ) {
30 $expire = time() - 600;
40 //if a cookie is found, run the appropriate callback to get the config params.
41 if ( array_key_exists( $name, $_COOKIE) ) {
42 $testSuiteName = $_COOKIE[$name];
43 $testIncludes = array(); //array containing all the includes needed for this test
44 $testGlobalConfigs = array(); //an array containg all the global configs needed for this test
45 if ( isset( $wgSeleniumTestConfigs ) && array_key_exists($testSuiteName, $wgSeleniumTestConfigs) ) {
46 $callback = $wgSeleniumTestConfigs[$testSuiteName];
47 call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs));
50 foreach ( $testIncludes as $includeFile ) {
51 $file = $IP . '/' . $includeFile;
52 require_once( $file );
54 foreach ( $testGlobalConfigs as $key => $value ) {
55 if ( is_array( $value ) ) {
57 $configArray = array();
58 if ( isset( $GLOBALS[$key] ) ) {
59 $configArray = $GLOBALS[$key];
61 foreach ( $value as $configKey => $configValue ) {
62 $configArray[$configKey] = $configValue;
64 $GLOBALS[$key] = $configArray;
66 $GLOBALS[$key] = $value;