Commit graph

67 commits

Author SHA1 Message Date
Alexander Vorwerk
04dfdc3653 Hard deprecate User::setOption()
deprecated since 1.35

Bug: T277818
Change-Id: Ic251d624e5d6fa857aa92f9c5dd3df44714ac610
2021-09-26 17:18:54 +02:00
Thiemo Kreuz
b95a07380a Remove meaningless ->expects( $this->any() ) from all tests
It is not entirely meaningless. It might be an indicator that
the number of calls to a method is intentionally unlimited.
This is similar to e.g. an @inheritDoc PHPDoc comment that
marks a method as being "intentionally undocumented".

However, what's the meaning of being "intentionally
unconstrained"? Let's just not have any constraint then.

I feel all these ->expects( $this->any() ) bloat the test
code so much that it's never worth it.

Change-Id: I9925e7706bd03e1666f6eb0b284cb42b0dd3be23
2021-04-23 11:58:58 +02:00
Thiemo Kreuz
40764d277c Replace PHPUnit ->returnValue() with ->willReturn() shortcut
It's the same and makes the test code much more readable, I
would like to argue.

Because of the was I split all the changes I made into smaller
patches this patch contains some other changes in the same
lines where I could not split them off. E.g. removal of
->any(), which is the default anyway and doesn't do anything.

Change-Id: Ib297b989d4aec33b31a4e33fe9d5032865b39be0
2021-04-22 10:37:45 +02:00
Daimona Eaytoy
535d7abf59 phpunit: Mass-replace setMethods with onlyMethods and adjust
Ended up using
  grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g'

special-casing setMethods( null ) -> onlyMethods( [] )

and then manual fix of failing test (from PS2 onwards).

Bug: T278010
Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
2021-04-16 20:15:00 +02:00
Sébastien Beyou
c4c41cda5c Restore the parameter srbackend in Special:Search
This parameter, mainly used during transition to CirrusSearch,
was no more effective because its value was read too late.

Also, added a test for this parameter.

Bug: T277045
Change-Id: I43af23bac983a5c88569c6cde1bab20039128389
2021-03-16 10:40:20 +01:00
Petr Pchelko
5d39397de3 Convert first batch of special pages to Authority
Change-Id: I4c6877ef2b1f32610190c6de0f1bcaaa3c835fb0
2021-03-01 21:41:20 +00:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
jenkins-bot
0b8914af50 Merge "use rewritten search term as search term" 2021-02-08 23:49:30 +00:00
Maryum Styles
4671a16d8b use rewritten search term as search term
if there has been a rewritten search term
then use that as the search term for subsesequent
page requests

Bug: T271103
Change-Id: I9964c5d9acde4ea74f93332b01ef5684b817a12b
2021-02-08 14:12:20 -08:00
Reedy
eb41565a9a Tests: Start marking some closures as static
Bug: T274036
Change-Id: Ib738ecd3bc23d34900bc268c8246702ac3655746
2021-02-06 19:57:42 +00:00
jenkins-bot
eb4b304ed8 Merge "Add missing @param and @return to documentation in tests" 2021-01-30 15:22:33 +00:00
jenkins-bot
480ca0f2d4 Merge "Revert "message boxes: Use CSS classes adhering to class naming scheme"" 2021-01-25 17:27:49 +00:00
VolkerE
e4b3c0e8b0 Revert "message boxes: Use CSS classes adhering to class naming scheme"
This reverts commit 066e77735e.

Reason for revert: Objections brought up on ticket by Esanders are in alignmenet with own objections, that arose after initially providing this patch. We need clarification that is better addressed in new patch, reverting this.

Bug: T270796
Change-Id: Id873b3e3b7efb3003daa4986225b1fb3e7e218c8
2021-01-25 16:31:08 +00:00
Umherirrender
7691dbeca9 Add missing @param and @return to documentation in tests
Change-Id: Ic663e81cca0bf007804a70772250914a85f1fef4
2021-01-22 19:57:25 +01:00
jenkins-bot
e2be1836e9 Merge "message boxes: Use CSS classes adhering to class naming scheme" 2021-01-22 02:15:34 +00:00
daniel
61a5531e4a Strict return types for PageIdentity
Bug: T208776
Change-Id: I7e71ffc209465b7cca385603d844cd40178485a9
2021-01-18 17:33:14 +01:00
Volker E
066e77735e message boxes: Use CSS classes adhering to class naming scheme
Change to reflect class naming scheme.

