This test ends up calling PermissionManager::getUserPermissions, which
calls UserGroupManager::getUserEffectiveGroups, which tries to access
the DB. Since WatchActionTest is not in the Database group, this will
fail after I96ecf9ffd5fbf18db3e15e8774f7dc2fe5b9fd2a.
The test doesn't care about permissions, but only about whether the user
is logged-in, and the check for that happens before PermissionManager is
used (in Action::checkCanExecute). Therefore, we can simply set a mock
PermissionManager to avoid DB queries.
Change-Id: Idcc68b0dea662792f0fd87a8f2052573ad64d003
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.
Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
Mock the relevant services that need the DB instead, when possible. When
not possible, e.g. because DB access is needed for the test to make
sense, add the test to the Database group instead.
Change-Id: Iefbfe00bedc243906c6b860572568343268646cc
This will allow us to treat $wgHooks as a normal config
variable in 1.41.
Note: should be backported to 1.40
Bug: T331602
Change-Id: Iddcb760cf8961316d6527e81b9aa968657d8354c
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
To follow Message. This is approved as part of RFC T166010.
Also namespace it but doing it properly with PSR-4 would require
namespacing every class under language/ and that will take some time.
Bug: T321882
Change-Id: I195cf4c67bd51410556c2dd1e33cc9c1033d5d18
When $wgWatchlistExpiry = true and a user adds a page to their
watchlist, they are currently presented with a combo box where they can
pick a duration of permanent, 1 week, 1 month, 3 months, and 6 months.
This patch adds 1 year to the combo box, and raises the maximum age to 1
year. `api.php?action=watch&expiry=1 year` will now also work.
Bug: T313255
Change-Id: Ia84d6f99584ae23feea3831499d5baee2dd1a024
* In PermissionManager, if a user is anonymous but temporary user
creation is possible, grant elevated permissions at RIGOR_QUICK rigor
level. This is mostly to make skins show "edit" instead of "view
source" to anonymous users in the recommended permissions
configuration.
* Present temporary users as if they are not logged in in various places
in the interface: create/move permissions errors, login, preferences,
watchlist, BotPasswords, ChangeEmail, ResetTokens.
* Show a warning on login/logout about loss of access to the temp
account.
* On login, don't show the temporary name as a suggestion for the login
username.
Change-Id: Id0d5ffa46c3ca5c7b30d540cedbaa528b682aa85
This ensures that assertions work in a uniform way,
and provides meaningful messages in cause of failure.
Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
Shared trait to create services in unit tests to reduce
the mocking needed, beginning with a mock WatchedItemStore.
While this doesn't have everything a full WatchedItemStore(Interface)
supports, it does properly handled the following methods
* getWatchedItem
* addWatch
* removeWatch
* isWatched
* isTempWatched
and properly differentiates between different users and titles,
something the existing mocks in WatchActionTest and
WatchlistManagerTest did not.
Change-Id: I487354542f5322478b9e2c0383cad86453bd5f3e
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
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
* parent::setUp() should be first, and ::tearDown()
should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
to /unit
Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
Watchlist expiry options are stored in a translatable
message that can potentially be malformed or contain invalid
strings representing time periods.
This patch addresses the following:
* Checks that the dropdown options are valid strings
supported by strtotime()
* If no valid options are found it falls back to english
* If a wiki decides to have their own time periods, it
picks the first one from the list and sets it as the
default option in the dropdowns
Bug: T267611
Change-Id: I072a49f1ec4901c8421d2687e14af10c91802668
Normalize watchlist expiry field so that it is set to
ConvertibleTimestamp and the expiry value validation is
handled by the WatchedItem class.
Bug: T260868
Bug: T260009
Change-Id: I3ef31900cfbe7bce23c5ebe1db777a5137ea6167
Use the localized array key rather than the canonical English
array value when retrieving the watchlist-expiry options, so
that the correct language is used in the success message
when watching a page via ?action=watch.
Also add tests for all eight possible messages displayed on this
screen.
Bug: T262547
Change-Id: Ia92266f13d226f6f83199593d5a0f9697ef8a870
When watching via action=watch, there's no need to
save if nothing has changed. This is already how
EditPage does it (by calling WatchAction::doWatchOrUnwatch())
so this change emulates that and also calls
doWatchOrUnwatch() when saving the watch item.
The format that's used in the expiry dropdown (in action=edit
and action=watch) is also changed to ISO8601 so that it
includes a timezone specifier and removes any ambiguity about
what timezone it is in.
The minor change to $changingWatchStatus is just to keep it as
a boolean and not turn it into an int.
Bug: T260009
Change-Id: If94ea7394588646abdac9a5025b0c8903366b521