Commit graph

104 commits

Author SHA1 Message Date
gerritbot 2da869fa58 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: Ia3b739ceacc035d64ec6d13de9d3e6de102dbb20
2023-08-19 12:22:49 +00:00
Daimona Eaytoy c581aab15e Avoid using TestUser in non-Database tests
TestUser is expensive and requires DB access because it creates the user
in the test database. That is not needed here. For these tests, a mock
is enough.

Also make PopupsGadgetsIntegrationTest an integration test, to fix a
local failure and in view of I0a04c82250582fed7a66c1e10868d9b4f3823a28.
If a test is testing the integration of X with Y, guess what, it's an
integration test ;-)

Change-Id: Ie8b3376ce97b9ddc67746f7754b92628c5ab9470
2023-08-10 00:08:49 +02:00
Umherirrender 9da6586158 tests: Make PHPUnit data providers static
Initally used a new sniff with autofix (T333745)

Bug: T332865
Change-Id: I1a585a5e81ad0355b3be806da249e632f3fd21ec
2023-05-20 13:56:14 +02:00
Fomafix 76e2339cec Inject service UserOptionsManager in Hooks
Change-Id: I690699210c041f950a076904b863bc014833e5ad
2022-12-15 22:13:23 +00:00
Fomafix c58f9234fc Use $this->getServiceContainer() in test cases
Change-Id: Ic03f4d692720cd9810c44700f7bf27d1cf07d26d
2022-11-05 09:50:56 +00:00
Fomafix 56d8a8df55 Inject service SpecialPageFactory
Change-Id: Ia38b468741bdfd5bab5bb34df79bf01d549498a9
2022-11-05 09:28:08 +00:00
Thiemo Kreuz dd3bff0d2a Use PHPUnit's convenience shortcuts where possible
Change-Id: I5cc75a66f5971de409a9debdd4f4ebfb8ee94b22
2022-09-29 14:41:35 +02:00
Reedy 3ac384e5a5 PopupsGadgetsIntegrationTest: Use namespaced Gadget class
Change-Id: Iad6488408fdd29af45dab46e1c81944d181f711d
2022-03-29 20:37:32 +01:00
Reedy b6eb2627ff Use namespaced GadgetRepo
Change-Id: Ibaa24dc0bf02b0d1cbe4e66a8a4efc47896d0fb9
2022-03-06 01:33:08 +00:00
Fomafix cfa0f5419b Use HookHandlers and implement hook interfaces
This change requires MediaWiki 1.35+.

Bug: T263353
Change-Id: I4d3aa20c666799e6e693a6a4b7a3e835303e2fc5
2021-12-20 11:05:19 +00:00
Alexander Vorwerk 131186d8b8 MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: I1cb26373fb173c5abf7c3838185b68016e4ade05
2021-10-12 01:00:04 +02:00
Sam Smith 8f5000f346 Remove Popups instrumentation
Bug: T267211
Change-Id: I640ab367cd235ab8da7dd70dbef7ae9076712e84
2021-07-29 17:01:01 +00:00
Alexander Vorwerk 35462639c3 Avoid using User::getBoolOption()
User::getBoolOption() is deprecated and should be replaced with
UserOptionsLookup::getBoolOption()

Bug: T277600
Change-Id: I9a2118a6342bd5f145174428dcfb518cba4e439b
2021-06-06 16:44:20 +02:00
anjali041 81bb920e2b Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: I5698b4422755a921c9c9c01ce29084ebfe5f5385
2021-06-02 12:21:10 +00:00
Thiemo Kreuz 3a00223a36 Separate reference preview settings in beta & non-beta
This is the smallest possible patch for a backport.

While it seems there is zero technical reason to limit user
option keys to lowercase with dashes, it's best-practice.
Same as message keys.

