Commit graph

64 commits

Author SHA1 Message Date
daniel
1d341ab3ce Minor cleanup in backup test cases
Change-Id: Iab2ad5a19b32cd32c2ea9c9dd0b589428056c86d
2018-08-31 14:34:21 +10: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
Adam Roses Wight
c7e8c25e8f New namespace MediaWiki\Tests\Maintenance
Bug: T184775
Change-Id: I041b8eb4f1ef3cf882a8082ff3f208604b8edf96
2018-01-16 15:09:44 -05:00
MusikAnimal
d09554b6ef Add basic IP range support to Special:Contributions
This works by using the new table introduced with T156318.

The only thing that differs from normal Special:Contribs is we are
showing the IP address next to each entry. This is it how it is
displayed if you request to see newbie contributions:
https://en.wikipedia.org/wiki/Special:Contributions?contribs=newbie

For the time being, Special:DeletedContributions does not support
IP ranges. Various other irrelevant links such as Uploads and Logs
are also hidden.

Refer to P4725 for a way to automate creation of edits by random
IPs in your dev environment.

IP::isValidBlock() has been deprecated with this dependent change:
https://gerrit.wikimedia.org/r/#/c/373165/

Bug: T163562
Change-Id: Ice1bdae3d16cf365da14c6df0e8d91d2b914e064
2017-09-05 16:15:33 -04:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Aaron Schulz
6fb5844fec Fix TextPassDumperDatabaseTest::testPrefetchPlain postgres failures
The insertId() method was returning a string, which caused the
returnValueMap not to trigger due to int/string mismatches.

Also add sanity integer cast to WikiPage::insertOn().

Added a few more type docs.

Bug: T75174
Change-Id: Id1090f3e3d0481272a3d13c3af8f2588f06dc912
2017-05-26 21:43:17 +00:00
Timo Tijhof
447ce7e39a phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat
The default will remain PHPUnit 4.x due to PHP 5.5 support.

But, we should allow developers to run tests with newer PHPUnit
versions which are noticably faster (especially for code coverage
reports).

* <https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0>
  PHPUnit 5 deprecates the getMock() shortcut for getMockBuilder()->getMock().
  It instead introduces the shortcut createMock() which has better defaults
  than getMockBuilder(). For example, it sets 'disableArgumentCloning' and
  other things by default.

  Going forward, code should either use getMockBuilder directly and configure
  it using the setter methods (instead of the confusing variadic arguments
  of getMock) or simply use the new minimalistic createMock method. This patch
  backports the createMock method to MediaWikiTestCase so that we can start
  using it.

Change-Id: I091c0289b21d2b1c876adba89529dc3e72b99af2
2017-04-06 00:44:32 +00:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Reedy
1834ee3d8e Fix numerous class/function casing
Change-Id: I23982bfa0548c9ea3bdb432be7982f1563930715
2016-03-18 23:14:49 +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
This, that and the other
4abb459392 Refactor dumpBackup.php and dumpTextPass.php to be Maintenance subclasses
Use the Maintenance class's new $orderedOptions and support for
passing options multiple times. This allows for option "chaining".

The BackupDumper and TextPassDumper class now extend Maintenance, but
should continue to function as before. The public function processArgs()
has been removed and replaced by processOptions(), which takes no
parameters. It is unlikely that users of these classes were calling
processArgs.

Inheritors of these classes that overrode processOption() will now need to
override processOptions() and use Maintenance::getOption() and friends.

The maintenance/backupTextPass.inc file has been deleted. Users should
include maintenance/dumpTextPass.php instead.

Bug: T122587
Change-Id: I2473ee119c185d1b2b00ac4b1e70ee8a6cafe4a3
2015-12-31 20:46:54 +11:00
umherirrender
977c810302 Remove empty line comments
Remove empty line comments as found by the
MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment sniff

Change-Id: I5d694f7a7d3bc97e16300ba03c60ad17f3c912a5
2015-10-14 09:46:44 +02:00
Reedy
7e5b29802e Revert "Swap leading spaces to tabs in backup phpunit tests"
This reverts commit 9ac7cc1300.

