Commit graph

31 commits

Author SHA1 Message Date
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
Kunal Mehta
61e2c04e4e Add @covers tags to miscellaneous tests (#2)
Change-Id: I9116598bee4f4917e02290d273644c13475ff721
2017-12-28 08:52:48 +00:00
Chad Horohoe
25c3c061b5 Fix/hack ErrorPageError to work from non-UI contexts
Right now, ErrorPageError *assumes* you're never running on the cli
or the API. It's kinda a crappy superclass to use for errors unless
you're 1000% sure you'll never hit that code path. Yay assumptions!

Ideally, all of this report() crap is cleaned up and unified across
the like 1192902117 places we have it spread out, but for now just
detect the scenario and delegate back to MWException, which does the
right thing

Bug: T168337
Change-Id: Ia2f490528e128527a7a5ef1f4f5eea36ec9ee810
2017-07-06 20:04:31 +00:00
Gergő Tisza
fcd495ffef Remove $wgExceptionHooks
Skip deprecation period because it is very unlikely that anyone used this:
it does not appear anywhere on gerrit/git, no nontrivial google hits,
the documentation has been flat out wrong for 9 years and no one
noticed it, and the whole feature is fairly useless as you need to declare
it separately for every single exception class you expect.

Change-Id: I85844a238d3135d05eeba10331149624b04bafe2
2017-05-22 00:57:44 +02:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Reedy
1834ee3d8e Fix numerous class/function casing
Change-Id: I23982bfa0548c9ea3bdb432be7982f1563930715
2016-03-18 23:14:49 +00:00
Timo Tijhof
ecb47bfb8f phpunit: Abstract user-lang override in MediaWikiTestCase
Removed redundant set up in these classes (same as their paren
class MediaWikiLangTestCase does already).
* BlockTest
* ExportTest
* MWTimestampTest
* TitlePermissionTest

Change-Id: I28d18cb797bb249981727b02dffce4f0d8682b02
2016-03-09 16:55:50 +00: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
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
54c1e18eec Remove various double empty newlines
The double empty newline is not needed between functions, variable or at
end of file

Change-Id: Ib866a95084c4601ac150a2b402cfa184ebc18afa
2015-12-27 18:55:12 +00:00
Vivek Ghaisas
9f5b6f5aeb Fix whitespace issues around parentheses
Fix issues found by MediaWiki.WhiteSpace.SpaceyParenthesis sniff.

Bug: T102617
Change-Id: Iec7f71e64081659fba373ec20d9d2006306a98f4
2015-06-16 22:14:02 +03:00
aude
acfff1bff1 Add tests for HttpError
Still missing tests for HttpError::report, but would
have caught the issue that Ie216d19 fixed.

Change-Id: Ic35d70af52c3a2d2a25fc3b9952383198db31fb1
2015-06-01 20:42:21 +02:00
Kevin Israel
74faccfa26 Change case of class names to match declarations
Found by running tests under a version of PHP patched to report
case mismatches as E_STRICT errors.

User classes:
* MIMEsearchPage
* MostlinkedTemplatesPage
* SpecialBookSources
* UnwatchedpagesPage

Internal classes:
* DOMXPath
* stdClass
* XMLReader

Did not change:
* testautoLoadedcamlCLASS
* testautoloadedserializedclass

Change-Id: Idc8caa82cd6adb7bab44b142af2b02e15f0a89ee
2014-12-19 16:01:26 +00: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
Timo Tijhof
96771e3a65 test: Clean up data providers that should be static
Follows-up b36d883.

By far most data providers are static (and PHPUnit expects them
to be static and calls them that way).

Most of these classes already had their data providers static
but additional commits sloppily introduced non-static ones.

* ResourceLoaderWikiModuleTest, 8968d8787f.
* TitleTest, 545f1d3a73.
  Odd unused method 'dataTestIsValidMoveOperation' was introduced
  in 550b878e63.
* GlobalVarConfigTest, a3e18c3670.

Change-Id: I5da99f7cd3da68c550ae507ffe1f725d31e7666f
2014-09-18 12:52:44 -07:00
umherirrender
4ee680a8b3 Fixed spacing
- Removed spaces after not operator (!)
- Removed spaces inside array index
- use tab as indent instead of spaces
- Add newline at end of file
- Removed spaces after casts

Change-Id: I9ba17c4385fcb43d38998d45f89cf42952bc791b
2014-07-24 11:53:04 +02:00
umherirrender
092cd8ee31 Fixed some @params documentation (tests)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: Ic8aaf0a93796b97d0fa4617c1f86ff59f4b36131
2014-04-17 20:43:42 +02: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
Mwalker
28326b93bc Merge "Add tests exceptions" 2014-03-05 18:54:08 +00:00
Mwalker
0bc431e7ec Merge "Expand MWException tests" 2014-03-01 00:06:02 +00:00
addshore
4ea70270ae Expand MWException tests
Change-Id: Ia6d579eff66c949f6d4318d09afb143ed78f3ac1
2014-02-27 11:25:19 +01:00
addshore
9e975c4a24 Add tests exceptions
- ErrorPageError
- ReadOnlyError
- UserNotLoggedIn

Change-Id: I9d0088d38e26a6b77e371288f1fa72dbe481cf66
2014-02-27 01:07:03 +01:00
Mwalker
95cbaf35ca Merge "Add test for BadTitleError exception" 2014-02-26 02:52:36 +00:00
Mwalker
f9f8d26946 Merge "Add test for ThrottledError exception" 2014-02-26 02:50:23 +00:00
addshore
89f4c93086 Fix typo in MWExceptionHandlerTest
Change-Id: I9868155c05bc9ca708f72b0ede02d90612136db9
2014-02-25 22:37:40 +01:00
addshore
ceabf35c40 Add test for BadTitleError exception
Change-Id: Ib7c5b9f385aa3fc3e68c55927b0cd5adc82ac1d1
2014-02-25 22:35:48 +01:00
addshore
87aee66672 Add test for ThrottledError exception
Change-Id: Ia98d6c24ce56c6707a67498e26107250d427a3bf
2014-02-25 22:35:06 +01:00
addshore
7a56bf8168 Add scope to Exception class methods
Change-Id: I0097aa9a6d9c178c85706b90484f7a68d3ddbc8b
2014-02-24 21:21:09 +01:00
addshore
557af13086 Split Exception.php
Change-Id: I8273b342f8814887b65227457d0a461d7cd31e75
2014-02-24 21:17:59 +01:00