[bug 37746] string ids for content model and format.
[lhc/web/wiklou.git] / tests / phpunit / maintenance / DumpTestCase.php
index f64ad0b..f573c74 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * Base TestCase for dumps
  */
-abstract class DumpTestCase extends MediaWikiTestCase {
+abstract class DumpTestCase extends MediaWikiLangTestCase {
 
        /**
         * exception to be rethrown once in sound PHPUnit surrounding
@@ -72,7 +72,7 @@ abstract class DumpTestCase extends MediaWikiTestCase {
         *
         * Clears $wgUser, and reports errors from addDBData to PHPUnit
         */
-       protected function setUp() {
+       public function setUp() {
                global $wgUser;
 
                parent::setUp();
@@ -295,13 +295,20 @@ abstract class DumpTestCase extends MediaWikiTestCase {
         * @param $text_sha1 string: the base36 SHA-1 of the revision's text
         * @param $text string|false: (optional) The revision's string, or false to check for a
         *            revision stub
+        * @param $model String: the expected content model id (default: CONTENT_MODEL_WIKITEXT)
+        * @param $format String: the expected format model id (default: CONTENT_FORMAT_WIKITEXT)
+        * @param $parentid int|false: (optional) id of the parent revision
         */
-       protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false ) {
+       protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false, $parentid = false,
+                                               $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT ) {
 
                $this->assertNodeStart( "revision" );
                $this->skipWhitespace();
 
                $this->assertTextNode( "id", $id );
+               if( $parentid ) {
+                       $this->assertTextNode( "parentid", $parentid );
+               }
                $this->assertTextNode( "timestamp", false );
 
                $this->assertNodeStart( "contributor" );
@@ -311,14 +318,39 @@ abstract class DumpTestCase extends MediaWikiTestCase {
                $this->skipWhitespace();
 
                $this->assertTextNode( "comment", $summary );
+               $this->skipWhitespace();
+
+               if ( $this->xml->name == "text" ) {
+                       // note: <text> tag may occur here or at the very end.
+                       $text_found = true;
+                       $this->assertText( $id, $text_id, $text_bytes, $text );
+               } else {
+                       $text_found = false;
+               }
+
+               $this->assertTextNode( "sha1", $text_sha1 );
+
+               $this->assertTextNode( "model", $model );
+               $this->skipWhitespace();
+
+               $this->assertTextNode( "format", $format );
+               $this->skipWhitespace();
+
+               if ( !$text_found ) {
+                       $this->assertText( $id, $text_id, $text_bytes, $text );
+               }
+
+               $this->assertNodeEnd( "revision" );
+               $this->skipWhitespace();
+       }
 
+       protected function assertText( $id, $text_id, $text_bytes, $text ) {
                $this->assertNodeStart( "text", false );
                if ( $text_bytes !== false ) {
                        $this->assertEquals( $this->xml->getAttribute( "bytes" ), $text_bytes,
                                "Attribute 'bytes' of revision " . $id );
                }
 
-
                if ( $text === false ) {
                        // Testing for a stub
                        $this->assertEquals( $this->xml->getAttribute( "id" ), $text_id,
@@ -339,11 +371,5 @@ abstract class DumpTestCase extends MediaWikiTestCase {
                        $this->assertNodeEnd( "text" );
                        $this->skipWhitespace();
                }
-
-               $this->assertTextNode( "sha1", $text_sha1 );
-
-               $this->assertNodeEnd( "revision" );
-               $this->skipWhitespace();
        }
-
 }