MediaWiki REL1_33
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
21 public function testXdiffAdler32( $input ) {
22 $xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 );
23 $dhb = new DiffHistoryBlob;
24 $myHash = $dhb->xdiffAdler32( $input );
25 $this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ),
26 "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) );
27 }
28
29 public function provideXdiffAdler32() {
30 // Hack non-empty early return since PHPUnit expands this provider before running
31 // the setUp() which marks the test as skipped.
32 if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
33 return [ [ '', 'Empty string' ] ];
34 }
35
36 return [
37 [ '', 'Empty string' ],
38 [ "\0", 'Null' ],
39 [ "\0\0\0", "Several nulls" ],
40 [ "Hello", "An ASCII string" ],
41 [ str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" ]
42 ];
43 }
44}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
testXdiffAdler32( $input)
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