Commit graph

29 commits

Author SHA1 Message Date
Umherirrender
abf2ea44e8 tests: Handle dynamic created properties on test classes
- Declare missing properties
- Remove unused or avoid set of properties
- Add AllowDynamicProperties

Bug: T314099
Change-Id: Ie631894f2ffbb616f6dd09851405d681f3eb8fcd
2023-01-13 21:03:42 +00:00
Kevin Israel
0ae29bbb69 tests: Replace checkPHPExtension() with @requires annotations
PHPUnit 3.7.0 was the first version to support @requires extension. At
the time checkPHPExtension() was added in a7901801b4, MediaWiki
still supported PHPUnit 3.6.7.

MediaWiki now requires intl and xml, so I removed checks for those
extensions rather than converting them to annotations.

checkPHPExtension() is removed without deprecation; it does not appear
to have ever been used (and is not likely to be used) in MW extensions.
This is explicitly permitted under the stable interface policy. Even if
it were not, only tests are affected, and they are supposed to fail
anyway if hard deprecated code is used.

Change-Id: I45f9b4c0e120683103cead916f4d4ef58bd11530
2022-10-23 20:47:14 -04:00
Kevin Israel
72b14c9459 IcuCollation: Remove unnecessary rtrim() and unset()
- MediaWiki no longer supports PHP versions that are old enough to
  include the null terminator in the sort key, so there's no need to
  remove it using rtrim(). See T137642 for more information.
- Simplify prefix comparison by setting the initial value of $prev to
  the empty string rather than false. A PHP array key can only be an
  integer or string, so there's no other reason to check for false.
- $letterMap is unset to "Reduce memory usage before caching", which
  made sense at the time (r80443 / eaeea84b44). In 2a86b5a17a, the
  code was refactored such that $letterMap goes out of scope before we
  save to the cache, so unset() should no longer be needed.

Change-Id: Id99ab3a6a29d037912f4ab3e817dba52d2ac24e8
2022-05-21 02:02:39 -04:00
Alexander Vorwerk
decbaf4f38 phpunit: use ->getServiceContainer() in integration tests
Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
2022-01-27 22:04:16 +01:00
Tim Starling
e85d532aa2 RemoteIcuCollation
Add a collation that gets its data from a remote Shellbox instance. This
is meant as a migration helper to use during an ICU upgrade.

Add a batch method to Collation so that this can be somewhat efficient
when adding multiple categories.

Bug: T263437
Change-Id: I76610d251fb55df90c78acb9f59fd81421f876dd
2021-12-13 22:13:10 +00:00
James D. Forrester
a362b2cff0 CollationTest: Be more specific with @covers
Change-Id: I1470fbf55efb401867d1cc0e53ef1a66b9a1f21c
2021-09-08 13:46:58 +00:00
Umherirrender
5b3d3ef802 collation: Create CollationFactory service
Use ObjectFactory specs for collation classes
Avoid the language construction in the factory class,
make it a detail of the implementation of each class

Follow-Up of Ifc96f851e6091ce834dbaf0e91695c648a42169c

Bug: T286079
Change-Id: Ib581f64aec8619986fb8dd49ceee0524d59a1b84
2021-09-04 02:46:06 +02:00
jenkins-bot
89259d5a61 Merge "Inject services into Collation classes" 2021-08-24 17:53:21 +00:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
DannyS712
c90a09e70b Inject services into Collation classes
Might be worth converting Collation::singleton/::factory
to a service at some point...

Change-Id: Ifc96f851e6091ce834dbaf0e91695c648a42169c
2021-07-21 19:38:32 +00:00
DannyS712
6a93b0ca93 More misc test cleanup
* parent::setUp() should be first, and ::tearDown()
  should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
  to /unit

Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
2020-12-24 00:52:06 +00:00
Reedy
deb55049ae CollationTest: Stop checking for intl being loaded
Bug: T267669
Change-Id: I4ee41ebe09eac7864bb5b64d36ad6efb7f990b3b
2020-11-29 00:22:40 +00:00
addshore
959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00
Thiemo Kreuz
5f3a92385b Fix visibility of setUp/tearDown
Change-Id: I636be48eb9f713680abac35d46091f7b49374696
2020-06-16 21:02:05 +02:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Umherirrender
5bd311b1a2 Add public as visibility in tests folder
Add public, protected or private to function missing a visibility
Enable the tests folder for the phpcs sniff

Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
2019-10-10 21:55:37 +02:00
Legoktm
4e35134f7a Revert "Separate MediaWiki unit and integration tests"
This reverts commit 0a2b996278.

