@covers tags for inclues/*Test
[lhc/web/wiklou.git] / tests / phpunit / includes / DiffHistoryBlobTest.php
1 <?php
2
3 class DiffHistoryBlobTest extends MediaWikiTestCase {
4 protected function setUp() {
5 if ( !extension_loaded( 'xdiff' ) ) {
6 $this->markTestSkipped( 'The xdiff extension is not available' );
7
8 return;
9 }
10 if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
11 $this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' );
12
13 return;
14 }
15 if ( !extension_loaded( 'hash' ) ) {
16 $this->markTestSkipped( 'The hash extension is not available' );
17
18 return;
19 }
20 parent::setUp();
21 }
22
23 /**
24 * Test for DiffHistoryBlob::xdiffAdler32()
25 * @dataProvider provideXdiffAdler32
26 * @covers DiffHistoryBlob::xdiffAdler32
27 */
28 public function testXdiffAdler32( $input ) {
29 $xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 );
30 $dhb = new DiffHistoryBlob;
31 $myHash = $dhb->xdiffAdler32( $input );
32 $this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ),
33 "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) );
34 }
35
36 public static function provideXdiffAdler32() {
37 return array(
38 array( '', 'Empty string' ),
39 array( "\0", 'Null' ),
40 array( "\0\0\0", "Several nulls" ),
41 array( "Hello", "An ASCII string" ),
42 array( str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" )
43 );
44 }
45 }