test: coverage recording now needs to be explicit
[mediawiki.git] / tests / phpunit / includes / DiffHistoryBlobTest.php
blob53f33d9d27ca1bb2261ed16ed274c52e2bfd9c47
1 <?php
3 class DiffHistoryBlobTest extends MediaWikiTestCase {
4 protected function setUp() {
5 if ( !extension_loaded( 'xdiff' ) ) {
6 $this->markTestSkipped( 'The xdiff extension is not available' );
8 return;
10 if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
11 $this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' );
13 return;
15 if ( !extension_loaded( 'hash' ) && !extension_loaded( 'mhash' ) ) {
16 $this->markTestSkipped( 'Neither the hash nor mhash extension is available' );
18 return;
20 parent::setUp();
23 /**
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() {
36 return array(
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)" )