Commit graph

38 commits

Author SHA1 Message Date
Siebrand Mazeland
5988bdee5d Remove methods in Block deprecated in 1.18
One use found in core or Gerrit extensions which was replaced.

* Block::clear() (deprecated in 1.18)
* Block::decodeExpiry() (deprecated in 1.18)
* Block::encodeExpiry() (deprecated in 1.18)
* Block::forUpdate() (deprecated in 1.18)
* Block::infinity() (deprecated in 1.18)
* Block::load() (deprecated in 1.18)
* Block::newFromDB() (deprecated in 1.18)
* Block::normaliseRange() (deprecated in 1.18)
* Block::parseExpiryInput() (deprecated in 1.18)

Change-Id: Ia8ea6b5248111326f929062346f3868a0550421b
2014-01-11 20:32:24 +01:00
addshore
9c540db2df @covers tags for inclues/*Test
Change-Id: Id28acdd8fe0028bf1e46344cfed131076c8f4c95
2013-10-24 11:54:02 +01:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
freakolowsky
66694155c1 Fixed dumpBlocks fcn
Change-Id: I5db9105a38ffd968cf6a6bac0d723db40ec1f518
2013-04-25 18:34:54 +00:00
csteipp
c38f71a3e7 Use a provider for Xff blocking tests
Move the block insertion to addDBData(), and use a provider to
itterate through the test strings.

This seems like the more correct way to run these tests, although it
still seems hacky, since the db isn't cleaned up after each test.

Change-Id: Ib22ce69797ec03a61b0cc330e8572865290ebd31
2013-04-14 17:08:01 +00:00
umherirrender
15abcf71ca Added/Removed spaces around string concatenation
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !

Fixed windows newline style

Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
2013-04-13 13:36:24 +02:00
Skizzerz
d99bda6ee6 Apply IP blocks to X-Forwarded-For header
Adds a new configuration variable ($wgApplyIpBlocksToXff), which when
enabled will scan the XFF header for IP addresses and check if any of
them have been blocked. $wgApplyIpBlocksToXff is disabled by default.

Bug: 23343
Change-Id: I3faa9c3e8107c6e46cdf21f8c18adda1f42890d7
2013-03-30 05:51:46 -07:00
Aaron Schulz
4ba66e41b5 Revert "Apply IP blocks to X-Forwarded-For header"
Test are now starting to fail for everything.

This reverts commit a5d70e3ae6

Change-Id: I30c9eb9c00be12ff080e85452e17c2a310f03bd3
2013-03-29 19:13:35 +00:00
Skizzerz
a5d70e3ae6 Apply IP blocks to X-Forwarded-For header
Adds a new configuration variable ($wgApplyIpBlocksToXff), which when
enabled will scan the XFF header for IP addresses and check if any of
them have been blocked. $wgApplyIpBlocksToXff is disabled by default.

Bug: 23343
Change-Id: I3e38b94d10600a60d2d4857de54307f34c4662c4
2013-03-29 11:29:17 -07:00
Siebrand Mazeland
ac63001d8e Update formatting
1 of n.

Change-Id: I852729f08bbb0c5e39c2db44362ccdc7f59dcc08
2013-02-14 12:22:13 +01:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
Alexandre Emsenhuber
2b0edc83e9 Setting $wgContLang without changing $wgLanguageCode accordingly is a very bad idea.
This caused about 200 exceptions "MWException: Error in MediaWikiLangTestCase::setUp(): $wgLanguageCode ('fr') is different from $wgContLang->getCode() (en)" on my installation.

Change-Id: I2987db68e22b27d8d36cdae118356fd7612e56a4
2012-10-20 18:15:18 +02:00
Timo Tijhof
181c7cdc8e Clean and repair many phpunit tests (+ fix implied configuration)
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.

Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...

Either way they won't have to anymore with setMwGlobals.

Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)

(Matching the function signature with PHPUnit/Framework/TestCase.php)

Replaces:
 * public function (setUp|tearDown)\(
 * protected function $1(

 * \tfunction (setUp|tearDown)\(
 * \tprotected function $1(

 * \tfunction (data|provide)\(
 * \tpublic static function $1\(

Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.

Fixes:

TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).

MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...

FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"

HttpTest
* Added comment about:
  "PHP Fatal: Call to protected MWHttpRequest::__construct()"
  (too much unrelated code to fix in this commit)

ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
  because regardless of whether wgExternalStores is true or false
  it only uses it if it is an array.

Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-09 03:01:51 +02:00
Antoine Musso
aeacaae2b2 (bug 38333) test blocked user cant createaccount
This patch adds BlockTest::testBlockedUserCanNotCreateAccount() which
test that a new user can createaccount and that blocking him will
prevents to the createaccount right.

Does not solve bug 38333 though!

Change-Id: Ia10e26825d50d47b4770900ee91dea666337f969
2012-07-19 08:19:15 +00:00
Aaron Schulz
e82c2cc7ee Merged r114672 from wmf1.19 plus tests; crosswiki block name/id fix.
Change 1:
* Delete any pre-existing block for the tests
* Renamed test function and fixed comment typo

Change-Id: I4804ccae81dd0455e9d3ddf48960c4b5cd6e4f5f
2012-04-10 09:49:52 -07:00
Aaron Schulz
ea6b51694e r112563: Removed random bogus user IDs passed into to Block constructor in tests 2012-02-28 02:32:59 +00:00
Max Semenik
7abd9f4abd Simplify r101365, this cruft is not really needed 2011-10-31 17:00:29 +00:00
Max Semenik
7e917c79b3 Fixed annoying intermittent BlockTest failures. No surprise we had 'em since blocks set to expire RIGHT NOW tend to expire at that very time:) 2011-10-31 16:54:42 +00:00
Brian Wolff
697487da5e Make testBug26425BlockTimestampDefaultsToTime be tolerrant of up to 2 seconds
difference.

Otherwise if the test happens to be run on a second barrier, it could
falsely fail (like it did just now when codur said some hurtful things
about my code failing unit-tests where it really didn't ;)

Some of the other block tests seem to itermitantly fail for no appearent
reason (null comes back instead of the block)... I don't know why.
2011-08-18 06:23:44 +00:00
Chad Horohoe
bb2b97b39d Mostly revert r89400: not needed since Brion fixed the tests in other ways 2011-08-08 16:08:48 +00:00
Aaron Schulz
a108dbfe8f Reverted r92489 and added/use hideDeprecated() to MW test framework 2011-07-25 16:27:33 +00:00
Aaron Schulz
dac8655a58 Removed testBug29116LoadWithEmptyIp. Fails due to wfDeprecated() call in load() and nothing uses that so it's not worth it. 2011-07-18 22:30:38 +00:00
Mark A. Hershberger
780ba99ac8 random eol w/s annoys me. 2011-06-26 20:04:38 +00:00
Brion Vibber
13b1da185e * (bug 29426) Fix wrong use of Block::load's second parameter in BlockTest
It was accidentally passing a username where it should have passed a user ID, causing PostgreSQL's stricter comparisons to fail, while MySQL's allowed it to run without complaint but returned bad results.
Of course that bug got hidden by the test.... testing the wrong thing... :)

Now correctly loads using the user id instead of name, checks the proper return values, and actually compares the right object.
2011-06-16 17:58:26 +00:00
Brion Vibber
15445510ff Fix for BlockTest -- when setup ran multiple times, the block entry wouldn't get re-saved and we'd end up with null or 0 as our block id.
By first removing any matching block, we can re-insert it at will and have a fresh working block to test.
2011-06-15 20:43:24 +00:00
Platonides
3399ffa031 BlockTest changes $wgContLang, too. 2011-06-14 21:27:07 +00:00
Chad Horohoe
cb569f094f Fix some of the weird freaky interaction between ApiBlockTest and BlockTest.
* By using the same summary for both, we allow both sets of tests to pass with --filter Block
* Just testing includes/BlockTest.php still passes
2011-06-03 06:22:18 +00:00
Chad Horohoe
6f7e2eb71e Followup r89311: rv unrelated changes 2011-06-02 01:28:30 +00:00
Chad Horohoe
89529808d8 Make user right selection in installer actually work, thanks Krinkle for spotting this 2011-06-02 01:26:26 +00:00
Chad Horohoe
5004f09bfa Exclude Block tests until somebody fixes them, also cache listTables() result so we can skip some queries 2011-06-01 22:54:33 +00:00
Antoine Musso
6642e733c6 Use the correct ID when retrieving a block
The ID might be different than the one you expect. Since r88755 the tables
are no more dropped and recreated, thus the autoincrement pointer is not
reset.  A previous test could have raised that pointer, thus the id might
be above the expected value.
This patch track the block ID inserted and use it in the assertion.
2011-05-28 21:25:29 +00:00
Brion Vibber
536fad8f90 * (bug 29116) Fix regression breaking CheckUser extension
Fixes regression from r84475 and friends which made Block->load() and its new front-end Block::newFromTarget() fail when an empty string was passed in as the IP / $vagueTarget parameter to indicate skipping IP-based lookups.
Added phpunit test cases to confirm that both Block->load() and Block::newFromTarget() work when given null (already ok), '' (as done from CheckUser), or false (not seen, but perfectly legit sounding).
Adjusted comparisons to work as expected.
2011-05-24 21:04:50 +00:00
Platonides
fe7ee51f3c Follow up r87210 2011-05-01 23:02:27 +00:00
Happy-melon
cf08b61b1b Follow-up r84475: fixing the warning is easy enough... :D Also some random tweaks to Database.php documentation. 2011-03-21 23:03:11 +00:00
Platonides
84709ae3b3 Follow up r79109.
Don't setup/destroy for databaseless tests.
Make needsDB() return based on the DocComment.
Delayed db init until the test is run, so that it isn't set for excluded tests (the exclusion is done after all the classes are instantiated).
2010-12-29 15:01:47 +00:00
X!
c4befaf28c Add test to supplement Bug 26425 (followup to r79013) 2010-12-28 19:27:34 +00:00
X!
a9ff87335f Add BlockTest unit test 2010-12-28 19:12:27 +00:00