Commit graph

15 commits

Author SHA1 Message Date
Bartosz Dziewoński
3bb9d855c1 Remove error printing in MWException
Was deprecated in I66d896f6f229b90e6ba9949311b56a6b6ab3da3d.

Bug: T353444
Change-Id: I004b1b87a7ef1a908123369842792d940b7d8079
2024-04-25 11:58:53 +00:00
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +00:00
Bartosz Dziewoński
825bf602a5 Deprecate error printing in MWException
It's now deprecated to use the individual error printing functions in
MWException or to override them. Printing MWException now works the
same as any other exception, and happens in MWExceptionRenderer.

It's still allowed to override MWException::report() to replace the
entire error page, for example in ErrorPageError.

Bug: T353444
Change-Id: I66d896f6f229b90e6ba9949311b56a6b6ab3da3d
2024-01-10 16:38:43 +01:00
Amir Sarabadani
d8e542abf9 Reorg: Move three output related classes to includes/Output/
And namesapce them:
 - StreamFile
 - OutputHandler
 - OutputPage

Bug: T321882
Change-Id: Iedf8d88c595e580f2d8f0734c92aa5c45618ba33
2023-09-05 19:36:42 +01:00
Thiemo Kreuz
61ae7504df Replace trivial usa of mock builder with createMock() shortcut
createMock() does the same, but is much easier to read.

A small difference is that some of the replacements made in this
patch didn't use disableOriginalConstructor() before. In case this
was relevant we should see the respective test fail. If not we can
save some CPU cycles and skip these constructors.

Change-Id: Ib98fb06e0fe753b7a53cb087a47e1159515a8ad5
2022-07-15 16:43:48 +00:00
DannyS712
fcecd9c5e4 Remove sepate getMockWgOut() method in exception tests
Single use method in both BadTitleErrorTest and ThrottledErrorTest,
merge into only place that needs it

Change-Id: I1a5c2ed2ac76ae821758d50b7d6378acb98af861
2021-03-08 03:54:14 +00: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
Daimona Eaytoy
2e02e7fdb1 Fix most PHPUnit 8 compat issues in DBless tests
This patch fixes all PHPUnit 8 compat issues in the DBless suite, aside
from assertArraySubset.

Bug: T192167
Change-Id: Iea782386509b9e579f06d63687669e14bc437fad
2019-12-15 00:24:21 +00:00
Brad Jorsch
4a275ea53c Don't write exceptions to STDERR from BadTitleErrorTest or ThrottledErrorTest
It's annoying and pointless. Instead, have MWException write them to
standard output where we can catch them with ob_start().

Bug: T170028
Bug: T170029
Change-Id: Icd99c1c39d4a30d78c511d33948ef639e1b92455
2018-02-16 09:01:51 +00: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
addshore
044f6418b1 Switch name to username in @author tags
From now on I will simply use addshore
everywhere to keep things uniform...

Change-Id: Iaf441b2d7a67a12c20529f0e9c7b47819f4abfae
2016-01-27 10:59:31 +01:00
umherirrender
9060817873 Use setMwGlobals on execption tests
Simplify $wgOut handling by setting the global with setMwGlobals

Change-Id: I64bf23e657ea82316e1cd71df6491322e537d5d1
2014-11-13 21:11:18 +00:00
Faidon Liambotis
acdfea8836 Set ThrottledError's response code to 429
ThrottledError currently returns a 503, which in turn results into
badly-written spambots occasionally flooding our 5xx logs and graphs.

There is no reason, however, for ThrottledError to return a 5xx in the
first place: it's a user-generated error (user hitting a rate limit and
being throttled), not a server error. 5xx error codes in general have
many other implications, such as frontend caches treating this as a
backend failure and potentially retrying the same request, so they are
unsuitable and undesirable for the ThrottledError exception.

RFC 6585 (April 2012, updates: 2616) has added a special 4xx code
specifically for rate-limiting, 429 Too Many Requests. As the
description of that code matches exactly what ThrottledError was meant
for, switch it to using 429 instead.

Note that there is a chance 429 might be mistreated and not showed by
older or badly-written user agents as it's fairly new and not part of
RFC 2616, the original HTTP/1.1 spec. However, the last paragraph of
section 6.1.1 of RFC 2616, specifically covers the issue of UAs &
unknown status codes: it dictates that applications MUST understand the
class of any status code and treat them as the "x00 status code of that
class" (here: 400), MUST NOT be cached, and "SHOULD present to the user
the entity returned with the response, since that entity is likely to
include human-readable information which will explain the unusual
status".

Change-Id: I46335a76096ec800ee8ce5471bacffd41d2dc4f6
2014-03-28 12:25:59 +02:00
umherirrender
2000672ac3 Fixed spacing
- Added spaces after if/foreach/catch
- Added new line before end of file
- Added or removed spaces before/after parenthesis, comma
- Added spaces around string concat

Change-Id: I0590070f1b3542108e242730e8d9a3ba9831e94f
2014-03-20 20:37:30 +00:00
addshore
87aee66672 Add test for ThrottledError exception
Change-Id: Ia98d6c24ce56c6707a67498e26107250d427a3bf
2014-02-25 22:35:06 +01:00