Merge "Change name of section so it does not get confused with Wikidata"
[lhc/web/wiklou.git] / tests / testHelpers.inc
index 7618986..f1eb833 100644 (file)
@@ -1,4 +1,25 @@
 <?php
+/**
+ * Recording for passing/failing tests.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Testing
+ */
 
 class TestRecorder {
        var $parent;
@@ -254,7 +275,7 @@ class DbTestRecorder extends DbTestPreviewer  {
         * and all that fun stuff
         */
        function start() {
-               $this->db->begin();
+               $this->db->begin( __METHOD__ );
 
                if ( ! $this->db->tableExists( 'testrun' )
                        || ! $this->db->tableExists( 'testitem' ) )
@@ -313,8 +334,6 @@ class TestFileIterator implements Iterator {
        private $eof;
 
        function __construct( $file, $parserTest ) {
-               global $IP;
-
                $this->file = $file;
                $this->fh = fopen( $this->file, "rt" );
 
@@ -323,7 +342,6 @@ class TestFileIterator implements Iterator {
                }
 
                $this->parserTest = $parserTest;
-               $this->parserTest->showRunFile( wfRelativePath( $this->file, $IP ) );
 
                $this->lineNum = $this->index = 0;
        }
@@ -463,7 +481,7 @@ class TestFileIterator implements Iterator {
                                }
 
                                if ( isset ( $this->sectionData[$this->section] ) ) {
-                                       throw new MWException( "duplicate section '$section' at line {$this->lineNum} of $this->file\n" );
+                                       throw new MWException( "duplicate section '$this->section' at line {$this->lineNum} of $this->file\n" );
                                }
 
                                $this->sectionData[$this->section] = '';
@@ -486,7 +504,7 @@ class TestFileIterator implements Iterator {
        private function clearSection() {
                $this->sectionData = array();
                $this->section = null;
-               
+
        }
 
        /**
@@ -495,7 +513,7 @@ class TestFileIterator implements Iterator {
         * Throw an exception if it is not set, referencing current section
         * and adding the current file name and line number
         *
-        * @param $token String: expected token that should have been mentionned before closing this section 
+        * @param $token String: expected token that should have been mentionned before closing this section
         */
        private function checkSection( $token ) {
                if( is_null( $this->section ) ) {
@@ -515,10 +533,8 @@ class TestFileIterator implements Iterator {
        }
 }
 
-
 /**
  * A class to delay execution of a parser test hooks.
- *   
  */
 class DelayedParserTest {
 
@@ -541,7 +557,7 @@ class DelayedParserTest {
 
        /**
         * Called whenever we actually want to run the hook.
-        * Should be the case if we found the parserTest is not disabled 
+        * Should be the case if we found the parserTest is not disabled
         */
        public function unleash( &$parserTest ) {
                if( !($parserTest instanceof ParserTest || $parserTest instanceof NewParserTest