From 94b196798caf0fe3298c64764810c15de90a05cf Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Mon, 14 Jan 2013 22:06:57 +0100 Subject: [PATCH] test: some Revision tests depends on PHP zlib ext Use an helper to verify whether 'zlib' is available, else will happilly skip the test. Change-Id: I43f8b20a95286b5495799d54b415f6d15894a335 --- tests/phpunit/includes/RevisionTest.php | 61 ++++++++++++------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index 9cddbe827e..cbf4bbeb5c 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -64,16 +64,14 @@ class RevisionTest extends MediaWikiTestCase { } function testGetRevisionTextGzip() { - if ( !function_exists( 'gzdeflate' ) ) { - $this->markTestSkipped( 'Gzip compression is not enabled (requires zlib).' ); - } else { - $row = new stdClass; - $row->old_flags = 'gzip'; - $row->old_text = gzdeflate( 'This is a bunch of revision text.' ); - $this->assertEquals( - 'This is a bunch of revision text.', - Revision::getRevisionText( $row ) ); - } + $this->checkPHPExtension( 'zlib' ); + + $row = new stdClass; + $row->old_flags = 'gzip'; + $row->old_text = gzdeflate( 'This is a bunch of revision text.' ); + $this->assertEquals( + 'This is a bunch of revision text.', + Revision::getRevisionText( $row ) ); } function testGetRevisionTextUtf8Native() { @@ -97,31 +95,27 @@ class RevisionTest extends MediaWikiTestCase { } function testGetRevisionTextUtf8NativeGzip() { - if ( !function_exists( 'gzdeflate' ) ) { - $this->markTestSkipped( 'Gzip compression is not enabled (requires zlib).' ); - } else { - $row = new stdClass; - $row->old_flags = 'gzip,utf-8'; - $row->old_text = gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" ); - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; - $this->assertEquals( - "Wiki est l'\xc3\xa9cole superieur !", - Revision::getRevisionText( $row ) ); - } + $this->checkPHPExtension( 'zlib' ); + + $row = new stdClass; + $row->old_flags = 'gzip,utf-8'; + $row->old_text = gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" ); + $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; + $this->assertEquals( + "Wiki est l'\xc3\xa9cole superieur !", + Revision::getRevisionText( $row ) ); } function testGetRevisionTextUtf8LegacyGzip() { - if ( !function_exists( 'gzdeflate' ) ) { - $this->markTestSkipped( 'Gzip compression is not enabled (requires zlib).' ); - } else { - $row = new stdClass; - $row->old_flags = 'gzip'; - $row->old_text = gzdeflate( "Wiki est l'\xe9cole superieur !" ); - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; - $this->assertEquals( - "Wiki est l'\xc3\xa9cole superieur !", - Revision::getRevisionText( $row ) ); - } + $this->checkPHPExtension( 'zlib' ); + + $row = new stdClass; + $row->old_flags = 'gzip'; + $row->old_text = gzdeflate( "Wiki est l'\xe9cole superieur !" ); + $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; + $this->assertEquals( + "Wiki est l'\xc3\xa9cole superieur !", + Revision::getRevisionText( $row ) ); } function testCompressRevisionTextUtf8() { @@ -139,8 +133,9 @@ class RevisionTest extends MediaWikiTestCase { } function testCompressRevisionTextUtf8Gzip() { - global $wgCompressRevisions; + $this->checkPHPExtension( 'zlib' ); + global $wgCompressRevisions; $wgCompressRevisions = true; $row = new stdClass; -- 2.20.1