Commit graph

715 commits

Author SHA1 Message Date
Petr Pchelko
f50c097b9a Keep ActorStore caches consistent on user rename
Multi-key in-memory keys for the actors is complicated
enough to have it's own small abstraction.

Change-Id: Id0e091504b71a44ce52d418c5737d64ac70495e9
2021-04-26 14:02:00 -07:00
vladshapik
3a150275de Implement injecting of dependencies to an AuthenticationProvider
init() method was added to AuthenticationProvider. It helps to inject
dependecies. Overridable postInitSetup() method was added to
AbstractAuthenticationProvider. A provider can override this to do
any necessary setup.
AbstractAuthenticationProvider ::setLogger(), ::setManager(), ::setConfig(),
::setHookContainer() were soft deprecated. Now developers must use
AbstractAuthenticationProvider::init().

Bug: T275030
Change-Id: I6ca63eddac1b177eeadbdcce992e71c44a480160
2021-04-26 15:17:34 +03:00
jenkins-bot
846c4413c3 Merge "Fix NoWriteWatchedItemStore::countWatchersMultiple" 2021-04-24 08:03:24 +00:00
jenkins-bot
adb08649b9 Merge "Convert MWBasicRequestAuthorizerTest to a unit test" 2021-04-24 03:33:09 +00:00
jenkins-bot
68a6512ad3 Merge "Reduce mocking LoggerInterface" 2021-04-24 03:33:03 +00:00
jenkins-bot
d7dac1bf4a Merge "RevisionStoreFactoryTest: Clean up and convert to unit test" 2021-04-24 03:32:57 +00:00
jenkins-bot
7ae12627a6 Merge "Convert SlotRoleRegistryTest to unit tests" 2021-04-24 03:07:56 +00:00
DannyS712
12ffb90aa8 Convert MWBasicRequestAuthorizerTest to a unit test
Already essentially a unit test, does not use any integration

Change-Id: I705c9e5fb04103f305e26b7cd677cf68fc7b73b5
2021-04-23 23:35:09 +00:00
DannyS712
1d5bac66c4 Reduce mocking LoggerInterface
Use TestLogger when we want to ensure specific
logged messages, or NullLogger when we don't care

Change-Id: Ifebc770933d4f5313d5b8b43a52437dbe1e24432
2021-04-23 22:35:43 +00:00
DannyS712
260f4ea92c Move MimeAnalyzerTest under unit tests
Extends the base PHPUnit\Framework\TestCase
and does not need any integration

Change-Id: I221ffb9d2ed96e240ad1be7f11c311f95883d882
2021-04-23 21:53:55 +00:00
DannyS712
7d896dc2b5 Convert SlotRoleRegistryTest to unit tests
No integration is used in the existing code

Change-Id: I2b454e97e446c68658c8b3efeb9c15a0a4ca23d7
2021-04-23 20:57:46 +00:00
DannyS712
633ec93a8c Clean up WatchlistManager tests
Most of the code in WatchlistManager does not depend
on integration logic, with the exception of
- ::clearTitleUserNotifications adding a DeferredUpdate

- ::addWatch and ::removeWatch using
User::newFatalPermissionDeniedStatus, which uses
MediaWikiServices

Move the majority of the rest to the unit tests, except
for an integration test of the overall basic functionality
that we leave to make sure that the integration with the
actual services works properly.

Also take this opportunity to document why the integration
tests left behind need to be integration test, and fix
the name of some tests to addWach/removeWatch instead of
the old doWatch/doUnwatch.

Explicitely add 'watchlist' to the tables used by the
integration test.

Change-Id: I899ef1618c59c179ed2591149b93969fd935276d
2021-04-23 17:19:34 +00:00
DannyS712
1acd9531d3 Fix NoWriteWatchedItemStore::countWatchersMultiple
Should call the same ::countWatchersMutiple on the
actual store, not ::countVisitingWatchersMultiple

Has been broken since NoWriteWatchedItemStore was
first introduced, see 1ff58fc746

