Commit graph

74 commits

Author SHA1 Message Date
Antoine Musso
a03bf9e27f tests: rm duplicate code in language classes
The language classes have been using the same setUp() tearDown() to
craft a new language object. I have abstracted that code in
LanguageClassesTestCase and made all the language test classes to extend
it. The language is interpolated directly from the class name and an
object for it can be retrieved with the getLang() method.

Change-Id: Ib931336ce219edabe2c72b7e9f04c976a500723e
2012-10-29 09:40:30 +01:00
Siebrand
5abe15bb9d Merge "SI standards for time units" 2012-10-17 23:09:49 +00:00
Federico Leva
31cb4c6b03 SI standards for time units
* Use "min" rather than "m".
* Add normal spaces to avoid hassles, no wrapping here anyway.

<https://translatewiki.net/wiki/Thread:Support/Abbreviation_for_'minute'>

Change-Id: I07f7aff41a831c88b82d6ddc53914372d6aec023
2012-10-13 18:03:08 +02:00
Timo Tijhof
181c7cdc8e Clean and repair many phpunit tests (+ fix implied configuration)
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.

Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...

Either way they won't have to anymore with setMwGlobals.

Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)

(Matching the function signature with PHPUnit/Framework/TestCase.php)

Replaces:
 * public function (setUp|tearDown)\(
 * protected function $1(

 * \tfunction (setUp|tearDown)\(
 * \tprotected function $1(

 * \tfunction (data|provide)\(
 * \tpublic static function $1\(

Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.

Fixes:

TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).

MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...

FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"

HttpTest
* Added comment about:
  "PHP Fatal: Call to protected MWHttpRequest::__construct()"
  (too much unrelated code to fix in this commit)

ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
  because regardless of whether wgExternalStores is true or false
  it only uses it if it is an array.

Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-09 03:01:51 +02:00
Niklas Laxström
25c60c313a Support explicit 0 and 1 forms for plural in PHP
rails-i18n has the same, lets see if this is flexible
enough or whether we need to allow more complex expressions.

Change-Id: I50eb0c6d1c02ca936848d310de625ed1fe43d91a
2012-09-16 20:22:22 +00:00
Santhosh Thottingal
c1dff7112f For languages without plural forms, use them from fallback language
* Fixes Bug 40251 and this is alternate for I403a29e2
* This brings back the old mediawiki behavior for languages without
  defined plural rules
* Add a test for hu, which had issue as per Bug 40251

Change-Id: I345c305134a62d43c9dfedc5243981d0e77e326d
2012-09-15 12:49:44 -07:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
Tim Starling
fceb9bcb49 CLDR plural parser in PHP
Wrote a CLDR plural rule parser to replace the eval()-based one from
I58a9cdfe. It converts the infix notation of the XML files to a
sanitized RPN notation, referred to in external interfaces as the
"compiled" form. The RPN notation is cached and then executed by a
fast non-validating evaluator.

Timings for the largest rule in the XML file are ~1.2ms for
compilation and ~200us for execution.

Also:
* Lazy-load the plural rules when recache() requests them, instead of
  loading them for every request.
* Language::convertPlural() needs integer keys, and CLDR only gives
  string keys. The previous code was not mapping them so it didn't work
  at all. I just mapped them in the order they appear in the XML file,
  i.e. the first rule becomes MediaWiki's $pluralForm=0, the second
  becomes $pluralForm=1, etc. Not sure if there is a more rigorous way
  to do it.

Change-Id: I65ee788c1a8e5ee2ede2091990d86eb722749dd3
2012-08-22 12:55:50 +00:00
Santhosh Thottingal
bbbcf089db CLDR Plural rules based plural form calculation
* Use the plurals.xml of CLDR for the plural rules of languages
* Use plurals-mediawiki.xml to override or extend the rules inside MW
* Remove the convertPlural method in each LanguageXX.php
* Parse and load the xml files in LocalisationCache
* Use the CLDRPluralRuleEvaluator.php for parsing the cldr plural rules
  (This is taken from Translate extension and might require a replacement
   parser without using eval)
* Add getPluralRules() to make the CLDR plural rules available to JS.

PS3: More method documentation, cleanup

Change-Id: I58a9cdfe60c7b9027bf031c91370472054f04ae2
2012-08-16 11:45:17 +10:00
robin
c6156c4b06 Add language converter for Uzbek.
Also add tests per Hashar, based on the Serbian file but less since
Uzbek does not have "variant guessing" or custom plural rules.

Change-Id: I27da994b88fbe13cfb7df12851e704d881397666
2012-07-27 15:59:13 +02:00
robin
d039e3a7f5 fix typo in LanguageSrTest.php
Change-Id: I2e72d428ac56c94e4980ee712fdd66d381c504e0
2012-07-27 15:56:50 +02:00
Reedy
c50a8db395 Add testRomanNumerals
Up Language::romanNumeral() to work upto 10,000

Does anyone know how do do letters with an underscore ontop of them? ;)

Change-Id: Ib1b1415126af855ce5fb55f81b71534c26d84cc9
2012-07-23 12:15:19 +00:00
Reedy
88040226b6 Increase the readability of provideFormattableTimes by adding newlines
Change-Id: I7f96f44c2e18153ecfd7ea6d593229808a835a63
2012-07-18 14:51:28 +00:00
awjrichards
c29fd59775 Big oops - merged to wrong branch.
Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up"

This reverts commit ee0d3d330f
2012-06-05 22:58:54 +00:00
awjrichards
ee0d3d330f Revert to arbitrarily old point before initial remote branch creation to help clean up
Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
2012-06-02 08:43:04 -07:00
lupo
5b9731e08a (bug 36839) Use mb_check_encoding() if available.
This is not a real fix for the cause of the bug (which is a
pcre.recursion_limit that is far too low), but I do wonder
about the efficiency of using a regexp to test for valid
UTF-8 encoding. After all the regexp has to be compiled first
into a state machine.

Patch set 2: Php unit test for Language.checkTitleEncoding
Patch set 3: benchmark
Patch set 4: add benchmark for non-capturing subgroup in regexp, and
since that's faster than a capturing subgroup, use it in
checkTitleEncoding() in the regexp branch.
Patch set 5: use Tim's suggestion (once-only pattern) in the regexp
branch. Also add to benchmark.

Change-Id: I551f096921d4c9c57cbcb091b80ab5970ca86a9b
2012-05-31 14:21:36 +02:00
Aaron Schulz
e515d15f3a Revert "tests to compare En, Qqq and messages.inc" due to test failures caused by extension dependencies.
This reverts commit 9a2aae3107
2012-04-20 21:12:08 +00:00
Antoine Musso
9a2aae3107 tests to compare En, Qqq and messages.inc
Change-Id: I7ebeeea703e955c628b57548eb023fa3eb5a2f52
2012-04-20 18:08:33 +02:00
Jeroen De Dauw
77d2f16760 duration formatter, makes time in sec easy to read
The Language::formatDuration() method introduced by this patch let us
easily render an amount of seconds for easier human reading.

 $ maintenance/eval.php
 > var_dump( $wgLang->formatDuration( 1000 );
 string(25) "16 minutes and 40 seconds"

Also ran rebuildLanguage.php on Siebrands request

Change-Id: If287fb10e897d3d2374cf6eeae3bc5be00cdfc01
2012-04-13 13:54:04 +02:00
Nikola Smolenski
598d96d24c - Fix bug 35076
- More tests, test comments

(This is the same as r114049.)

Patch set 2: Squash in missed test file

Change-Id: Icaf7fdd11499c64c42b46e442c158f22309345a7
2012-04-10 13:39:46 -04:00
Sam Reed
c27fbf5330 Trim trailing whitespace
Add/improve documentation

Explicitly define a few variables

Change-Id: If0017770a0a47f8f6be178b5bde8ae6691f74b6a
2012-03-21 15:47:05 -07:00
Roan Kattouw
311200ee2c Revert r114067, r114071, r114075, r114079, r114081, r114082, r114084, r114086, r114088, r114089, r114101, r114118, r114137, r114147, r114164, r114172, r114175, r114180, r114208, r114209, r114215, r114219, r114226, r114321, r114322.
This reverts the SpecialCachedPage and formatDuration sagas, with some collateral damage here and there. All of these revisions are tagged with 'gerritmigration' and will be resubmitted into Gerrit after the Gerrit switchover. See also http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html
2012-03-20 23:03:59 +00:00
Jeroen De Dauw
d42c2f4d7a added some tests using the intervals param 2012-03-20 22:48:28 +00:00
Jeroen De Dauw
bc9cca92ed follow up to r114084, add tests for stuff w/ multiple units 2012-03-17 23:26:37 +00:00
Sam Reed
a2dc33a5a3 Trim trailing whitespace
Add/improve documentation

Explicitly define a few variables
2012-03-17 22:52:54 +00:00
Sam Reed
e8ab5f6466 Noralise a few of the magic numbers used in r114084 2012-03-17 22:47:02 +00:00
Sam Reed
5736aa4132 Unit tests for r114067 2012-03-17 22:39:38 +00:00
Niklas Laxström
17c9d085c8 Whitespace cleanup 2012-02-02 11:14:26 +00:00
Antoine Musso
fc6bc233be Fix doxygen docs before REL1_19 branching 2012-02-01 20:53:38 +00:00
Amir E. Aharoni
5b7484cfe3 Added tests for plural, same as Russian. 2012-02-01 15:59:26 +00:00
Amir E. Aharoni
655dbec995 Fixed plural rules for Romanian / Moldovan according to CLDR. Added tests for Romanian and fixed tests for Moldovan. 2012-02-01 15:37:40 +00:00
Amir E. Aharoni
05070ac01c Adding plural tests for more languages. 2012-02-01 04:53:55 +00:00
Amir E. Aharoni
adf5248562 Testing the case when dual is not provided. 2012-01-31 14:42:38 +00:00
Amir E. Aharoni
b8cc074d88 Adding tests for plural in Hebrew. 2012-01-31 13:49:36 +00:00
Santhosh Thottingal
4682c16bc3 Followup r110279. $count % 100 in 1..19 is few form.
In r110279, it was 2..19.
2012-01-30 13:51:04 +00:00
Santhosh Thottingal
6fd023b9c5 phpunit testcases for lv, mg,and ml languages to test Plural 2012-01-30 11:40:28 +00:00
Santhosh Thottingal
4f2eaa8d80 For Moldavian $count % 100 < 20 is not 'few' form, but $count % 100 in 1..19 is few form.
This was causing 200 considered as 'few' form, while it should be 'other' form as per
http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#mo

Add phpunit test cases for LanguageMo plural rules
2012-01-30 11:34:36 +00:00
Santhosh Thottingal
17eb54b617 Add PHPUnit tests for plural rules. For languages cs, cu, cy, dsb, fr, ga, gd, gv, hr, hsb, hy, ksh, ln 2012-01-27 11:13:06 +00:00
Santhosh Thottingal
97c25c61aa phpunit testcases on the plural rules for am, ar, be, be_tarask, bh, bs and hi languages 2012-01-27 06:01:43 +00:00
Santhosh Thottingal
c652c3ba7f Use dataprovider for testcases. 2012-01-27 05:58:46 +00:00
Antoine Musso
de46c34467 fix '999bps' test message
follow r108413
2012-01-09 19:38:38 +00:00
Chad Horohoe
34244403d7 Followup r108403, use data providers 2012-01-09 16:51:34 +00:00
Antoine Musso
655bef2ae1 test format bitrate with '999' 2012-01-09 14:01:51 +00:00
Santhosh Thottingal
266c6e8515 Cleanup the convertPLural method for Lithuanian(lt)
Add phpunit test cases.
2012-01-09 12:46:53 +00:00
Santhosh Thottingal
ad13e54f84 Address an edge case - input being null. Add test cases. 2012-01-04 08:56:36 +00:00
Brian Wolff
9faf44cf58 Follow-up r107806 - More extensive tests for Language::sprintfDate. Including test to make sure not affected by php timezone.
Also adds a small test for converting numerals (formatNum) in Arabic.
2012-01-02 10:41:58 +00:00
Sam Reed
cea7c863e5 Prevent undefined offset when formatBitrate is given a significantly large enough number (10^27)
> echo $wgLang->formatBitrate( pow( 10, 27 ) );
PHP Notice:  Undefined offset: 9 in /home/reedy/mediawiki/trunk/phase3/languages/Language.php on line 3827
PHP Stack trace:
PHP   1. {main}() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:0
PHP   2. eval() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:82
PHP   3. Language->formatBitrate() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php(82) : eval()'d code:1

Notice: Undefined offset: 9 in /home/reedy/mediawiki/trunk/phase3/languages/Language.php on line 3827

Call Stack:
    0.0006     650736   1. {main}() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:0
   61.6539   21593432   2. eval(''echo $wgLang->formatBitrate( pow( 10, 27 ) );;'') /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:82
   61.6540   21593512   3. Language->formatBitrate() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php(82) : eval()'d code:1

1bps
2011-12-31 22:53:50 +00:00
Sam Reed
450ad142b9 Fixup and add rest of tests
Followup r107734

bug 33014 done too?
2011-12-31 22:30:31 +00:00
Sam Reed
f2c6e0afb6 Shut up Jenkins!
Ping r107734
2011-12-31 21:01:30 +00:00
Sam Reed
ef30bc81d0 Start adding tests for Language::formatBitrate()
1Gbps commented out as for some reason it's returning 1.1Gbps...
2011-12-31 20:30:06 +00:00