Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / DiffHistoryBlobTest.php
blobe28a92cf43c1e46e9e753c0d7ccf0091a1767ea9
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' );
14 return;
18 /**
19 * Test for DiffHistoryBlob::xdiffAdler32()
20 * @dataProvider provideXdiffAdler32
21 * @covers DiffHistoryBlob::xdiffAdler32
23 public function testXdiffAdler32( $input ) {
24 $xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 );
25 $dhb = new DiffHistoryBlob;
26 $myHash = $dhb->xdiffAdler32( $input );
27 $this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ),
28 "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) );
31 public static function provideXdiffAdler32() {
32 return array(
33 array( '', 'Empty string' ),
34 array( "\0", 'Null' ),
35 array( "\0\0\0", "Several nulls" ),
36 array( "Hello", "An ASCII string" ),
37 array( str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" )