Unit tests for CollationFa (0bfcbd724)
authorBrian Wolff <bawolff+wn@gmail.com>
Mon, 29 May 2017 16:22:33 +0000 (16:22 +0000)
committerBrian Wolff <bawolff+wn@gmail.com>
Tue, 30 May 2017 19:05:16 +0000 (19:05 +0000)
Change-Id: I8286244cc1a61f34a3599c4f2e6201ba91c5e79a

tests/phpunit/includes/collation/CollationFaTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/includes/collation/CollationFaTest.php b/tests/phpunit/includes/collation/CollationFaTest.php
new file mode 100644 (file)
index 0000000..f230197
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+class CollationFaTest extends MediaWikiTestCase {
+
+       /*
+        * The ordering is a weird hack designed to work only with a very
+        * specific version of libicu, and as such can't really be unit tested
+        * against a random version of libicu
+        */
+
+       /**
+        * @dataProvider provideGetFirstLetter
+        */
+       public function testGetFirstLetter( $letter, $str ) {
+               $coll = new CollationFa;
+               $this->assertEquals( $letter, $coll->getFirstLetter( $str ), $str );
+       }
+
+       public function provideGetFirstLetter() {
+               return [
+                       [
+                               '۷',
+                               '۷'
+                       ],
+                       [
+                               'ا',
+                               'ا'
+                       ],
+                       [
+                               'ا',
+                               'ایران'
+                       ],
+                       [
+                               'ب',
+                               'برلین'
+                       ],
+                       [
+                               'و',
+                               'واو'
+                       ],
+                       [ "\xd8\xa7", "\xd8\xa7Foo" ],
+                       [ "\xd9\x88", "\xd9\x88Foo" ],
+                       [ "\xd9\xb2", "\xd9\xb2Foo" ],
+                       [ "\xd9\xb3", "\xd9\xb3Foo" ],
+               ];
+       }
+}