From: Chad Horohoe Date: Mon, 7 Jul 2014 23:22:00 +0000 (-0700) Subject: Convert CleanUpTest to use data providers X-Git-Tag: 1.31.0-rc.0~15064^2 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=9413a99ec26a3bf47dd03e5b58eb3c10440ae19d;p=lhc%2Fweb%2Fwiklou.git Convert CleanUpTest to use data providers These tests are pretty slow, and by only doing one data set per test it extends the time they're allowed to run Change-Id: Ia238a607ca94b96d02116ba6e3dc293c1c82a5a9 --- diff --git a/tests/phpunit/includes/normal/CleanUpTest.php b/tests/phpunit/includes/normal/CleanUpTest.php index dff31c1e5a..97b76fe992 100644 --- a/tests/phpunit/includes/normal/CleanUpTest.php +++ b/tests/phpunit/includes/normal/CleanUpTest.php @@ -110,15 +110,20 @@ class CleanUpTest extends MediaWikiTestCase { } /** @todo document */ - public function testAllBytes() { - $this->doTestBytes( '', '' ); - $this->doTestBytes( 'x', '' ); - $this->doTestBytes( '', 'x' ); - $this->doTestBytes( 'x', 'x' ); + public function provideAllBytes() { + return array( + array( '', '' ), + array( 'x', '' ), + array( '', 'x' ), + array( 'x', 'x' ), + ); } - /** @todo document */ - function doTestBytes( $head, $tail ) { + /** + * @dataProvider provideAllBytes + * @todo document + */ + function testBytes( $head, $tail ) { for ( $i = 0x0; $i < 256; $i++ ) { $char = $head . chr( $i ) . $tail; $clean = UtfNormal::cleanUp( $char ); @@ -149,18 +154,11 @@ class CleanUpTest extends MediaWikiTestCase { } } - /** @todo document */ - public function testDoubleBytes() { - $this->doTestDoubleBytes( '', '' ); - $this->doTestDoubleBytes( 'x', '' ); - $this->doTestDoubleBytes( '', 'x' ); - $this->doTestDoubleBytes( 'x', 'x' ); - } - /** + * @dataProvider provideAllBytes * @todo document */ - function doTestDoubleBytes( $head, $tail ) { + function testDoubleBytes( $head, $tail ) { for ( $first = 0xc0; $first < 0x100; $first += 2 ) { for ( $second = 0x80; $second < 0x100; $second += 2 ) { $char = $head . chr( $first ) . chr( $second ) . $tail; @@ -202,16 +200,11 @@ class CleanUpTest extends MediaWikiTestCase { } } - /** @todo document */ - public function testTripleBytes() { - $this->doTestTripleBytes( '', '' ); - $this->doTestTripleBytes( 'x', '' ); - $this->doTestTripleBytes( '', 'x' ); - $this->doTestTripleBytes( 'x', 'x' ); - } - - /** @todo document */ - function doTestTripleBytes( $head, $tail ) { + /** + * @dataProvider provideAllBytes + * @todo document + */ + function testTripleBytes( $head, $tail ) { for ( $first = 0xc0; $first < 0x100; $first += 2 ) { for ( $second = 0x80; $second < 0x100; $second += 2 ) { #for( $third = 0x80; $third < 0x100; $third++ ) {