aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/parser/MagicWordArrayTest.php
Commit message (Collapse)AuthorAgeFilesLines
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-3/+3
| | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* Move Language and friends into Language namespaceJames D. Forrester2024-08-101-1/+1
| | | | | Bug: T353458 Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
* Add __debugInfo to MediaWikiTestCaseTrait::createNoOpMockthiemowmde2024-04-101-1/+1
| | | | | | | | | | | I keep running into this whenever I use createNoOpMock. I think it's XDebug that's calling this method, and then PHPUnit flooding the console with extremely long stack traces. We pretty much never do anything custom with this method: https://codesearch.wmcloud.org/search/?q=__debugInfo&files=%5C.php%24 Change-Id: Ib2ab86fb243555f5e4449ed72cb032cb465e415d
* tests: Add or fix Parser test namespacesReedy2024-02-161-0/+4
| | | | | Bug: T357823 Change-Id: I1d07ff559f4607ba98bc834a1432e014f3ebdd35
* tests: Use namespaced classesUmherirrender2023-12-111-0/+3
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statements and changes to docs done manually Change-Id: Ib326ae1e5c8409a98398c721e8b8ce42c73bd012
* Add PHPUnit test for MagicWord classthiemowmde2023-11-211-0/+2
| | | | | | | This is much more trivial than e.g. MagicWordArray. Still deserves it's own test, in my opinion. Change-Id: I1c19c9c1e51fd210a3827a2200153686f7205eee
* Merge "Make MagicWordArray not fail on old revs with broken UTF-8"jenkins-bot2023-10-271-0/+1
|\
| * Make MagicWordArray not fail on old revs with broken UTF-8thiemowmde2023-10-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Garbage in, garbage out. When the wikitext is broken, it's still helpful if the user can see the broken wikitext. Even if it's not fully parsed. It's not the job of this class to fix broken UTF-8. The worst thing that can happen is that the wikitext contains some unparsed magic words. However, this is really only relevant for very old revisions (20 years old, see T321234). It's very normal that old revisions can't be 100% parsed any more, most notably because of deleted templates. This here is not much different. Bug: T321234 Change-Id: I0ce40f6575668847ef309599ee32de52190ab212
* | parser: Replace exception with /J modifier in MagicWordArraythiemowmde2023-10-271-2/+11
|/ | | | | | | | | | | | | | | | | | | | | | | | | The extra code that scans for duplicates and throws an exception was added via I95dea67 in 2017. I'm not entrirely sure why. This should be impossible in all relevant real-world scenarios. Maybe it happened in a local dev scenario? Even if, duplicates are harmless. Let me explain: The only way a duplicate can end here is when the same magic word is added twice to the $this->names array. The only thing that happens then is that the resulting regex contains one of the sub-patterns twice. It doesn't matter which one matches. We know these subpatterns are identical. Unfortunately the PCRE compiler doesn't know and assumes duplicate names are a problem. We have two options to fix this: Strip duplicates in $this->names with array_unique() or tell the PCRE compiler that duplicates are ok with the /J modifier. I would like to avoid the extra, potentially expensive array_unique() because, as said, duplicates never happen in real-world scenarios. The /J modifier is supported since PHP 7.2. Change-Id: I5f113abdbb44354fcc01be7f36fbc7d07f75876c
* parser: deprecate unused MagicWord::getId, improve docs and testsTimo Tijhof2023-10-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * MagicWord::getId was added in r24808 (164bb322f2) but never used. At the time, access modifiers like 'private' were not yet in use. Deprecate the method with warnings, for removal in a future release. * Fix zero coverage for MagicWord, due to constructor being internal, this is only intended to be created via array and factory classes. Let their tests cover this class. * Remove redundant file-level description and ensure the class desc and ingroup tag are on the class block instead. Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+message:ingroup * Mark constructor `@internal` (was already implied by stable interface policy), and explain where to get the object instead. * Mark load() `@internal`. Method was introduced in 1.1 when the class (and PHP) did not yet use visibility modifiers for private methods. The only way to get an instance of MagicWord (MagicWordFactory::get) already calls load(), the method is not a no-op if called a second time, and (fortunately) there exist no callers to this outside this class that I could find. * MagicWordArray::getBaseRegex was marked as internal in change I17f1b7207db8d2203c904508f3ab8a64b68736a8. Change-Id: I4084f858bb356029c142fbdb699f91cf0d6ec56f
* parser: Add more complex MagicWordArray test casesthiemowmde2023-10-191-3/+96
| | | | | | | The tests we added before create only MagicWordArray objects with a single magic word. Here we are testing actual arrays of magic words. Change-Id: I5880cca2a1e1ecf7018edd22c11229da5d5baffd
* Add missing PHPUnit test for MagicWordArray classthiemowmde2023-10-061-0/+122
I think this code is effectively covered by the parser tests that use magic words. Still it worried me more and more to make changes to this code without dedicated unit tests. Change-Id: Id72e1d7ef4736e4d0672798d720465648d91b3ba