MediaWiki
REL1_20
|
00001 <?php 00002 00003 class DiffHistoryBlobTest extends MediaWikiTestCase { 00004 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 } 00018 00023 function testXdiffAdler32( $input ) { 00024 $xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 ); 00025 $dhb = new DiffHistoryBlob; 00026 $myHash = $dhb->xdiffAdler32( $input ); 00027 $this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ), 00028 "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) ); 00029 } 00030 00031 function provideXdiffAdler32() { 00032 return array( 00033 array( '', 'Empty string' ), 00034 array( "\0", 'Null' ), 00035 array( "\0\0\0", "Several nulls" ), 00036 array( "Hello", "An ASCII string" ), 00037 array( str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" ) 00038 ); 00039 } 00040 }