Reason for revert: Broke postgres tests.

Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
2019-06-13 23:00:08 +00:00
Máté Szabó
0a2b996278 Separate MediaWiki unit and integration tests
This changeset implements T89432 and related tickets and is based on exploration
done at the Prague Hackathon. The goal is to identify tests in MediaWiki core
that can be run without having to install & configure MediaWiki and its dependencies,
and provide a way to execute these tests via the standard phpunit entry point,
allowing for faster development and integration with existing tooling like IDEs.

The initial set of tests that met these criteria were identified using the work Amir did in
I88822667693d9e00ac3d4639c87bc24e5083e5e8. These tests were then moved into a new subdirectory
under phpunit/ and organized into a separate test suite. The environment for this suite
is set up via a PHPUnit bootstrap file without a custom entry point.

You can execute these tests by running:
$ vendor/bin/phpunit -d memory_limit=512M -c tests/phpunit/unit-tests.xml

Bug: T89432
Bug: T87781
Bug: T84948
Change-Id: Iad01033a0548afd4d2a6f2c1ef6fcc9debf72c0d
2019-06-13 22:56:31 +02:00
Bartosz Dziewoński
0313128b10 Use PHP 7 "\u{NNNN}" Unicode codepoint escapes in string literals
In cases where we're operating on text data (and not binary data),
use e.g. "\u{00A0}" to refer directly to the Unicode character
'NO-BREAK SPACE' instead of "\xc2\xa0" to specify the bytes C2h A0h
(which correspond to the UTF-8 encoding of that character). This
makes it easier to look up those mysterious sequences, as not all
are as recognizable as the no-break space.

This is not enforced by PHP, but I think we should write those in
uppercase and zero-padded to at least four characters, like the
Unicode standard does.

Note that not all "\xNN" escapes can be automatically replaced:
* We can't use Unicode escapes for binary data that is not UTF-8
  (e.g. in code converting from legacy encodings or testing the
  handling of invalid UTF-8 byte sequences).
* '\xNN' escapes in regular expressions in single-quoted strings
  are actually handled by PCRE and have to be dealt with carefully
  (those regexps should probably be changed to use the /u modifier).
* "\xNN" referring to ASCII characters ("\x7F" and lower) should
  probably be left as-is.

The replacements in this commit were done semi-manually by piping
the existing "\xNN" escapes through the following terrible Ruby
script I devised:

  chars = eval('"' + ARGV[0] + '"').force_encoding('utf-8')
  puts chars.split('').map{|char|
    '\\u{' + char.ord.to_s(16).upcase.rjust(4, '0') + '}'
  }.join('')

Change-Id: Idc3dee3a7fb5ebfaef395754d8859b18f1f8769a
2018-06-04 16:20:13 +00:00
Amir Sarabadani
5a21de8abb Remove everything related to CollationFa
This workaround was needed when ICU in production was broken
but after T189295 this is not needed anymore and we switched off
this collation from all Persian Wikis already

Bug: T139110
Change-Id: Ifad89555b6ac96a3eb36ca24b55e1f8ee57a1f05
2018-05-18 18:33:25 +02:00
jenkins-bot
1a21a63d52 Merge "Add collation for Abkhaz (ab)" 2018-01-23 18:42:29 +00:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
Kunal Mehta
a9960b53be tests: Use checkPHPExtension() instead of re-implementing it
Change-Id: I7f5e8684d556befc0aefa302187c573e7a3cff62
2017-12-25 22:06:37 +00:00
Kunal Mehta
222afabc80 Add @covers tags for Collation tests
Change-Id: I8b0623a6b716acdc9d369349fd4e306dbdc91d18
2017-12-25 21:59:01 +00:00
Bartosz Dziewoński
e94587dfbb Add collation for Abkhaz (ab)
* Adding new class AbkhazUppercaseCollation, mapped to 'uppercase-ab'.
* Extended CustomUppercaseCollation with support for sorting digraphs
  and for alphabets larger than 64 letters (up to 4096).

Bug: T183430
Change-Id: I16d44568e44d7ef5b39c38b1a6257b9fe10a34d4
2017-12-25 14:37:14 +00:00
Huji Lee
f05821e87c Do not run CollationFaTest if 'intl' is not loaded
Bug: T176040
Change-Id: I6b19bf1123d4dca5a1c8e002c0de65bab2138180
2017-09-16 16:30:18 -04:00
Brian Wolff
d16c26fd2c Unit tests for CollationFa (0bfcbd724)
Change-Id: I8286244cc1a61f34a3599c4f2e6201ba91c5e79a
2017-05-30 19:05:16 +00:00
Brian Wolff
73f5937047 Add collation for Bashkir (ba)
This is based on a numeric uppercase collation. Bashkir characters
will be remapped to the private use area for the purpose of sorting.

Bug: T162823
Change-Id: I65f1af0b57ff6ded7d464e39efd401f178a3519e
2017-05-10 04:17:46 +00:00