Change-Id: I5e05df8d3ab83820008f833f1512689594b81c8a
2015-09-26 19:53:14 +00:00
Reedy
9ac7cc1300 Swap leading spaces to tabs in backup phpunit tests
Change-Id: I821e71ab5c459d11b942f09853dbf4560fbe4d19
2015-09-26 18:54:50 +01:00
Timo Tijhof
e3266ae87e backupTextPassTest: Disable flaky test 'testCheckpointPlain'
Follows-up 9107fb5391.

Ref T70653

Change-Id: I493c0a97bd9b5213a3f1f6ed0b2a6c591fd67d3b
2015-07-07 18:43:39 +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
Timo Tijhof
9107fb5391 backupTextPassTest: Disable testCheckpointGzip test
Follows-up 3d4c0e93, 73c6f525.

Bug: T70653
Change-Id: I2fbb3e8a2ba14751dfc8942d6d1a379faa9c48bf
2015-04-16 04:04:07 +01:00
Christian Aistleitner
73c6f525e0 Fix and re-enable Dumps' checkpoint tests
It seems that fread can now bring 0.5MB into a buffer at once. That
recently made the checkpoint tests erratic, as they relied on the
backupTestPass.inc dump reading loop taking at least two rounds, as
only the second round can trigger creating the second checkpoint file.

By taking advantage of the just added parameter to set the buffer
size, we lower the used buffer size for the tests. Thereby, we force
more than one iteration of the dump reading loop, and finally make the
tests pass again reliably.
Hence, the tests get enabled again.

Bug: T70653
Change-Id: I4449b42558ada8bd579a33b651f2a630a47bfe1c
2015-02-20 00:56:40 +01:00
Christian Aistleitner
7f687cc858 Allow to set stub read buffer size for TextPassDumper
The default buffer size of 512KB seems to unconveniently high for
checkpoint tests. To be able to speed up tests in a follow-up commit,
we allow callers to set the buffer size to use for reads of the stub.

Bug: T70653
Change-Id: Ib63e89fac2abaac8feb542839d4d8e53c917ebe1
2015-02-20 00:56:39 +01:00
Timo Tijhof
3d4c0e933f backupTextPassTest: Disable checkpointHelper test
Bug: T70653
Change-Id: Iafab3094b7526dd646610f34ed9f97cfca868c3a
2015-02-12 08:56:50 +00:00
umherirrender
489d793882 Fixed spacing
- Added/removed spaces around parenthesis
- Added newline in empty blocks
- Added space after switch/foreach/function
- Use tabs at begin of line
- Add newline at end of file

Change-Id: I244cdb2c333489e1020931bf4ac5266a87439f0d
2014-12-05 22:28:07 +01:00
daniel
e596cac514 Apply exportTransform in backupTextPass.inc
This is intended to help us fix 72348: Wikidata uses exportTransform to 
convert old revision content to the new canonical JSON model. This patch
will make this work with the multi-pass dumping process employed to 
generate dumps for dumps.wikimedia.org.

Bug: 72361
Change-Id: Ie9046d1968efc40a02a0812a536f5ef7176af7d7
2014-11-23 16:42:13 +00:00
daniel
da3c19fb17 Change position of <model> and <format> tags in XML dumps.
Bug: 72417
Change-Id: I1d11ce8147cf0bf0018e3931202f533afd4ea93e
2014-10-31 16:49:58 +00:00
umherirrender
cd80906d4a Change @return to start with type
MediaWiki default is "@return type Description", so set a type after
return and start the description with a capital letter. Also use the
more common spelling of boolean.

See http://phpdoc.org/docs/latest/references/phpdoc/tags/return.html for
more about @return

Change-Id: I4e5198822fe92836f9cef9918a9fc1a1a1e0a043
2014-08-20 20:35:41 +02:00
Siebrand Mazeland
4ede8c2e9d Pass phpcs-strict on some test files (11/11)
Woo!

Change-Id: I9fc116dfdf18c2772d047adb5bb14535d0bd39ed
2014-04-24 13:51:05 -07: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
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
addshore
86adcfb8b7 @covers tags for maintenance tests
Change-Id: Ica5f351f71ee5fccae97560f2de6d75fc5da721b
2013-10-24 19:12:22 +01:00
Timo Tijhof
4bd5471ca3 docs: Remove odd colons after @todo
Most were this way already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/todo.html

