= BacklinkCache.php =
authorMark A. Hershberger <mah@users.mediawiki.org>
Tue, 5 Oct 2010 03:47:08 +0000 (03:47 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Tue, 5 Oct 2010 03:47:08 +0000 (03:47 +0000)
* BacklinkCache class
** Set a few otherwise unset varables ($wgContLang & $wgMemc in
   BacklinkCache)
= testHelpers.inc =
* TectRecorder class
** TestRecorder::record() accept and use a recorder object
** change TestFileIterator::setParser use a MediaWikiParserTest instead
   of ParserTest
= parserTest.inc =
* ParserTest class
** Make $ParserTest->regex and $ParsaerTest->savedGlobals member
   variables available to stop warnings.
** Force ParserTest::$showProgress and $showFailure to false
** Set ParserTest::$uploadDir on time
** Move ParserTest::chomp() and addArticle() to bootstrap for
   MediaWikiTestSetup.
** Update ParserTest::runTest so that Success and Failure are reported
   via reporter->showsTestResult() or ParserTestSuiteBackend::show*()
   as needed.
** Set $ParserTest->uploadDir with setupUploadDir()
** Change ParserTest->setupGlobals() so that $wgDBprefix doesn't get
   to set to the “parsertest_” bits.
** Sprinkle $this->teardownGlobals() at exit points in
  ParserTest->teardownDatabase()
= bootstrap.php =
* MediaWikiTestSetup class
** Make member variables MediaWikiTestSetup::$suite,
  MediaW* Make member variables MediaWikiTestSetup::$suite,
  MediaWikiTestSetup::$regex, MediaWikiTestSetup::$runDisabled
  available.
* Setup a constructor MediaWikiTestSetup that accepts an optional
  PHPUnit_Framework_TestSuite so they can use PHPUnit.
* Change MediaWikiParserTest so that it is derived from
  MediaWikiTestSetup instead of PHPUnit_Framework_TestSuite
* Make MediaWikiParserTest create a PHPUnit_Framework_TestSuite for
  the parser tests and pass it to the new parent (MediaWikiTestSetup)
  as the PHPUnit testsuite.
* Replace MediaWikiParserTest->run() with MediaWikiParserTest::suite()
  so that the tests can be loaded into a suite and then run with
  PHPUnit's test runner.
= ParserHelpers.php =
* ParserUnitTest class
** Force run() $backend to use ParserTestSuiteBackend instead of
   trying to get the  backend from the suite member.
** Use ParserTest::runTest() instead of
  ParserikiTestSetup::$regex, MediaWikiTestSetup::$runDisabled
  available.
** Setup a constructor MediaWikiTestSetup that accepts an optional
   PHPUnit_Framework_TestSuite so they can use PHPUnit.
** Change MediaWikiParserTest so that it is derived from
   MediaWikiTestSetup instead of PHPUnit_Framework_TestSuite
** Make MediaWikiParserTest create a PHPUnit_Framework_TestSuite for
   the parser tests and pass it to the new parent (MediaWikiTestSetup)
   as the PHPUnit testsuite.
** Replace MediaWikiParserTest->run() with MediaWikiParserTest::suite()
   so that the tests can be loaded into a suite and then run with
   PHPUnit's test runner.
= ParserHelpers.php =
* ParserUnitTest class
** Force run() $backend to use ParserTestSuiteBackend instead of
   trying to get the  backend from the suite member.
** Use ParserTest::runTest() instead of
  ParserTestSuiteBackend::runTest()
* ParserTestSuiteBackend class
** extends PHPUnit_FrameWork_TestSuite instead of ParserTest
** Add member variables  $recorder, $term, and $usePHPUnit
** Add a constructor that determines if PHPUnit is usewd.
** Add a method showTestResult() that can be used to show success or
   failure
** Change showSucess and showFailure() to be static and use identical
   arguments and only use PHPUnit_Framework_Assert::assertEquals
   when PHPUnit is in use.
= SearchEngineTest.php =
** Fix path in require to bootstrap.php

maintenance/tests/parser/parserTest.inc

index faa4c72..5bf3ef0 100644 (file)
@@ -57,6 +57,9 @@ class ParserTest {
        private $fuzzSeed = 0;
        private $memoryLimit = 50;
 
+       public $regex = "";
+       private $savedGlobals = array();
+
        /**
         * Sets terminal colorization and diff/quick modes depending on OS and
         * command-line options (--color and --quick).
@@ -82,15 +85,14 @@ class ParserTest {
                        : new DummyTermColorer();
 
                $this->showDiffs = !isset( $options['quick'] );
-               $this->showProgress = !isset( $options['quiet'] );
-               $this->showFailure = !(
-                       isset( $options['quiet'] )
-                       && ( isset( $options['record'] )
-                               || isset( $options['compare'] ) ) ); // redundant output
+               $this->showProgress = false; #!isset( $options['quiet'] );
+               $this->showFailure = false; /* !( */
+                       /* isset( $options['quiet'] ) */
+                       /* && ( isset( $options['record'] ) */
+                       /*      || isset( $options['compare'] ) ) ); // redundant output */
 
                $this->showOutput = isset( $options['show-output'] );
 
-
                if ( isset( $options['regex'] ) ) {
                        if ( isset( $options['record'] ) ) {
                                echo "Warning: --record cannot be used with --regex, disabling --record\n";
@@ -104,6 +106,7 @@ class ParserTest {
 
                $this->setupRecorder( $options );
                $this->keepUploads = isset( $options['keep-uploads'] );
+               $this->uploadDir = $this->setupUploadDir();
 
                if ( isset( $options['seed'] ) ) {
                        $this->fuzzSeed = intval( $options['seed'] ) - 1;
@@ -129,18 +132,6 @@ class ParserTest {
                }
        }
 
-       /**
-        * Remove last character if it is a newline
-        */
-       public function chomp( $s ) {
-               if ( substr( $s, -1 ) === "\n" ) {
-                       return substr( $s, 0, -1 );
-               }
-               else {
-                       return $s;
-               }
-       }
-
        /**
         * Run a fuzz test series
         * Draw input from a set of test files
@@ -422,12 +413,12 @@ class ParserTest {
                }
 
 
-               $this->teardownGlobals();
-
-               if ( $result === $out && ( $noxml === true || $this->wellFormed( $out ) ) ) {
-                       return $this->showSuccess( $desc );
+               if ( method_exists( $this->recorder, "showTestResult" ) ) {
+                       return $this->recorder->showTestResult( $desc, $result, $out );
+               } else if ( $result === $out && ( $noxml === true || $this->wellFormed( $out ) ) ) {
+                       return ParserTestSuiteBackend::showSuccess( $desc, $result, $out );
                } else {
-                       return $this->showFailure( $desc, $result, $out );
+                       return ParserTestSuiteBackend::showFailure( $desc, $result, $out );
                }
        }
 
@@ -550,7 +541,6 @@ class ParserTest {
                        'wgStyleSheetPath' => '/skins',
                        'wgSitename' => 'MediaWiki',
                        'wgLanguageCode' => $lang,
-                       'wgDBprefix' => $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_',
                        'wgRawHtml' => isset( $opts['rawhtml'] ),
                        'wgLang' => null,
                        'wgContLang' => null,
@@ -712,7 +702,10 @@ class ParserTest {
                if ( $wgDBtype == 'oracle' )
                        $db->query( 'BEGIN FILL_WIKI_INFO; END;' );
 
-               $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' );
+               if ( ( $wgDBtype != 'oracle' && $wgDBprefix != 'parsertest_' )
+                       && $wgDBprefix != 'pt_' ) {
+                       $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' );
+               }
 
                # Hack: insert a few Wikipedia in-project interwiki prefixes,
                # for testing inter-language links
@@ -769,7 +762,6 @@ class ParserTest {
                global $wgMessageCache, $wgMemc;
                $wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
 
-               $this->uploadDir = $this->setupUploadDir();
                $user = User::createNew( 'WikiSysop' );
                $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) );
                $image->recordUpload2( '', 'Upload of some lame file', 'Some lame file', array(
@@ -820,6 +812,7 @@ class ParserTest {
                global $wgDBtype;
 
                if ( !$this->databaseSetupDone ) {
+                       $this->teardownGlobals();
                        return;
                }
                $this->teardownUploadDir( $this->uploadDir );
@@ -829,6 +822,7 @@ class ParserTest {
 
                if ( $this->useTemporaryTables ) {
                        # Don't need to do anything
+                       $this->teardownGlobals();
                        return;
                }
 
@@ -842,6 +836,8 @@ class ParserTest {
 
                if ( $wgDBtype == 'oracle' )
                        $db->query( 'BEGIN FILL_WIKI_INFO; END;' );
+
+               $this->teardownGlobals();
        }
 
        /**