Follow-up r103915: We need to increment $end before the strcspn.
[lhc/web/wiklou.git] / tests / phpunit / includes / RevisionTest.php
index a9405b6..d7654db 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-class RevisionTest extends PHPUnit_Framework_TestCase {
+class RevisionTest extends MediaWikiTestCase {
        var $saveGlobals = array();
 
        function setUp() {
@@ -9,8 +9,7 @@ class RevisionTest extends PHPUnit_Framework_TestCase {
                $globalSet = array(
                        'wgLegacyEncoding' => false,
                        'wgCompressRevisions' => false,
-                       'wgInputEncoding' => 'utf-8',
-                       'wgOutputEncoding' => 'utf-8' );
+               );
                foreach ( $globalSet as $var => $data ) {
                        $this->saveGlobals[$var] = $GLOBALS[$var];
                        $GLOBALS[$var] = $data;
@@ -33,12 +32,16 @@ class RevisionTest extends PHPUnit_Framework_TestCase {
        }
 
        function testGetRevisionTextGzip() {
-               $row = new stdClass;
-               $row->old_flags = 'gzip';
-               $row->old_text = gzdeflate( 'This is a bunch of revision text.' );
-               $this->assertEquals(
-                       'This is a bunch of revision text.',
-                       Revision::getRevisionText( $row ) );
+               if ( !function_exists( 'gzdeflate' ) ) {
+                       $this->markTestSkipped( 'Gzip compression is not enabled (requires zlib).' );
+               } else {
+                       $row = new stdClass;
+                       $row->old_flags = 'gzip';
+                       $row->old_text = gzdeflate( 'This is a bunch of revision text.' );
+                       $this->assertEquals(
+                               'This is a bunch of revision text.',
+                               Revision::getRevisionText( $row ) );
+               }
        }
 
        function testGetRevisionTextUtf8Native() {
@@ -62,23 +65,31 @@ class RevisionTest extends PHPUnit_Framework_TestCase {
        }
 
        function testGetRevisionTextUtf8NativeGzip() {
-               $row = new stdClass;
-               $row->old_flags = 'gzip,utf-8';
-               $row->old_text = gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" );
-               $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
-               $this->assertEquals(
-                       "Wiki est l'\xc3\xa9cole superieur !",
-                       Revision::getRevisionText( $row ) );
+               if ( !function_exists( 'gzdeflate' ) ) {
+                       $this->markTestSkipped( 'Gzip compression is not enabled (requires zlib).' );
+               } else {
+                       $row = new stdClass;
+                       $row->old_flags = 'gzip,utf-8';
+                       $row->old_text = gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" );
+                       $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
+                       $this->assertEquals(
+                               "Wiki est l'\xc3\xa9cole superieur !",
+                               Revision::getRevisionText( $row ) );
+               }
        }
 
        function testGetRevisionTextUtf8LegacyGzip() {
-               $row = new stdClass;
-               $row->old_flags = 'gzip';
-               $row->old_text = gzdeflate( "Wiki est l'\xe9cole superieur !" );
-               $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
-               $this->assertEquals(
-                       "Wiki est l'\xc3\xa9cole superieur !",
-                       Revision::getRevisionText( $row ) );
+               if ( !function_exists( 'gzdeflate' ) ) {
+                       $this->markTestSkipped( 'Gzip compression is not enabled (requires zlib).' );
+               } else {
+                       $row = new stdClass;
+                       $row->old_flags = 'gzip';
+                       $row->old_text = gzdeflate( "Wiki est l'\xe9cole superieur !" );
+                       $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
+                       $this->assertEquals(
+                               "Wiki est l'\xc3\xa9cole superieur !",
+                               Revision::getRevisionText( $row ) );
+               }
        }
 
        function testCompressRevisionTextUtf8() {