MediaWiki
REL1_21
|
00001 <?php 00002 00003 class DiffHistoryBlobTest extends MediaWikiTestCase { 00004 protected function setUp() { 00005 if ( !extension_loaded( 'xdiff' ) ) { 00006 $this->markTestSkipped( 'The xdiff extension is not available' ); 00007 return; 00008 } 00009 if ( !function_exists( 'xdiff_string_rabdiff' ) ) { 00010 $this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' ); 00011 return; 00012 } 00013 if ( !extension_loaded( 'hash' ) && !extension_loaded( 'mhash' ) ) { 00014 $this->markTestSkipped( 'Neither the hash nor mhash extension is available' ); 00015 return; 00016 } 00017 parent::setUp(); 00018 } 00019 00024 function testXdiffAdler32( $input ) { 00025 $xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 ); 00026 $dhb = new DiffHistoryBlob; 00027 $myHash = $dhb->xdiffAdler32( $input ); 00028 $this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ), 00029 "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) ); 00030 } 00031 00032 public static function provideXdiffAdler32() { 00033 return array( 00034 array( '', 'Empty string' ), 00035 array( "\0", 'Null' ), 00036 array( "\0\0\0", "Several nulls" ), 00037 array( "Hello", "An ASCII string" ), 00038 array( str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" ) 00039 ); 00040 } 00041 }