MediaWiki
REL1_24
|
00001 <?php 00002 00003 class DiffHistoryBlobTest extends MediaWikiTestCase { 00004 00005 protected function setUp() { 00006 parent::setUp(); 00007 00008 $this->checkPHPExtension( 'hash' ); 00009 $this->checkPHPExtension( 'xdiff' ); 00010 00011 if ( !function_exists( 'xdiff_string_rabdiff' ) ) { 00012 $this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' ); 00013 00014 return; 00015 } 00016 } 00017 00023 public 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 public static 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 }