Bug: T281235
Change-Id: Ia4a45cf4459543c81b23b757ae9c2cfaf9676894
2021-04-27 16:15:17 +02:00
Thiemo Kreuz e19b557227 Merge duplicate ReferencePreviews Beta feature flag
Change-Id: Ia7f1c9128460bc5a139e37eb16fff649e80cd20f
2021-04-21 10:46:05 +02:00
Andrew Kostka e4e07e509a Separate page and reference preview preferences
Bug: T277638
Change-Id: I8144625e0d3a2626511f35d4e92d082b6fa44bb4
2021-03-29 14:09:27 +02:00
WMDE-Fisch 97538eb9e1 Add tests for bitmask code
Bug: T276716
Change-Id: I7c21e909f121217e43bf5072061bda422f390693
2021-03-11 14:05:21 +01:00
WMDE-Fisch 58f820009e Use flags to represent settings
To reduce size of code added to the <head> and increase performance.
The increased bundlesize is still less than the size spared bytes in
ResourceLoaderGetConfigVars. - But nevertheless the main gain is loading
less in the <head> anyways.

To avoid further complexity in the code, the bitmask is converted to
the according config setting early on instead of adding checks on the
bitmask all over the place.

Tests will be added in follow ups.

Bug: T276716
Change-Id: Ib4f82bed58295b25f0a41cb37e36244e45f16317
2021-03-11 13:38:06 +01:00
jenkins-bot e441052cb0 Merge "Combine page and reference preview preferences" 2021-03-01 11:10:17 +00:00
Umherirrender eaaf560d99 build: Updating mediawiki/mediawiki-codesniffer to 35.0.0
Change-Id: Ib411b8fbec93f469e4f4812f60f8349207744ecd
2021-02-26 23:42:29 +01:00
Andrew Kostka 82d54945e4 Combine page and reference preview preferences
Update copy and remove unnecessary reference preview preference
in favor of using the default preference. It seems there is no
stable method to link to the subsections on the preference page
for gadgets. So in all cases does the link just point to the
gadgets pref page.

These changes should only be visible when reference previews
are no longer marked as a beta feature.

Bug: T265709
Change-Id: I7b8ab91331092ada04b230315373548673b9272c
2021-02-25 10:21:16 +00:00
Svantje Lilienthal 1962372a44 Add cogwheel to disable ReferencePreviews
I added the common styling for the setting icon to the popup.less
and removed the now empty pagePreview.less.

Bug: T234205
Change-Id: I2a82831bc71a4208c4b66c18e2a4613127c43e1f
2021-02-16 15:39:43 +01:00
Vedmaka ff2ba9ebf5 Adds "$wgPopupsTextExtractsIntroOnly" option to control "intro" parameters for TextExtracts API request
Change-Id: I84f91ab0752bbd4a5b1ee159b7cbe1388f942f24
2020-12-07 15:00:29 -08:00
Svantje Lilienthal 0b6c859a2b hide reference previews when reference tooltip gadget is active
Change-Id: I5f43270bfeba944c05dc09adf771ed07057237c7
2020-11-16 18:36:04 +01:00
Ammar Abdulhamid 5e405eb2f2 Popups: Rename new config variable
In this patch we introduce a new config variable and update its default
to be the same as the production value of $wgPopupsPageBlacklist.

When this code is deployed everywhere, we will remove wgPopupsPageBlacklist
from mediawiki config and defer to the Popups extension as the source of
truth from now on.

Bug: T254676
Change-Id: Ifebdcf8f5eec854a2b947dc390eaf47704a5c5eb
2020-07-07 09:47:59 -07:00
Thiemo Kreuz 092e2a4959 Talk about "exclusions" instead of "blacklists"
AVoid the term if possible, in all internal code. The only remaining
use of the word is in the public $wgPopupsPageBlacklist config
variable.

