rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / DiffHistoryBlobTest.php
blobc267a30e05ba99eceb392ff9fd6c41228720cf5d
1 <?php
3 class DiffHistoryBlobTest extends MediaWikiTestCase {
5 protected function setUp() {
6 parent::setUp();
8 $this->checkPHPExtension( 'hash' );
9 $this->checkPHPExtension( 'xdiff' );
11 if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
12 $this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' );
13 return;
17 /**
18 * Test for DiffHistoryBlob::xdiffAdler32()
19 * @dataProvider provideXdiffAdler32
20 * @covers DiffHistoryBlob::xdiffAdler32
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" ) );
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' ] ];
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)" ]