aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/GlobalFunctions
Commit message (Collapse)AuthorAgeFilesLines
...
* Coding style: Auto-fix MediaWiki.Usage.PHPUnit*James D. Forrester2020-01-101-1/+1
| | | | Change-Id: I86fc55a4fc8ceafe368692173211bbcd6d8581d7
* Remove `wfGlobalCacheKey` global function, deprecated and unusedDannyS7122020-01-081-12/+0
| | | | | Bug: T241350 Change-Id: Icdb2512f3ec10bc4b26a6faa08f14d7603176c82
* Fixes for PHPUnit 8 compat in DB suiteDaimona Eaytoy2019-12-151-1/+2
| | | | | | | Once again, this fixes all issues aside from assertArraySubset. Bug: T192167 Change-Id: I45c91dc1cf23f04140576dc66233558bb6021324
* Tests for an old PHP bug in parse_urlBrad Jorsch2019-12-131-0/+40
| | | | | | | | | | It would get confused by URLs with a query portion but no path. We no longer support any vulnerable versions of PHP, but it would still be useful to have these tests. Bug: T212067 Change-Id: I15c15161a668115d68eb2e2f8004826b47148fc1
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-303-3/+3
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* tests: Replace PHPUnit's loose assertEquals(false) with assertFalse()Thiemo Kreuz2019-10-041-1/+1
| | | | | | | | | | | | | assertEquals( false, … ) still succeeds when the actual value is 0, null, an empty string, even an empty array. All these should be reported as a failure, I would argue. Note this patch previously also touched assertSame( false ). I reverted these. The only benefit would have been consistency within this codebase, but there is no strict reason to prefer one over the other. assertFalse() and assertSame( false ) are functionally identical. Change-Id: Ic5f1c7d504e7249002d3184520012e03313137b4
* Remove unneeded overrideMwServices/resetServicesAryeh Gregor2019-08-292-7/+0
| | | | Change-Id: If6cbdec05b8f310ef3a0b4649aaa16d9fb80a047
* Call resetServices() when setting globals in testsAryeh Gregor2019-08-291-4/+6
| | | | | | | | | | | Now that resetServices() will preserve (but reset) customized services, it should be reasonably safe to call it every time globals are changed, and much more effective than relying on tests to call it every time themselves. Depends-On: Iab8ea3a61bbc6803805d855ef23c071067646f71 Depends-On: I00e35ecea6a27468674b2a6e7d9d9eb6518e3bd5 Change-Id: Ie7a89f6ed7d52a0bc01672019ff92e7ee105a1f3
* BadFileLookup to replace wfIsBadImageAryeh Gregor2019-08-211-59/+6
| | | | | | | | | | | | | | | | | | | | | I think this probably shouldn't be directly in the MediaWiki namespace, but I don't know where is a better place to put it. In order to avoid gratuitous use of TitleFormatter, I changed the cache format -- the old implementation used getPrefixedDBkey() and I switched to an ns/dbkey pair. I also changed the cache keys to use SHA1 instead of MD5, by Daniel's request. The previous implementation cached the parsed blacklist for one minute without invalidation, so it could return slightly stale results, but it didn't retrieve the bad image list message on a cache hit. The new implementation unconditionally retrieves the bad image list message, but uses a hash of it in the cache key and caches for one day. The new behavior happens to be more cleanly implementable in a service. Bug: T200882 Bug: T139216 Change-Id: I69fed1b1f3cfc1aa149e0739780e67f6de01609d
* Rewrite integration test for wfIsBadImage()Aryeh Gregor2019-08-211-15/+95
| | | | | | | In preparation for rewriting as a service. I didn't figure out how to get file redirects to be tested. Change-Id: Ic6669a19a13025744036f9f8adc4d1a25490fb42
* GlobalFunctions: Hard deprecate `wfGlobalCacheKey()` functionDerick Alangi2019-07-181-0/+1
| | | | | | | | | | | | | | The only extension that used this was ConfirmEdit and it has been cleaned up with Ia7b276ee65fdf58c, so is it time we hard deprecate it? Usage ===== https://codesearch.wmflabs.org/search/?q=%5CbwfGlobalCacheKey%5Cb&i=nope&files=&repos= Depends-On: Ia7b276ee65fdf58c4fc0859563930528d44a03ca Change-Id: I3fda797c64ec62df4454625ad1a3bf89f6a88246
* Load GlobalFunctions.php to tests/phpunit/bootstrap.phpAmir Sarabadani2019-07-1411-906/+0
| | | | | | | That mostly enables testing global functions Bug: T87781 Change-Id: Ib42c56a67926ebcdba53f4c6c54a5bff98cb77a3
* Skip ::testT69870() under Windows systemRazeSoldier2019-06-221-5/+8
| | | | | | | | | | | | Anonymous pipe under Windows does not support asynchronous read and write[1], and the default buffer is too small (~4K), the test will definitely block it. Before T69870, anonymous pipe for Windows can no longer hold more than 4K of data. [1] https://docs.microsoft.com/en-us/windows/desktop/ipc/anonymous-pipe-operations Bug: T209159 Change-Id: Ie9de36b1e6b68db95c35a0044c5b0d86c0050d33
* Use [...] instead of array(...) in PHP comments and documentationFomafix2019-06-171-1/+1
| | | | Change-Id: I0c83783051bf35fe785bc01644eeb2946902b6b2
* Revert "Separate MediaWiki unit and integration tests"Legoktm2019-06-1312-0/+926
| | | | | | | | This reverts commit 0a2b996278e57a8b8c5377cd3a3eaa54f993d4a9. Reason for revert: Broke postgres tests. Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
* Separate MediaWiki unit and integration testsMáté Szabó2019-06-1312-926/+0
| | | | | | | | | | | | | | | | | | | | | 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
* tests: Remove use of wfRandomString() for test fixturesTimo Tijhof2019-05-061-6/+2
| | | | | | | | | | | | | | | | | | | | | | | This reduces confidence in the test. There is no guruantee that it won't return the same value twice during the duration of a full PHPUnit run of all test suites, whether twice in a row or 20 minutes apart. For a test that needs a string of any kind, use an explicit, consinstent and cheap literal value. For a test that specifically needs some kind of uniqueness compared to something else within the same test case, do so explicitly. Tests that require something globally unique (for some undefined/vague definition of "global") were not found, and should not exist anyway. Also, in libs/objectcache tests, fix order of parameters in some assertions (expected first, then actual), and use assertFalse/assertSame instead of assertEqual for cases where false is expected to remove tolerance of other loosely equal values. Change-Id: Ifc60e88178da471330b94bfbf12e2731d2efc77d
* GlobalFunctions: Remove usage of `wfArrayFilter` & `wfArrayFilterByKey`Derick Alangi2019-04-271-44/+0
| | | | | | | | | | | | | These functions were hard deprecated in 1.32 and usage no longer exist and seems to have been completely removed from all repos. See below; Usage ===== https://codesearch.wmflabs.org/search/?q=%5B%5E%3E%5D(wfArrayFilterByKey%5C(%7CwfArrayFilter%5C()&i=nope&files=&repos= Bug: T42485 Change-Id: I28092eeb8dec058c5dba2fb63f3602249c137b31
* Drop clearCache() from (Configured)ReadOnlyModeAryeh Gregor2019-04-101-14/+8
| | | | | | | These are services, so tests should just override services to reset them. Change-Id: Icb1a041f8fac1ea0b7421e69b7b31b24171d868b
* Use new externallinks.el_index_60 fieldBrad Jorsch2018-11-121-57/+0
| | | | | | | | | | | | | | | | | | | | | This adds a method to LinkFilter to build the query conditions necessary to properly use it, and adjusts code to use it. This also takes the opportunity to clean up the calculation of el_index: IPs are handled more sensibly and IDNs are canonicalized. Also weird edge cases for invalid hosts like "http://.example.com" and corresponding searches like "http://*..example.com" are now handled more regularly instead of being treated as if the extra dot were omitted, while explicit specification of the DNS root like "http://example.com./" is canonicalized to the usual implicit specification. Note that this patch will break link searches for links where the host is an IP or IDN until refreshExternallinksIndex.php is run. Bug: T59176 Bug: T130482 Change-Id: I84d224ef23de22dfe179009ec3a11fd0e4b5f56d
* Fix wfDebug() test so that it works with overridden SPITim Starling2018-08-311-1/+4
| | | | | | | Fix testDebugFunctionTest() so that it works when LocalSettings.php sets $wgMWLoggerDefaultSpi Change-Id: I5e573b0ce1ce037c3505d3b44d9710395c9af8d6
* tests: Replace Bugddddd with Tddddd in test names, test stringsFomafix2018-08-201-1/+1
| | | | Change-Id: Ic6fbc5e14b1a756f62dd6cc3a6b2acc0d47db498
* GlobalFunctions: Enable patch-coverage for wfExpandUrl testTimo Tijhof2018-07-251-0/+1
| | | | Change-Id: I3b4594dab0aba659cc47233f7be3da751066b7de
* Merge "$wgHttpsPort should only be used in very special cases"jenkins-bot2018-07-241-6/+41
|\
| * $wgHttpsPort should only be used in very special casesTim Starling2018-07-111-6/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When expanding a URL, don't overwrite an explicitly specified port or add a port to a foreign URL. $wgHttpsPort is only useful for a very specific case: when $wgServer is protocol-relative and HTTPS is requested. Documented correct use of $wgHttpsPort in DefaultSettings.php. Fixed invalid "@see", in Doxygen it can only point to "classes, functions, methods, variables, files or URL". Added test cases which previously failed. Change-Id: Id65c58300d22712212b6605711ff916916e8768b
* | Deprecate wfArrayFilter() and wfArrayFilterByKey()Max Semenik2018-07-191-1/+3
|/ | | | | | | | | Now that all our supported PHP versions have array_filter() with a third parameter, these functions aren't needed anymore. Depends-On: I3b097a1a048baabcaca15dc214a3a1bb06e746cc Depends-On: I0187e27ac47cbab099249572201d1a649226a734 Change-Id: I7cabd0252691a083cb749cf9d3a7a23f1d076c39
* Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenientBartosz Dziewoński2018-05-301-3/+1
| | | | | | | | | | | | | | Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/ Replace with: '\1 ?? ' (Everywhere except includes/PHPVersionCheck.php) (Then, manually fix some line length and indentation issues) Then manually reviewed the replacements for cases where confusing operator precedence would result in incorrect results (fixing those in I478db046a1cc162c6767003ce45c9b56270f3372). Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
* build: Updating mediawiki/mediawiki-codesniffer to 16.0.0Umherirrender2018-02-171-1/+1
| | | | Change-Id: I59b59f79bbf3ce4feff3b3a20c1c31bc16370531
* Update suppressWarning()/restoreWarning() callsReedy2018-02-101-2/+2
| | | | | Bug: T182273 Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
* tests: Add @group and @covers to wfArrayFilterTestTimo Tijhof2018-01-311-0/+5
| | | | Change-Id: I6565ad21b6d6e78d876f730596e213555143c3fc
* Add @covers tags to miscellaneous testsKunal Mehta2017-12-241-0/+9
| | | | Change-Id: I7e65c1734aef01cd6395ee65204a0158d1635b0c
* Get conflict results from diff3WMDE-Fisch2017-12-061-2/+32
| | | | | | | | | | | This patch extends the global wfMerge function to also return the result of the first merge attempt that detects merge conflicts. The additional output explicitly names the conflicting lines and could help when solving edit conflicts. Bug: T151320 Change-Id: I97acebdc87b31779200c7fde4dd4449cd1ee8ead
* Expose string->bool conversion as functionStanislav Malyshev2017-11-151-0/+51
| | | | | | | | | | There is code in several places in extensions which converts setting or parameter string (such as "true", "yes", "false", "no") to boolean. Since we already have the code that does in global functions in wfStringToBool(), it makes sense to expose this code and reuse it. Change-Id: I88d98b012ff4bf14fd64a05a9135a6e75cf2d4e7
* Refactor global function wfBCP47 to static function LanguageCode::bcp47Fomafix2017-10-051-121/+0
| | | | | | Deprecate global function wfBCP47. Change-Id: Ie6bb061b5d6ca67289bb18bc468a87421f38fc94
* build: Updating mediawiki/mediawiki-codesniffer to 0.12.0Umherirrender2017-09-101-1/+1
| | | | Change-Id: Iefaae5043fa77d5d556c31079549dab8f61bd3ef
* Remove test code that depends on extensionMatthias Mullie2017-08-131-2/+5
| | | | | | | | | | | | | | | | | | And allow extensions to add their own media handlers. I'm not too happy with the introduction of another global, but didn't like the alternatives either: * Add some hook to MockMediaHandlerFactory that would allow extensions to add their own stuff in. * Use another hook (like ParserTestTables or ParserTestGlobals) and then override the service with a new instance - seemed too hacky The good thing about this is that it lets us kill off a class. I'm other to other suggestions in case I missed something. Bug: T169258 Depends-On: I5875621c58597426ad5242bf3d07714555c439b5 Change-Id: I1c2e903fb235395a8de8e0f7bf65ce07739d2930
* Remove empty lines at begin of function, if, foreach, switchUmherirrender2017-07-011-2/+0
| | | | | | Organize phpcs.xml a bit Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
* build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0Umherirrender2017-06-261-5/+5
| | | | | | | | | | | | The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment. Will be fixed in next version, see T167168 Changed: - Remove duplicate newline at end of file - Add space between function and ( for closures - and -> &&, or -> || Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
* ChangesList: Expose basic properties of lines as data attributesGergő Tisza2017-06-081-0/+37
| | | | | | | | | | | | | | | | | | | | | | We have several types of change lists (old RC/watchlist/related changes, enhanced RC/watchlist, history) with slightly different HTML, each with their own idiosyncracies. JavaScript code trying to identify lines by log ID / revision ID has to jump through all kinds of hoops to work with that. To simplify the lives of frontend / gadget maintainers and provide something approaching an API for these pages, we now expose the basic attributes of each change line (revision ID for edits, log type/action and ID for log events) as data attributes. The OldChangesListRecentChangesLine, EnhancedChangesListModifyLineData, EnhancedChangesListModifyBlockLineData, PageHistoryLine, ContributionsLineEnding and DeletedContributionsLineEnding hooks are updated accordingly. New hooks (LogEventsListLineEnding and NewPagesLineEnding) are added for the change list pages which did not yet have them. Change-Id: I6dd006d0b1b0fd35c0020f0f9eea9113eca30b35
* A service for read-only modeTim Starling2017-04-191-2/+19
| | | | | | | | | | | | | | | | Introduce a service to represent wfReadOnly() and friends. It's necessary to have two service instances, one for wfReadOnly() and one for wfConfiguredReadOnlyReason(), to avoid a circular dependency, since LoadBalancer needs the configured reason during construction, but wfReadOnly() needs to query the currently active load balancer. Not having a cache of the configuration makes it possible to dynamically change the configuration. Ideally things would not change the configuration, and I removed such instances in core, but to support extensions, I added a test ensuring that the configuration can be changed. Change-Id: I9bbee946c10742526d3423208efd68cb3cc5a7ee
* Add missing @group Database tags in testsaude2017-03-181-0/+1
| | | | Change-Id: Id92aab0b1f8cde6657d6558d0d82605109daa588
* tests: Replace implicit Bugzilla bug numbers with Phab onesJames D. Forrester2017-02-211-2/+2
| | | | | | | It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345" except where it doesn't, so let's just standardise on the real numbers. Change-Id: I46261416f7603558dceb76ebe695a5cac274e417
* Remove empty lines from PHP and JavaScript comment blocksThiemo Mättig2016-12-091-1/+0
| | | | | | | | | This is a pure documentation change. It mostly removes empty lines from comments (and entirely empty comments), as well as adds a few missing documentation blocks and fixes a minor mistake. I hope it's ok to have this in one patch. I can split it, please tell me. Change-Id: I9668338602ac77b903ab6b02ff56bd52743c37c4
* Use HTTPS instead of HTTP for ietf.org URLsFomafix2016-09-281-1/+1
| | | | | | http://tools.ietf.org/ redirects to https://tools.ietf.org/ Change-Id: Ia45d2ce80399e1c9172e0924abd6bf794a53122f
* Override MediaHandlers in tests using MediaWikiServicesKunal Mehta2016-08-031-3/+1
| | | | Change-Id: Ie39fd9243e7817191b87179f792d932f7b96de0c
* Use more short array syntax in comments (/tests/)umherirrender2016-07-103-7/+7
| | | | Change-Id: I86c73cb9447ac562a73348b4030e24ebf49a90dc
* Support hash fragments in wfAppendQuery()Roan Kattouw2016-05-021-0/+12
| | | | Change-Id: Icb99d5479836fea25a47451b5a758dd71f642f71
* Update comments about language codesFomafix2016-02-191-4/+4
| | | | | | | | | | | | | | * RFC 3066 is obsoleted by RFC 4646. * RFC 4646 is obsoleted by RFC 5646. * All are also known as BCP 47. * Language codes must treated as case insensitive. * There exist conventions for the capitalization of some of the subtags. * Write a space between BCP and 47 in comments. * http://www.adobe.com/devnet/xmp/pdfs/XMPSpecificationPart1.pdf is not available. * https://wwwimages2.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/XMP%20SDK%20Release%20cc-2014-12/XMPSpecificationPart1.pdf is the new position. Change-Id: I91e305fd5754cf4dedf8fd7460f7d3375f792c89
* Convert all array() syntax to []Kunal Mehta2016-02-1715-649/+649
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Give TestCase::checkHasDiff3 a better nameaddshore2016-01-281-1/+1
| | | | | | | | | | This method actually marks the test it is called from as skipped if Diff3 is not confugured. The new name "markTestSkippedIfNoDiff3" better reflects that. Change-Id: I1dffeba0aceb312b3a82216f0b55227e24bc2e34