Add tests for autoformatting enabled AND disabled. Some enabling changes in parserTes...
authorAndrew Garrett <werdna@users.mediawiki.org>
Wed, 25 Mar 2009 01:24:13 +0000 (01:24 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Wed, 25 Mar 2009 01:24:13 +0000 (01:24 +0000)
maintenance/parserTests.inc
maintenance/parserTests.txt

index 1df6338..b689fc1 100644 (file)
@@ -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];
index 9ce0d02..8897536 100644 (file)
@@ -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
 </p>
 !! end
 
+!! test
+Formatted date with autoformatting disabled
+!! config
+wgUseDynamicDates=false
+!! input
+[[2009-03-24]]
+!! result
+<p><a href="/index.php?title=2009-03-24&amp;action=edit&amp;redlink=1" class="new" title="2009-03-24 (page does not exist)">2009-03-24</a>
+</p>
+!!end
+
 #
 #
 #