Change-Id: I20ab9a130f5bfe8b888ad08ea5852f13a03184f8
2021-04-23 15:27:56 +00:00
jenkins-bot
89b00fcfbe Merge "Remove unnecessary ->equalTo() from tests" 2021-04-23 14:43:04 +00:00
Thiemo Kreuz
c1ee8250e9 Remove unnecessary ->equalTo() from tests
This is the default anyway when using ->with(). The test code
becomes so much more readable without this, I would like to
argue. Let it just say "with these values".

Because of the way I split my changes into multiple patches
there are a few other changes in this patch I could not split,
e.g. removing unnecessary ->any(). This is the default anyway
and doesn't make the test more specific.

Change-Id: I34990799fa9258ba8dc64c7e78ec43f7903b7681
2021-04-23 12:02:42 +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
DannyS712
ee23dd80df RevisionStoreFactoryTest: Clean up and convert to unit test
Combine single use private methods, simplify mocks,
use a mock ActorMigration to allow making a unit test

Change-Id: I50e18b7727ca78a0ce0504d2b6c978e14d142b6a
2021-04-22 20:16:05 +00:00
jenkins-bot
b57ace7aee Merge "Replace PHPUnit ->returnValue() with ->willReturn() shortcut" 2021-04-22 15:47:14 +00:00
jenkins-bot
29604272e8 Merge "Remove some meaningless $this->equalTo() from tests" 2021-04-22 15:47:04 +00:00
jenkins-bot
5bb19aa157 Merge "Replace ->exactly( 1 ) with ->once() in tests" 2021-04-22 15:38:10 +00:00
Thiemo Kreuz
f10f4e05de Remove some meaningless $this->equalTo() from tests
This is the default behavior anyway when using ->with().

Change-Id: I64b6474280eb7da122eb22fc0afa28cca81e96c5
2021-04-22 10:47:54 +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
Thiemo Kreuz
e2ec44d73f Replace ->exactly( 1 ) with ->once() in tests
It's shorter, the more canonical form, and easier to read
because of this.

Change-Id: I9c68a49c1f31bddfac91a74a6592fe3545ca00a7
2021-04-22 09:42:28 +02:00
Thiemo Kreuz
f36808dddc Use UserIdentityValue in tests where possible
… instead of PHPUnit mocks. The tiny value class is made for
this.

Change-Id: Ie04cde57126fcafabf8906f9644c6e80345d8a48
2021-04-22 09:32:43 +02:00
Cindy Cicalese
b242d49a62 Use WatchlistManager in API classes
Change-Id: I7b2016162e86b455c0102742751981c44d7e829c
2021-04-21 04:41:06 +00:00
jenkins-bot
b72b2973b0 Merge "Move watchlist-related methods from WatchAction to WatchlistManager" 2021-04-21 02:13:17 +00:00
Cindy Cicalese
577824ae7f Move watchlist-related methods from WatchAction to WatchlistManager
Deprecate the watchlist-related methods in WatchAction.

Change-Id: Id235cc483e2f1f3a432e2c26aebc48ae6cd73a0b
2021-04-20 21:44:54 -04:00
jenkins-bot
9f39b1f55d Merge "HtmlCacheUpdater: replace Title in method signatures." 2021-04-19 18:10:57 +00:00
jenkins-bot
022b38299b Merge "Remove Title from method signatures in User" 2021-04-19 02:52:51 +00:00
daniel
cf6e3c50dc Remove Title from method signatures in User
Bug: T278459
Change-Id: I78c6a1b57e1b8383905e6650ab16085d28a38769
2021-04-16 15:37:05 -04: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
daniel
c1eb74603a Remove Title from public interface of OutputPage
Bug: T278459
Change-Id: If455682540faf8d42fd8a14e0ef09bac24f72db4
2021-04-16 10:01:56 -07:00
jenkins-bot
e6a88353de Merge "Do not use a NullLogger when no handler is declared" 2021-04-16 16:40:15 +00:00
daniel
90e1469012 HtmlCacheUpdater: replace Title in method signatures.
We still rely on Title internally, until the logic for mapping Titles to
URLs has been factored out.