Change-Id: Ib238731270f473ad44fcff13df617a70433f2452
2020-06-09 08:56:06 +02:00
DannyS712 48f3a8f720 Remove unneeded ::setUp and ::tearDown methods that only call parent
Change-Id: I2700613e5071bc20ef8ed9706de70e596cdfdbc7
2020-06-07 03:10:11 +00:00
DannyS712 68d52f7fa9 Use assertTrue instead of assertSame to compare with true
Bug: T244552
Change-Id: I42c50e37515e49a15658041147edc1d644812c46
2020-02-07 07:17:04 +00:00
Piotr Miazga 0ab39f88e7 Enable by default
Popups is enabled on the Wikipedias but disabled by default, which makes
it more difficult to enable on third-party wikis.

Things should be enabled by default, and them WMF configs should disable
features when they are not used/available.

Supporting changes:

- Rename PopupsContextTest#testAnonUserHasDisabledPagePreviews and
  remove the associated data provider, which provided only one datum

- Set $wgPopupsReferencePreviews to false in
  PopupsContextTest#testShouldSendModuleToUser in order to isolate the
  code under test

Change-Id: Ib8cc7041d792bed0a19d18e14506627099a69bef
2020-01-29 15:40:23 +00:00
Umherirrender 9fa7f2071c build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Change-Id: Ifb739130872b192b0fee54351555b65c3099981e
2020-01-26 20:22:03 +01:00
jenkins-bot 5d925e3479 Merge "Add tests case for user preferences while in Beta mode" 2019-12-18 07:57:40 +00:00
Thiemo Kreuz 776f4af6c5 Add tests case for user preferences while in Beta mode
This is a direct follow up for I4d31805. Note the previous patch was
only testing the code path when Beta is disabled. But the bug was about
what happens when Beta is enabled. This is now properly covered by
these tests.

Bug: T240947
Change-Id: I54c5e9751e14a94808e85d935e1972eea0395002
2019-12-17 16:27:26 +01:00
Thiemo Kreuz fc6a72094d Turn some tests into faster running "pure" unit tests
On my local machine, this reduced the runtime for all PHPUnit tests
combined from 900ms to 800ms.

Change-Id: Iec4f0396115fd270ba1a1f6668e1672cea5f7aff
2019-12-17 16:20:27 +01:00
Thiemo Kreuz 5752c2538e Fix initial preferences for newly created user accounts
It appears like we accidentially copy-pasted the behavior for
PagePreviews and made ReferencePreviews behave the same, not taking
into account that the later feature is in Beta mode.

Bug: T240947
Change-Id: I4d31805ee9b2045c49c7ab4179c5a4adbcba0394
2019-12-17 13:37:11 +00:00
Thiemo Kreuz 71ac670d9e Add visibility keywords to all constants in PHP code
Change-Id: I384cffed670c7e845465e3e18808e267327011ed
2019-10-22 07:10:31 +00:00
Thiemo Kreuz fe32c48268 Replace all mock builders with createMock() calls
This was motivated by two things:

1. Notice the bad class name in UserPreferencesChangeHandlerTest. This
was possible because the default mock builder does not check if a class
exists, *and* there was no type hint in place. createMock() *does* check
if a class exists.

2. We are free to use createMock() from PHPUnit 5+ now. It's not only
shorter but more strict and reliable.

Change-Id: I301a171d587026eab0a62575ab2fdbfd7733c661
2019-10-18 14:31:10 +00:00
Thiemo Kreuz a63a1cf91c Split user preferences for Page and Reference previews
Bug: T233813
Change-Id: I89205658c561961b90abaa133a004e54beebfab5
2019-10-17 11:21:21 +02:00
James D. Forrester e16143df16 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: Icd67aed448269f603dd4465f7e46eac9a64bd1a1
2019-10-15 16:13:01 -07:00
Max Semenik b72a95b5c0 Fixes for PHPUnit 6
Bug: T192167
Change-Id: I354077e8e44cfea3e75219d6701a4f9e11d4c70a
2019-10-05 22:43:20 -07:00
Thiemo Kreuz 3eb7c9b976 Replace all loose assertEquals with strict PHPUnit assertions
A method that is expected to return, for example, a boolean true
should not return an other value that PHPs loose == comparison might
also consider true.

