2010-10-14 16:38:40 +00:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
* Dynamically change configuration variables based on the test suite name and a cookie value.
|
|
|
|
|
* For details on how to configure a wiki for a Selenium test, see:
|
|
|
|
|
* http://www.mediawiki.org/wiki/SeleniumFramework#Test_Wiki_configuration
|
|
|
|
|
*/
|
2010-10-18 18:15:13 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
|
|
|
|
die( 1 );
|
2010-10-14 16:38:40 +00:00
|
|
|
}
|
2010-10-18 18:15:13 +00:00
|
|
|
|
|
|
|
|
$fname = 'SeleniumWebSettings.php';
|
|
|
|
|
wfProfileIn( $fname );
|
|
|
|
|
|
2010-10-14 16:38:40 +00:00
|
|
|
$cookiePrefix = $wgSitename . "-";
|
2010-10-18 18:15:13 +00:00
|
|
|
$cookieName = $cookiePrefix . "Selenium";
|
2010-10-14 16:38:40 +00:00
|
|
|
|
|
|
|
|
//if we find a request parameter containing the test name, set a cookie with the test name
|
2010-10-18 18:15:13 +00:00
|
|
|
if ( isset( $_GET['setupTestSuite'] ) ) {
|
2010-10-14 16:38:40 +00:00
|
|
|
$setupTestSuiteName = $_GET['setupTestSuite'];
|
2010-10-18 18:15:13 +00:00
|
|
|
|
|
|
|
|
if ( preg_match( '/[^a-zA-Z0-9_-]/', $setupTestSuiteName ) || !isset( $wgSeleniumTestConfigs[$setupTestSuiteName] ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-10-14 16:38:40 +00:00
|
|
|
if ( strlen( $setupTestSuiteName) > 0 ) {
|
|
|
|
|
$expire = time() + 600;
|
2010-10-18 18:15:13 +00:00
|
|
|
setcookie( $cookieName,
|
2010-10-14 16:38:40 +00:00
|
|
|
$setupTestSuiteName,
|
|
|
|
|
$expire,
|
|
|
|
|
$wgCookiePath,
|
|
|
|
|
$wgCookieDomain,
|
|
|
|
|
$wgCookieSecure,
|
|
|
|
|
true );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//clear the cookie based on a request param
|
2010-10-18 18:15:13 +00:00
|
|
|
if ( isset( $_GET['clearTestSuite'] ) ) {
|
2010-10-14 16:38:40 +00:00
|
|
|
$expire = time() - 600;
|
2010-10-18 18:15:13 +00:00
|
|
|
setcookie( $cookieName,
|
2010-10-14 16:38:40 +00:00
|
|
|
'',
|
|
|
|
|
$expire,
|
|
|
|
|
$wgCookiePath,
|
|
|
|
|
$wgCookieDomain,
|
|
|
|
|
$wgCookieSecure,
|
|
|
|
|
true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if a cookie is found, run the appropriate callback to get the config params.
|
2010-10-18 18:15:13 +00:00
|
|
|
if ( isset( $_COOKIE[$cookieName] ) ) {
|
|
|
|
|
$testSuiteName = $_COOKIE[$cookieName];
|
|
|
|
|
if ( !isset( $wgSeleniumTestConfigs[$testSuiteName] ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-10-14 16:38:40 +00:00
|
|
|
$testIncludes = array(); //array containing all the includes needed for this test
|
2010-10-18 18:15:13 +00:00
|
|
|
$testGlobalConfigs = array(); //an array containg all the global configs needed for this test
|
|
|
|
|
$callback = $wgSeleniumTestConfigs[$testSuiteName];
|
|
|
|
|
call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs));
|
2010-10-14 16:38:40 +00:00
|
|
|
|
|
|
|
|
foreach ( $testIncludes as $includeFile ) {
|
|
|
|
|
$file = $IP . '/' . $includeFile;
|
|
|
|
|
require_once( $file );
|
|
|
|
|
}
|
|
|
|
|
foreach ( $testGlobalConfigs as $key => $value ) {
|
2010-10-18 18:15:13 +00:00
|
|
|
if ( is_array( $value ) ) {
|
|
|
|
|
$GLOBALS[$key] = array_merge( $GLOBALS[$key], $value );
|
2010-10-14 16:38:40 +00:00
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$GLOBALS[$key] = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-10-18 18:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wfProfileOut( $fname );
|