Bug: T279796
Change-Id: I6abf30b8359fbe306c569ea290a64ed0d4105d71
2021-04-16 11:04:26 +00:00
Func
278e195ab7 Set $status->value in EditFilterMergedContentHookConstraint::checkConstraint() properly to display error message
When hook handler return false and use $status->fatal() to put up a error,
we should set $status->value to self::AS_HOOK_ERROR_EXPECTED to show edit form
and display error message.

Bug: T273354
Change-Id: I02d643c5cb1978da8ab749856493d75137b6cb02
2021-04-15 22:01:30 +02:00
DannyS712
d638b0c2cf Move remaining ParamValidator tests to unit tests
Change-Id: I82d18a3c8a4c68c7456d5e5e4979d6445185f1c8
2021-04-15 14:51:39 +00:00
jenkins-bot
c32c06887f Merge "Move most ParamValidator tests to unit tests" 2021-04-15 14:49:13 +00:00
Tim Starling
647e6be277 Remove MovePageFactoryTest
The tests in this file make no sense now that MovePageFactory no longer
exists. Obviously you do not pass all constructor arguments to
PageCommandFactory through to MovePage.

To make it pass against the following commit, I could update the
getExtraClassArgCount(), but that would be necessary pretty much every
time the constructor argument list of either class is changed. There's
no reason to think a difference in argument count is an error anymore.

Change-Id: Id4f4b43d47217ebb0111800d7ccb9855d56f7abb
2021-04-15 14:05:49 +10:00
DannyS712
ec3d351c62 Move most ParamValidator tests to unit tests
No integration needed, except for maybe in
the tests for the UploadedFile* classes, which
are left where they are for now - those tests
deal with the file system.

Change-Id: I4f38557d524b2d36dea36a926d0f31e1afed5c7a
2021-04-14 23:57:20 +00:00
jenkins-bot
686abd50bf Merge "Convert WatchlistManager to use Authority and PageIdentity" 2021-04-14 23:18:35 +00:00
jenkins-bot
ccb2e92fe8 Merge "uuid: Simplify GlobalIdGenerator by removing QUICK_VOLATILE flag" 2021-04-14 22:45:40 +00:00
Cindy Cicalese
200e9abbd0 Convert WatchlistManager to use Authority and PageIdentity
- take PageIdentity in addition to LinkTarget where appropriate and
  deprecate taking LinkTarget
- take Authority in addition to UserIdentity where appropriate and
  deprecate taking UserIdentity

Change-Id: I410a4c26b25e086e1e6abb293789d718de4aa20a
2021-04-14 18:21:58 -04:00
jenkins-bot
5752dcbe0b Merge "Reset fake timestamps for unit tests too" 2021-04-14 21:45:02 +00:00
Aaron Schulz
bb1fdb91ac uuid: Simplify GlobalIdGenerator by removing QUICK_VOLATILE flag
Change-Id: I4f504be5d805281eeb9400cd4fd783c50b561b87
2021-04-14 21:40:35 +00:00
jenkins-bot
58fb3289f4 Merge "Convert MWLBFactoryTest to pure unit tests" 2021-04-14 21:26:25 +00:00
jenkins-bot
45966b9573 Merge "HTMLFileCache: replace Title in method signatures" 2021-04-14 21:26:17 +00:00
DannyS712
438b3924b4 Reset fake timestamps for unit tests too
Discovered in another patch that while integration
tests automatically reset fake timestamps afterwards,
unit tests don't. Add a shared method to MediaWikiTestCaseTrait
to reset for both integration tests and unit tests

Do the same for TypeDefTestCase

Change-Id: I677aec4e60894053fc554f2e13b069fb599858f2
2021-04-14 21:01:33 +00:00
jenkins-bot
9c74a067c3 Merge "Factor out rollback logic from WikiPage" 2021-04-14 20:22:27 +00:00
Petr Pchelko
46db19ecdf Factor out rollback logic from WikiPage
Change-Id: I95da91875fcf2f53143c315560e35ccd5ffbf4b3
2021-04-14 11:49:07 -07:00
daniel
185d535457 HTMLFileCache: replace Title in method signatures
Bug: T278459
Change-Id: I77fb37c1aec17d3e51056f85fdff59821f326cc3
2021-04-14 18:49:45 +02:00