Commit graph

103 commits

Author SHA1 Message Date
Amir E. Aharoni
6848470450 Wrote proper skip reason
Change-Id: I80627dab1db279ee0b9d27ec929671bc458558b7
2013-02-18 23:58:43 +05:30
Siebrand Mazeland
feb9419a51 Update formatting
7 of n.

Change-Id: I07687a4381f29fd9fc73666e460f25769ed54092
2013-02-15 12:53:41 +00:00
Santhosh Thottingal
ff3df41363 (Bug 44987) Allow n=form in plural syntax
phpunit testcases included

Change-Id: I7be51e24a0b953dcd1f9cb21f54af9b4127a5cdb
2013-02-14 15:32:46 +05:30
jenkins-bot
75ef257c29 Merge "pass codesniffer on tests/" 2013-01-28 23:47:45 +00:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
Amir E. Aharoni
fee2b0045e (bug 41476) Implement Language::isKnownLanguageTag()
Change-Id: I130d8e0b397323e21058cf46510440da066fa12b
2013-01-28 09:10:11 +00:00
Amir E. Aharoni
4a25561370 (bug 41478) Implement Language::isWellFormedLanguageTag()
Change-Id: Ief5643e9a7d3883d6d131503087aca15207b0a44
2013-01-25 13:05:13 +02:00
Niklas Laxström
0e08362b40 (bug 41477) Add Language::isSupportedLanguage
Change-Id: If48c23fd580133bf78c19d4a0e8e00e74a639fa1
2013-01-21 08:47:53 +00:00
Yuri Astrakhan
8551f29ae2 Language::listToText cleanup with unit test
Change-Id: If88ab7da07e336fc5f6264c7d6b4f6ce542f99c9
2013-01-07 20:02:56 +00:00
IAlex
83aafac2b0 Merge "Do correct average year length arithmetic." 2012-12-29 19:18:05 +00:00
Liangent
70e300e270 Do correct average year length arithmetic.
We have ( 24 * 3 + 25 ) leap years in total every 400 years in the
Gregorian calendar.

Change-Id: I2ad9036473afa914ecf8ddcf99ce27e316178f76
2012-12-29 22:15:36 +08:00
Kaldari
5e13ecaa9b Fixing some variable names and comment formatting - no functional changes
Changing $_ to $number; changing $numberpart to $integerpart

Also adding a unit test for the commafy function

Change-Id: Iaf6dd027bd70722d316d1a9c10c9913fff8300ce
2012-12-24 07:47:21 +00:00
Liangent
c50cd60069 Always return something nice in Language::translateBlockExpiry()
Change-Id: I30a1950df5ae018cb9124392dc8d6e99ca3b98b8
2012-11-21 00:01:35 +08:00
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
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
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
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
Antoine Musso
de46c34467 fix '999bps' test message
follow r108413
2012-01-09 19:38:38 +00:00
Antoine Musso
655bef2ae1 test format bitrate with '999' 2012-01-09 14:01:51 +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
Sam Reed
3b06d6fbc9 Followup r106791, r107692 and bug 33014
Make Language::formatNum() handle  TB through YB

Rewrote code to be simpler and less indenty

Though, something like formatBitrate might be be better in future... We'll see!
2011-12-31 20:20:15 +00:00
Sam Reed
fa9efe332d Add some tests for formatSize 2011-12-31 02:13:59 +00:00
Brion Vibber
f1ce2ce952 * (bug 32461) Add two-digit short form year for Persian calendar ({{#time:xiy}})
Patch by Platonides https://bugzilla.wikimedia.org/attachment.cgi?id=9490&action=diff
Plus test case. Note the test case uses Latin-style digits because it's testing English; in fa you'd get the persian digits as in the examples on the bug.
2011-12-14 00:32:56 +00:00
Roan Kattouw
0e52aee608 Per CR on r97962, introduce an array parameter for formatTimePeriod() rather than adding more boolean params. 2011-09-24 15:44:43 +00:00
Roan Kattouw
e5a9b38294 Make Language::formatTimePeriod() more flexible so it can produce stuff like '3 hours ago'.
* Add a $noAbbrevs parameter that causes the 'seconds', 'minutes', etc. messages to be used instead of the 'seconds-abbrev', 'minutes-abbrev', etc. messages
* Add the 'seconds', 'minutes', 'hours' and 'days' messages
* Change the -abbrev messages to take a parameter rather than having the number prepended to them. This is for compatibility with 'seconds' et al, which need the parameter for {{PLURAL:}}. It also generally makes more sense. This does BREAK the messages in non-English languages that override them; Niklas told me to leave this alone and ping the TranslateWiki folks
* Introduce an 'ago' message for '$1 ago'. Not currently used in core, but I want to use it in an extension and it seemed stupid not to have such a thing in core.
* Refactor the function to use message objects and pass the number as a parameter
* Add tests! They exposed a subtle bug in my first iteration; all hail tests!
2011-09-23 22:17:10 +00:00
Roan Kattouw
e9e287d1de Rewrite testFormatTimePeriod() with a data provider 2011-09-23 22:02:36 +00:00
Roan Kattouw
6a8cb49f82 Per CR on r90915, fix the description of one of the assertions 2011-08-20 09:59:00 +00:00
Antoine Musso
854b84ef42 enhance tests name (for --testdox option) 2011-07-03 18:09:30 +00:00
Aaron Schulz
bc6aaa19ed * Added truncate() & truncateHTML() tests
* Some fixes/changes to truncateHTML() based on tests
** Something like "<span>hello</span>" ends up as "<span>...</span>" instead of just "..." for relevant cases)
** If we get something like "<span></span" in, just return it back instead of ""
* Renamed $dispLength -> $dispLen in truncateHTML()
2011-06-28 01:09:02 +00:00
Aaron Schulz
ac5f7b3127 Added formatTimePeriod() tests for r90385 and made some fixes 2011-06-27 22:32:58 +00:00
Chad Horohoe
db833df9dc Remove useless bootstrap inclusions 2011-06-03 04:25:21 +00:00
Antoine Musso
0330258617 Underscore are not valid in language code
* Reject underscore in validation
* Still case unsensitive
* Corrected tests using underscore


Follow up r83160 which was a follow up of r82927 (language code validation)
2011-03-04 17:16:09 +00:00
Antoine Musso
93348f39d4 Fix language code validation (from r82927)
A language code may contains the underscore character (be_tarask)
and might as well be upper case (FR).

Add tests for Language::isValidBuiltInCode() against some language codes
2011-03-03 19:13:57 +00:00
Chad Horohoe
5f528203aa Rename MediaWikiTestSetup to MediaWikiTestCase: this is going to be the base class for all unit tests from now on 2010-12-28 17:45:33 +00:00
Chad Horohoe
23f69f10ed Per wikitech-l discussion: Move tests from maintenance/tests/ to tests/. They're not strictly maintenance scripts, and some people want to do a selective checkout that doesn't include the tests. There's still debate on whether we should include these in the release downloads, but we had a pretty firm consensus to move this. 2010-12-14 16:26:35 +00:00