Localisation updates for core and extension messages from translatewiki.net (2010...
[lhc/web/wiklou.git] / includes / SeleniumWebSettings.php
1 <?php
2 /*
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
6 */
7 if ( !$wgEnableSelenium ) {
8 return;
9 }
10 $cookiePrefix = $wgSitename . "-";
11 $name = $cookiePrefix . "Selenium";
12
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;
19 setcookie( $name,
20 $setupTestSuiteName,
21 $expire,
22 $wgCookiePath,
23 $wgCookieDomain,
24 $wgCookieSecure,
25 true );
26 }
27 }
28 //clear the cookie based on a request param
29 if ( array_key_exists( 'clearTestSuite', $_GET) ) {
30 $expire = time() - 600;
31 setcookie( $name,
32 '',
33 $expire,
34 $wgCookiePath,
35 $wgCookieDomain,
36 $wgCookieSecure,
37 true );
38 }
39
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));
48 }
49
50 foreach ( $testIncludes as $includeFile ) {
51 $file = $IP . '/' . $includeFile;
52 require_once( $file );
53 }
54 foreach ( $testGlobalConfigs as $key => $value ) {
55 if ( is_array( $value ) ) {
56
57 $configArray = array();
58 if ( isset( $GLOBALS[$key] ) ) {
59 $configArray = $GLOBALS[$key];
60 }
61 foreach ( $value as $configKey => $configValue ) {
62 $configArray[$configKey] = $configValue;
63 }
64 $GLOBALS[$key] = $configArray;
65 } else {
66 $GLOBALS[$key] = $value;
67 }
68 }
69 }