Depends-On: I14ee75bd173fb2de1e33067f95ce09deba5bf27a
Bug: T270796
Change-Id: I7bf7f293712a8516862247d10e98289ff2e3e2cd
2021-01-14 13:09:55 -08:00
David Causse
95db1c18ee Special:Search find variant links before showing the create page link
On a multi–writing system wiki it may happen that Special:Search
show the create page link on a "blue link".
Rely on LanguageConverter::findVariantLink() to find such link.

Bug: T260957
Change-Id: Ic95188543a2aa88764882a7789e4c3a99fd5c3cc
2020-12-09 13:19:09 +01:00
Umherirrender
9758a871ab Inject services into SpecialSearch
This covers only directly used services by this special page and pager
Services used by the base class are not part of this patch set

Bug: T259960
Change-Id: Ic64c83d5496680cecf7c76bcad0802c330e0078c
2020-11-15 11:54:17 +01: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
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
Cormac Parle
c4eae0dad4 Search: Provide new preference to control redirects on search matches
To avoid preference bloat, this preference is hidden unless the new
sysadmin config $wgSearchMatchRedirectPreference is set.

Bug: T235263
Change-Id: Ic16f53a4e6ddb6da071d63cd5da28d937d4692c8
2019-11-06 15:37:56 +00: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
Max Semenik
dc3fba4619 tests: Nuke everything HHVM-related
Change-Id: Ieccce5ebba25132b2433fc13a575b65a5bd538f2
2019-10-05 12:51:07 -07:00
Erik Bernhardson
4d9d61460d Validate sort order in Special:Search
Providing an invalid sort order to Special:Search could trigger an
exception from the search engine when trying to apply it. Validate the
sort order, much like API classes do, and let the user know that the
sort they requested could not be applied.

We also have a unreported error for invalid profile requested, so
added that warning to the display while here.

Bug: T228171
Change-Id: I79079eea8c03a90b5b65f1dad11c99e514de00e1
2019-07-23 10:18:34 -07:00
Fomafix
110a5877e9 Use [...] instead of array(...) in PHP comments and documentation
Change-Id: I0c83783051bf35fe785bc01644eeb2946902b6b2
2019-06-17 21:15:09 +02:00
Thiemo Kreuz
8a4e15db7f Add missing newline between <?php and namespace/use section
The rest of the codebase is using this code formatting standard.

Change-Id: I4d2ba61757a7e28d40096d9dc5915005c340d4f2
2019-06-03 13:36:48 +00:00
Umherirrender
ca1a101d97 Add missing @covers to search related tests
Change-Id: Iba122ad763a5728a7ddb487b3d01d679de6845e5
2019-02-01 21:35:26 +00:00
Aryeh Gregor
e68fdb4065 Mass conversion to SpecialPageFactory service
Change-Id: Ia6e1e819ec6cbe8bf75b820109f51d47863e31fc
2018-08-17 12:03:12 -07:00
Erik Bernhardson
c2a308075f Convert SearchResultSet to typical iteration
The funky iteration here was at best annoying. Switch
it over to an iterator based approach with appropriate
BC code to simulate the old iteration style.

Depends-On: I19a8d6621a130811871dec9335038797627d9448
Change-Id: I9fccda15dd58a0dc35771d3b5cd7a6e8b02514a0
2018-06-11 13:35:41 -07:00
Umherirrender
45da581551 Use ::class to resolve class names in tests
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
2018-01-26 22:49:13 +01:00
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
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
2017-06-26 17:14:31 +00:00
aude
4f93da7259 Avoid database connection in SpecialSearchTest data provider
SearchResult::newFromTitle involves database connnection,
thus better to avoid calling this in the data provider.

Change-Id: I891e97cf18ca1dd44abefe01731dfc5da51f1982
2017-03-18 15:43:16 -04:00
James D. Forrester
1e9c361960 tests: Replace implicit Bugzilla bug numbers with Phab ones
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
2017-02-21 02:14:34 +00:00
This, that and the other
d0f17d8a97 Merge duplicate SpecialSearchTest files
Change-Id: I1d6be3f6c32102ee8c7f4ee3dc6f0c752ef05534
2017-02-01 00:54:35 +11:00
Erik Bernhardson
7075ea92d2 Cleanup execution flow through SpecialSearch::execute()
Not a big change, but makes it so there is only one path into
SpecialSearch::showResults(). Makes things a little easier to follow.
Also moves the code for checking if full text search is disabled into
execute(), makes sense to check before even trying to make a search
engine. Also moves some setup code out of execute and into the setupPage
function

