MediaWiki REL1_31
DiffHistoryBlobTest.php
Go to the documentation of this file.
1<?php
2
4
5 protected function setUp() {
6 parent::setUp();
7
8 $this->checkPHPExtension( 'hash' );
9 $this->checkPHPExtension( 'xdiff' );
10
11 if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
12 $this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' );
13 return;
14 }
15 }
16
22 public function testXdiffAdler32( $input ) {
23 $xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 );
24 $dhb = new DiffHistoryBlob;
25 $myHash = $dhb->xdiffAdler32( $input );
26 $this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ),
27 "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) );
28 }
29
30 public function provideXdiffAdler32() {
31 // Hack non-empty early return since PHPUnit expands this provider before running
32 // the setUp() which marks the test as skipped.
33 if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
34 return [ [ '', 'Empty string' ] ];
35 }
36
37 return [
38 [ '', 'Empty string' ],
39 [ "\0", 'Null' ],
40 [ "\0\0\0", "Several nulls" ],
41 [ "Hello", "An ASCII string" ],
42 [ str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" ]
43 ];
44 }
45}
testXdiffAdler32( $input)
Test for DiffHistoryBlob::xdiffAdler32() provideXdiffAdler32 DiffHistoryBlob::xdiffAdler32.
Diff-based history compression Requires xdiff 1.5+ and zlib.
xdiffAdler32( $s)
Compute a binary "Adler-32" checksum as defined by LibXDiff, i.e.
checkPHPExtension( $extName)
Check if $extName is a loaded PHP extension, will skip the test whenever it is not loaded.
if(is_array($mode)) switch( $mode) $input