else {
$data['options'] = $this->chomp( $data['options'] );
}
+ if (!isset( $data['config'] ) )
+ $data['config'] = '';
+
if (preg_match('/\\bdisabled\\b/i', $data['options'])
|| !preg_match("/{$this->regex}/i", $data['test'])) {
# disabled test
$this->chomp( $data['test'] ),
$this->chomp( $data['input'] ),
$this->chomp( $data['result'] ),
- $this->chomp( $data['options'] ) );
+ $this->chomp( $data['options'] ),
+ $this->chomp( $data['config'] )
+ );
$ok = $ok && $result;
$this->recorder->record( $this->chomp( $data['test'] ), $result );
$data = array();
* @param string $result Result to output
* @return bool
*/
- private function runTest( $desc, $input, $result, $opts ) {
+ private function runTest( $desc, $input, $result, $opts, $config ) {
if( $this->showProgress ) {
$this->showTesting( $desc );
}
- $this->setupGlobals($opts);
+ $this->setupGlobals($opts, $config);
$user = new User();
$options = ParserOptions::newFromUser( $user );
* Set up the global variables for a consistent environment for each test.
* Ideally this should replace the global configuration entirely.
*/
- private function setupGlobals($opts = '') {
+ private function setupGlobals($opts = '', $config = '') {
if( !isset( $this->uploadDir ) ) {
$this->uploadDir = $this->setupUploadDir();
}
'wgExternalLinkTarget' => false,
'wgAlwaysUseTidy' => false,
);
+
+ if ($config) {
+ $configLines = explode( "\n", $config );
+
+ foreach( $configLines as $line ) {
+ list( $var, $value ) = explode( '=', $line, 2 );
+
+ $settings[$var] = eval("return $value;" );
+ }
+ }
+
$this->savedGlobals = array();
foreach( $settings as $var => $val ) {
$this->savedGlobals[$var] = $GLOBALS[$var];