From: Andrew Garrett
Date: Wed, 25 Mar 2009 01:24:13 +0000 (+0000)
Subject: Add tests for autoformatting enabled AND disabled. Some enabling changes in parserTes...
X-Git-Tag: 1.31.0-rc.0~42382
X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=6c2b06c657553f84249d1dafffdf4a3aa4793250;p=lhc%2Fweb%2Fwiklou.git
Add tests for autoformatting enabled AND disabled. Some enabling changes in parserTests.inc
---
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
+
#
#
#