Merge "mediawiki.page.gallery.resize: Remove weird mw.hook call"
[lhc/web/wiklou.git] / tests / phpunit / includes / normal / CleanUpTest.php
index a495700..97b76fe 100644 (file)
@@ -3,7 +3,7 @@
  * Tests for UtfNormal::cleanUp() function.
  *
  * Copyright © 2004 Brion Vibber <brion@pobox.com>
- * http://www.mediawiki.org/
+ * https://www.mediawiki.org/
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -89,7 +89,9 @@ class CleanUpTest extends MediaWikiTestCase {
                                ( $i > UNICODE_SURROGATE_LAST && $i < 0xfffe ) ||
                                ( $i > 0xffff && $i <= UNICODE_MAX )
                        ) {
-                               if ( isset( UtfNormal::$utfCanonicalComp[$char] ) || isset( UtfNormal::$utfCanonicalDecomp[$char] ) ) {
+                               if ( isset( UtfNormal::$utfCanonicalComp[$char] )
+                                       || isset( UtfNormal::$utfCanonicalDecomp[$char] )
+                               ) {
                                        $comp = UtfNormal::NFC( $char );
                                        $this->assertEquals(
                                                bin2hex( $comp ),
@@ -108,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 );
@@ -147,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;
@@ -200,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++ ) {
@@ -243,12 +238,14 @@ class CleanUpTest extends MediaWikiTestCase {
                                                }
                                        } elseif ( $first > 0xc1 && $first < 0xe0 && $second < 0xc0 ) {
                                                $this->assertEquals(
-                                                       bin2hex( UtfNormal::NFC( $head . chr( $first ) . chr( $second ) ) . UTF8_REPLACEMENT . $tail ),
+                                                       bin2hex( UtfNormal::NFC( $head . chr( $first ) .
+                                                                       chr( $second ) ) . UTF8_REPLACEMENT . $tail ),
                                                        bin2hex( $clean ),
                                                        "Valid 2-byte $x + broken tail" );
                                        } elseif ( $second > 0xc1 && $second < 0xe0 && $third < 0xc0 ) {
                                                $this->assertEquals(
-                                                       bin2hex( $head . UTF8_REPLACEMENT . UtfNormal::NFC( chr( $second ) . chr( $third ) . $tail ) ),
+                                                       bin2hex( $head . UTF8_REPLACEMENT .
+                                                               UtfNormal::NFC( chr( $second ) . chr( $third ) . $tail ) ),
                                                        bin2hex( $clean ),
                                                        "Broken head + valid 2-byte $x" );
                                        } elseif ( ( $first > 0xfd || $second > 0xfd ) &&