Same for all other loose equality checks.

Change-Id: If729c6e97d5337eee10b717da76dad428218ff69
2019-10-04 10:34:21 +02:00
Timo Tijhof 81b94eff0a Remove redundant wgPopupsShouldSendModuleToUser variable
It is set based on the same conditional that loads the code,
thus checking it inside the loaded code is a no-op and adds
extra HTML to the <head> that blocks text/layout rendering and
delays fetching of Popups JS.

Bug: T219342
Change-Id: I9c1f4b3861ce2cecb654eb0a78469a616730a40b
2019-04-09 18:31:35 +00:00
Thiemo Kreuz e32fc4914e Add some missing newlines to separate PHP code better
I believe these additional newlines all make the code easier to read.
It's easier to see what belongs together, and what is a separate thing.
I found the Squiz.WhiteSpace.FunctionSpacing sniff very helpful to
enforce this code style. We enabled this already in almost all WMDE
codebases. It is not yet part of the upstream MediaWiki rule set, but
discussed.

Change-Id: Ibdf788529b28637bf98e7940c2516852c3afcef7
2019-03-11 11:33:13 +01:00
Thiemo Kreuz 1cf4e5902b Enable Squiz.Strings.DoubleQuoteUsage PHPCS sniff
The majority of this was fixed just recently via I8de42df. The sniff
makes sure all old and new code conforms to this style.

Change-Id: I8aecf3653d021fc8f86abcdc5939529864f86a48
2019-03-01 11:28:20 +01:00
Derick Alangi 8fa98056f7 PopupsContextTest: Improve the PopupsContext test suit
-> Use single quotes for string literals.
-> Document missing parameter in test method.

This is just to improve on code readability, consistency
and maintainability.

Change-Id: I8de42df9f856ecb409637fe33b5f84b8bed1b547
2019-03-01 09:38:17 +01:00
jenkins-bot ac6e03cc0d Merge "Update documentation and signatures of hook handlers" 2019-02-26 22:30:57 +00:00
Thiemo Kreuz 1697cb9a65 Update documentation and signatures of hook handlers
* Explain the difference between the two hooks that both set config vars.

* Remove by-ref & that are not needed. This is a non-breaking change.
Even if the code calling a hook handler provides a variable by reference,
the hook handler being called does not need to require a reference.
Removing these & makes the code less confusing and easier to read.

* Replace an OutputPage type hint with a more narrow IContextSource.
That's all this code actually needs to know. It doesn't need access to
the entire OutputPage, so it doesn't need to require it.

* Update the signature of the ResourceLoaderGetConfigVars handler to
match the caller.

Bug: T215896
Change-Id: Ie1e4b50cd954812f71dd628003b8e9d40fdf5fe8
2019-02-26 17:45:39 +00:00
Thiemo Kreuz 54af069999 Remove unused $config constructor parameter from loggers
As suggested in I69ad209.

As far as I can tell the idea was to be able to pass logger-specific
configuration to the logger factory, e.g. to be able to toggle certain
things the loggers would do. But this is not used at the moment. There
is not much value in keeping unused code around. It can esaily be
introduced again later when it turns out it is needed.

Furthermore, I'm told most of the logging functionality should be
removed anyway. See T193051.

Change-Id: I6b1ddb2a65eacc0e096f2ba44922d63e63212a65
2019-02-26 12:20:59 +01:00
Andrew Kostka f91c160214 Add a beta feature switch for reference previews
Bug: T215896
Change-Id: I6a4cc2103d594dc11f62da247891d3f190619899
2019-02-25 20:38:12 +01:00
Thiemo Kreuz 13015ad317 Fix a series of minor documentation issues in PHP code
E.g. type hints that have been missing, missing indention, and such.

Change-Id: I34610a03ad69d7988e9976a08a289c64121420ca
2019-02-01 09:42:14 +01:00