Commit graph

24 commits

Author SHA1 Message Date
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +00:00
Derick Alangi
6e5f2d0822 tests: Migrate setMwGlobals() to overrideConfigValue(s)()
Directories covered are:
- tests/phpunit/includes/cache/
- tests/phpunit/includes/changes/
- tests/phpunit/includes/changetags/
- tests/phpunit/includes/config/
- tests/phpunit/includes/content/
- tests/phpunit/includes/debug/
- tests/phpunit/includes/deferred/
- tests/phpunit/includes/diff/

Change-Id: I3a1f586867db7d57b177e13a03a4593f7eed09f4
2022-07-23 05:53:49 +01:00
Umherirrender
2582db5ed2 DeprecationHelper: Fix method name in deprecation message
The wfDeprecated is called directly from __get/__set/__isset which needs
only a 2, not 3. That means the message is one caller of.

Change-Id: Ia29fb0a07841f69a4d8b95431f0915df9793c340
2022-04-11 23:30:06 +00:00
daniel
972dde7107 DeprecationHelper: avoid closures
The cost of creating closures adds up, so avoid it if we can be using
method names instead.

Bug: T297236
Change-Id: Ifb78d5f310fe45db58fd450c9db3c7af295ae399
2021-12-10 17:15:13 +00:00
Umherirrender
2e4ee47c3d Cleanup mixed space/tab line indent
Change-Id: I833052a656b1ce419c0929f6f0514f2a33c2c4cc
2021-09-04 00:52:31 +02:00
Petr Pchelko
ac629eed2d DeprecationHelper: Support mocking and dynamic properties
DeprecationHelper currently breaks dynamic properties
on phpunit mocks. This happens because phpunit starts
mocking the magic methods if they're explicitly defined.

By default, magic methods and up doing nothing, but
if proxying to original methods is enabled, magic methods
are called like regular methods, regarless of whether
property exists or not. With this patch we can workaround
this issue, and create mocks for classes with deprecations.

Needed-By: I4297aea3489bb66c98c664da2332584c27793bfa
Change-Id: Id60a7751ece05669eced6eddd3216da7149411c7
2021-08-04 12:38:02 -07:00
vladshapik
1be1fae99f DeprecationHelper: Support null coalescing on dynamic props
Change-Id: If46287f0b29fee043d212944cb64d56ecf2e413a
2021-08-02 09:00:04 -07:00
Petr Pchelko
0c395c3592 DeprecationHelper: allow or deprecate dynamic property access.
Setting and getting dynamic class properties (e.g. $parser->my_fancy_prop)
is a horrific practice that we should get rid of, but it is still
used. DeprecationHelper right now can not be used on classes
where this practice is used by extensions. Introduce methods
to allow or deprecate this practice.

Change-Id: Ib378bef792dd31be155f186f1a4965a05004a37c
2021-07-29 07:57:20 -07: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
Reedy
eb41565a9a Tests: Start marking some closures as static
Bug: T274036
Change-Id: Ib738ecd3bc23d34900bc268c8246702ac3655746
2021-02-06 19:57:42 +00:00
Peter Ovchyn
d8f54cae8b Language: Turn public properties into Getters in LanguageConverter based hierarchy
The main goal is to simplify the construction of the LanguageConverter and
avoid using constructors for derived classes.

In order to hard-deprecate removed property, DeprecationHelper::deprecatePublicPropertyFallback
was introduced.

Bug: T253834
Change-Id: Ib167982e4e872cfdf0fbcb78b7ca597f5ac8d60a
2021-02-03 15:17:42 +02:00
Gergő Tisza
d7269d08f0
Fix DeprecationHelperTest on PHP 8
The non-existent property error message is phrased a bit differently.

Bug: T272326
Change-Id: I53099853631a078ec5d88a1c8a22117238efcbc5
2021-01-19 09:50:30 -08: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
Reedy
229b2c15e8 Fix a plethora of class and function call case mismatches
Bug: T231412
Change-Id: I597a25de3294a6673424f30475760280ef209a8a
2020-05-26 14:14:46 +01:00
Peter Ovchyn
7d57b967b5 deprecation: Remove DeprecationHelper::newArgumentWithDeprecation and change callers accordingly
Bug: T245075
Change-Id: I0714b1c5d5a379cfe3ca473b72244d4d6bd1b7b8
2020-04-27 20:23:58 +03:00
Peter Ovchyn
50e3bd4fac parser: Inject a LanguageConverterFactory through DI containers:
1. into class Parser
2. into class LinkHoderArray
3. into class DefaultPreferencesFactory

Add more tests for DefaultPreferencesFactory:
1. testVariantsSupport verifies that converter with variants is used correctly.
2. Test testUserGroupMemberships verifies that membership is used correctly

Bug: T243320, T243321, T243317
Change-Id: I1e5c37e18332d0d32391c74c06e3d84862e48df8
2020-02-04 14:42:03 +02:00
Fomafix
6a3f192d11 Forbid wfDeprecated with $version = true
$version = true is not supported.

Change-Id: Id08ada32cd0273564c638d242354351333a9f163
2019-12-31 13:53:36 +01: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
Daimona Eaytoy
8545ce131a Kill the remaining usages of PHPUnit4And6Compat methods
Bug: T192167
Change-Id: I1ea19e9b53683b7d32ff9836990ee73ab3e11104
2019-10-06 10:12:54 +00:00
Derick Alangi
49bbfc7f1f GlobalFunctions: Tighten version number type for wfDeprecated()
To avoid cases like: facddc4 and Ifaf6ab0d36bc02bd170, make sure the
value of the mediawiki version  must be a string (e.g. '1.33') or a
boolean (e.g. `false`).

For some reason, typos can slip through for this value to be a float.
Let's safe guard for future cases like this.

Change-Id: I52bdf94c957bda67548a937d51649e925195f926
2019-07-01 21:07:10 +00:00
Gergő Tisza
a015ee72ae
Fix class name handling in DeprecationHelper
The method for getting the declaring class name was not used when
printing the class name, and was incorrect anyway. Use reflection
when on the error path to ensure the correct class name is used.

Change-Id: Ic9cd4319535d5ab877a0563e0433371e1025d985
2019-04-19 01:09:25 -07:00
C. Scott Ananian
8025629395 Ensure disabled deprecation warnings are re-enabled before next test
Tests should not interfere with each other; disabled deprecation
warnings should be disabled for a single test case only.

Bug: T191960
Change-Id: Ic9b892bc83ba6d71c1077df0d93c95dde36988bb
2018-09-25 16:30:38 +00:00
Gergő Tisza
4aedefdbfd
Add helper trait for deprecating properties
Change-Id: I83e6ee4e8eedd49acef2b5d92132d37af715bff3
2018-07-18 15:15:46 +02:00