3 class DiffHistoryBlobTest
extends MediaWikiTestCase
{
4 protected function setUp() {
5 if ( !extension_loaded( 'xdiff' ) ) {
6 $this->markTestSkipped( 'The xdiff extension is not available' );
10 if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
11 $this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' );
15 if ( !extension_loaded( 'hash' ) && !extension_loaded( 'mhash' ) ) {
16 $this->markTestSkipped( 'Neither the hash nor mhash extension is available' );
24 * Test for DiffHistoryBlob::xdiffAdler32()
25 * @dataProvider provideXdiffAdler32
27 function testXdiffAdler32( $input ) {
28 $xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 );
29 $dhb = new DiffHistoryBlob
;
30 $myHash = $dhb->xdiffAdler32( $input );
31 $this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ),
32 "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) );
35 public static function provideXdiffAdler32() {
37 array( '', 'Empty string' ),
38 array( "\0", 'Null' ),
39 array( "\0\0\0", "Several nulls" ),
40 array( "Hello", "An ASCII string" ),
41 array( str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" )