Ran a find/replace on the odd ones. Also made them all
lower case.

Change-Id: I70c6a69344ddebc603e9a1c1d87e3cc4f4f4c560
2013-05-15 06:23:40 +00:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Siebrand Mazeland
63fffc4fcb Update formatting
10 of n.

Change-Id: I9c17088ac063c14544484176daa00272dcd607b8
2013-02-15 13:29:37 +00:00
btongminh
a0b99c4372 Dump unit tests no longer fail if gzip is not available
Change-Id: Id1890984124028cb44960977c18572f1f6fded4c
2013-01-29 10:31:01 +00: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
daniel
759518bdde Fixing dump tests for non-wikitext in NS_MAIN.
Change-Id: I7945a1b950d3b9b394a336813abc8cd1e288766f
2012-10-12 17:34:29 +02:00
daniel
329d5b3516 Merge branch 'Wikidata' into master.
This introduces the ContentHandler facility into MediaWiki,
see docs/contenthandler.txt.

For convenient review, a squashed version is available at
https://gerrit.wikimedia.org/r/27191

The ContentHandler facility is a major building block of the Wikidata project.
It has been discussed repeatedly on wikitech-l.

Change-Id: I3804e2d5f6f59e6a39db80744bdf61bfe8c14f98
2012-10-09 11:34:24 +02:00
Siebrand
430ecafd87 Merge changes I9d2b148e,Iccf6ea81
* changes:
  Clean and repair many phpunit tests (+ fix implied configuration)
  Fix HtmlTest, XmlTest; Add setMwGlobals method to base TestCase.
2012-10-09 06:27:04 +00: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
Siebrand Mazeland
4c0688f4e8 Update version to 1.21.
Change-Id: I0305bb936104eadd60a2f43cdbf7cb676a55d3cb
2012-10-08 20:47:34 +02:00
daniel
12166f46b4 merged master (2012-09-11)
Change-Id: I8e953eaa22f9d331b0af5e780fbeff6d702b23e3
2012-09-11 11:43:02 +02:00
Alexandre Emsenhuber
c293d90acb Remove usage of wfTime() in benchmarks and backupTextPassTest.php
Left the usage in GlobalTest.php since these are tests for
that function.

This function is only a wrapper to microtime( true ),
so it can easily be replaced and deprecated at some point.

Change-Id: I4f7c1f6705e10e2664f8e9be51d86ed5c8ff1e1c
2012-09-06 19:47:17 +02:00
daniel
9994968774 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 15:20:15 +02:00
Daniel Kinzler
392af46809 Revert "merged master"
This reverts commit 67bfdc7a68
2012-08-29 13:14:49 +00:00
daniel
67bfdc7a68 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 12:06:38 +02:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
daniel
d87135d706 merged master
Change-Id: Iad12ee382d6aeb1fab6fefb611d290b74865ea4b
2012-07-23 22:07:18 +02:00
Aaron Schulz
9cd080744f Merge "adjust method comment for Ia19f1011" 2012-07-09 20:25:37 +00:00
Christian Aistleitner
85000a975b Choose parentids in tests as they are in real dumps
Change-Id: Ib6e9e0a7bebce2a54c039dea16ddc2115776e777
2012-06-27 22:15:57 +02:00
daniel
906a1ba51f [bug 37746] string ids for content model and format.
The content model is stored as a varbinary(32), the format
as varbinary(64).

If the standard model resp. format is used, null is written
to the database instead of the actual id, saving space.

Change-Id: I32659b49a9ad3cb8ecae9019562cff7de42b65f9
2012-06-26 15:56:06 +02:00
umherirrender
278ec75070 adjust method comment for Ia19f1011
Change-Id: I2330c3fb1ef5e4c72fe280d02048668a1199f790
2012-06-23 02:22:48 +02:00
daniel
42770ef54d improved failure message for timing-dependant test case
Change-Id: If3bcc4fb55aea6713e9082e249ddbae4ccd26ffc
2012-06-21 19:11:39 +02:00