From 6c2b06c657553f84249d1dafffdf4a3aa4793250 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Wed, 25 Mar 2009 01:24:13 +0000 Subject: [PATCH] Add tests for autoformatting enabled AND disabled. Some enabling changes in parserTests.inc --- maintenance/parserTests.inc | 24 ++++++++++++++++++++---- maintenance/parserTests.txt | 13 +++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index 1df63383d7..b689fc1b5a 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -353,6 +353,9 @@ class ParserTest { 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 @@ -364,7 +367,9 @@ class ParserTest { $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(); @@ -414,12 +419,12 @@ class ParserTest { * @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 ); @@ -502,7 +507,7 @@ class ParserTest { * 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(); } @@ -568,6 +573,17 @@ class ParserTest { '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]; diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 9ce0d02417..88975361c3 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -7253,6 +7253,8 @@ Multibyte character in padright !! test Formatted date +!! config +wgUseDynamicDates=1 !! input [[2009-03-24]] !! result @@ -7278,6 +7280,17 @@ Formatted unlinked date with default format

!! end +!! test +Formatted date with autoformatting disabled +!! config +wgUseDynamicDates=false +!! input +[[2009-03-24]] +!! result +

2009-03-24 +

+!!end + # # # -- 2.20.1