Bug: T150393
Change-Id: Ib527fc3a3c39eb2e56985e5d1e4905fc4562353c
2017-01-17 13:45:40 -08:00
umherirrender
eac06f65ce Use more short array syntax in comments (/tests/)
Change-Id: I86c73cb9447ac562a73348b4030e24ebf49a90dc
2016-07-10 17:23:29 +02:00
Stanislav Malyshev
34b02d87ac Convert SearchEngine to service containers
Change-Id: Icef1ecbed3d831557e0256fdfa53743b194007cc
2016-04-25 16:25:17 -07:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
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
2016-02-17 01:33:00 -08:00
umherirrender
660bbda5f6 Set Language in SpecialSearchTest.php
Test fails on wikis with $wgLanguageCode not = 'en', fix this by
setting the language on the context.

Change-Id: I3a89b347263e460f639ba0641f5dbc65e8bf258d
2015-12-07 19:01:02 +01:00
Amir E. Aharoni
51f6dca4aa SpecialSearchTest.php: Make lines shorter to make phpcs happier
Also fixes a "Single space expected before closing parenthesis" failure.

Change-Id: Id35e490e7d17ee58b643e9f74583afcef62145c2
2015-09-26 14:42:26 +00:00
Erik Bernhardson
23acf6e70f Move query rewriting into search backend
Special:Search recently gained query rewriting behavior when the
original query returned no results.  We want to expose this query
rewriting behavior to both api and web requests.  Additionally we
want to be able to test different configurations of the query
suggestions.  This patch allows for both by moving the rewriting
from core into the search backend.

This defaults to enabled for Special:Search, and disabled for
ApiQuerySearch. Internal code that talks to the search backend
needs to specifically enable this feature.

Bug: T106888
Change-Id: I0a8f75759f9148f53358707369b8a7128215de86
2015-08-31 22:41:05 -07:00
Erik Bernhardson
bbfc872871 Auto-forward to search suggestion when zero results
If the user gets zero results, but gets a "Did you mean" result, just
run the query for the "Did you mean" result and inform the user that
this happened. Adds a new query param 'runsuggestion' which will, when
given a falsy value, prevent running the suggestion and give the result
to the original query.

Bug: T105202
Change-Id: I7ed79942c242b1957d46bdcad59985f37466fb83
2015-07-27 08:25:01 -07:00
Bartosz Dziewoński
1021f20100 Fix instances of preg_quote() without second parameter
This might work in specific cases, depending on the string we're
quoting, but is never correct. The instance in SpecialAllMessages.php
was resulting in incorrect behavior (and log spam, T103879).

Searched for this regex: preg_quote\((?:\([^)]+?\)|[^,()])+?\)

Change-Id: Icc88775970f4927ddf953e5ad7c5c19d59491573
2015-06-25 19:43:56 +02:00
jenkins-bot
25505f7839 Merge "Remove unused private var and fix phpdoc" 2014-08-22 23:32:30 +00:00
umherirrender
6b4c44c2db Add missing @param to function docs
Change-Id: Ib26407bc55dff7969d8a3b1e2ae51751b202d8fb
2014-08-18 16:24:59 +00:00
addshore
0215a5e0f0 Remove unused private var and fix phpdoc
Change-Id: I4a9d5f19cb0255067895f16dde4bc6d7376d904f
2014-08-17 23:20:09 +01:00
Chad Horohoe
1cf7eff66f Force default search backend on search test
Other backends might not mimic this behavior. Having CirrusSearch
enabled causes this test to fail.

Change-Id: I462446cd2e5eaf43d843c066cb5d7596394429d8
2014-07-07 20:30:18 -07:00
Siebrand Mazeland
69ec133bc5 Pass phpcs-strict on some test files (10/11)
Change-Id: I5624292143fcabe890779f5095eae735d7afb176
2014-04-24 13:50:56 -07:00