Commit graph

5213 commits

Author SHA1 Message Date
daniel
047151c692 Introduce DB schema overrides for unit tests.
This introduces MediaWikiTestCase::getSchemaOverrides,  which can be overwritten
to return information about which tables are going to be altered, and which SQL
files should be used to set up the target schema. This allows tests for a class
that interacts with the database can have a subclass for each supported database
schema.

NOTE: this has only been tested with MySQL.

Bug: T180705
Change-Id: I7a4071072d802a82ecf7d16fbf8882ff8c79287f
2018-01-05 16:23:55 +00:00
jenkins-bot
22583897da Merge "[MCR] Tests for WikiPage::doUpdateRestrictions" 2018-01-05 10:24:19 +00:00
jenkins-bot
21d7f854e3 Merge "Added Tests for ListToggle" 2018-01-05 00:53:46 +00:00
ryan10145
31045933a1 Added Tests for ListToggle
Bug: T183898
Change-Id: I1c6cd8ea21127db56701cc6073fa880b2180d846
2018-01-04 23:08:23 +00:00
Umherirrender
9954607848 Use namespaced version of IDatabase
Change-Id: I49c9b462d316763f90ebf5a95caa388716d6a278
2018-01-04 23:18:55 +01:00
jenkins-bot
d3d8c3fa85 Merge "Moved textbox1 building into TextConflictHelper on edit conflicts" 2018-01-04 21:56:45 +00:00
jenkins-bot
afe317e26d Merge "Add tests for ApiFormatRaw" 2018-01-04 21:05:29 +00:00
jenkins-bot
dcf3a3be60 Merge "Add tests for ApiFormatBase" 2018-01-04 21:01:12 +00:00
WMDE-Fisch
fb9a36c049 Moved textbox1 building into TextConflictHelper on edit conflicts
Factored out some minor parts about building editor CSS classes.

getEditConflictMainTextBox() mainly mirrors showTextbox1 parts not
included were moved to the EditPage.

Change-Id: I671e095acc08382dd0a1c3d167fdaaa623ec5499
2018-01-04 18:21:13 +00:00
Phantom42
92e249c4dc Add tests for ApiFormatRaw
Bug: T183767
Change-Id: I63ce42dd61f6e47f7278c436cad1e4f05e287b04
2018-01-04 19:28:27 +02:00
jenkins-bot
643ebd78e4 Merge "[MCR] fix RevisionStore::checkDatabaseWikiId for DB names with dashes." 2018-01-04 17:27:45 +00:00
addshore
afe3d071a9 [MCR] fix RevisionStore::checkDatabaseWikiId for DB names with dashes.
This is a quick hack, for a proper solution see I6a98684af1d7

Bug: T183914
Change-Id: I45a151a332145438c484e02bbe96cd85dd602b9e
2018-01-04 17:18:41 +00:00
addshore
1583f478da [MCR] Tests for WikiPage::doUpdateRestrictions
Bug: T180989
Change-Id: I75518d5ba34119e88e3e382523583fa8b65bc730
2018-01-04 11:28:01 +00:00
jenkins-bot
ba00b23a1d Merge "ApiComparePages: Add 'fromsection' and 'tosection' parameters" 2018-01-04 07:01:31 +00:00
Brad Jorsch
a8f5964cfe Add tests for ApiFormatBase
Ensuring proper behavior of the base class lets comprehensive tests of
subclasses be simpler.

This also adjusts ApiFormatTestBase to be a bit more usable, passing an
array of options through to encodeData() instead of just a class name.
And removes the unused 'SKIP' from testGeneralEncoding, but allows
expecting an exception (for use in I63ce42dd).

Change-Id: Ib2a1fa0b04860b09105376881ff8411f9534c453
2018-01-03 16:08:12 -05:00
MaxSem
9106f072f1 Merge "Allow programmatic input in Command" 2018-01-03 17:22:28 +00:00
Gergő Tisza
0e211c4f29 Allow programmatic input in Command
Bug: T182463
Change-Id: Ib68180c7af12558686f4864c24fd85f01201d6fb
2018-01-03 19:53:47 +03:00
Phantom42
55a12fcfa7 Add message to the assert of ApiClearHasMsgTest
This adds 'sanity check' message for one of asserts so it is more
clear that it is asserting a precondition.

Change-Id: I10d36c1bf69effd7bd83f4a2259144e9f6e114fc
2018-01-03 04:29:23 +02:00
Sam Wilson
2e248f0bb2 Convert Preferences class into PreferencesFactory service
This deprecates the Preferences class and replaces it with
a PreferencesFactory service. Basically, all code from Preferences
is moved into DefaultPreferencesFactory. All Prefereces methods
are now either shims calling DefaultPreferencesFactory or just
throw exceptions.

Bug: T178449
Change-Id: Id0b2db0c2de0890f6e1609a9a0dca207c4600f99
2018-01-03 09:48:25 +08:00
daniel
33164b828f Add test for DBConnRef
Change-Id: I510b2ed22b3866392592a5df53aa0f3ff6aab750
2018-01-02 15:25:17 +01:00
jenkins-bot
4ad03aa11d Merge "Add @covers tags for more tests" 2018-01-02 12:19:02 +00:00
jenkins-bot
304ef40c33 Merge "HooksTest: Covers Hooks::callHook too" 2018-01-02 11:55:26 +00:00
Kunal Mehta
823a96e2ce Add @covers tags for more tests
Change-Id: If2254b3a9e61e056091779a1ea14237aa7b42eb6
2018-01-02 11:52:42 +00:00
Bartosz Dziewoński
eb6bb6b7b9 Generalize non-digit-grouping of four-digit numbers
In some languages it's conventional not to insert a thousands
separator in numbers that are four digits long (1000-9999).
Rather than copy-paste the custom code to do this between 13 files,
introduce another option and have the base Language class handle it.

This also fixes an issue in several languages where this logic
previously would not work for negative or fractional numbers.

To implement this, a new option is added to MessagesXx.php files,
`$minimumGroupingDigits = 2;`, with the meaning as defined in
<http://unicode.org/reports/tr35/tr35-numbers.html>. It is a little
roundabout, but it could allow us to migrate the number formatting
(currently all custom code) to some generic library easily.

Bug: T177846
Change-Id: Iedd8de5648cf2de1c94044918626de2f96365d48
2018-01-02 11:17:25 +01:00
jenkins-bot
08324f14b4 Merge "build: Updating mediawiki/mediawiki-codesniffer to 15.0.0" 2018-01-02 10:12:27 +00:00
Kunal Mehta
91a1a3ba2f HooksTest: Covers Hooks::callHook too
Change-Id: Id2b97b031b2fcf82a6fba66dae353db1acf340c3
2018-01-02 00:19:21 -08:00
Phantom42
a6dad54007 Add test for ApiClearHasMsg
Bug: T183769
Change-Id: I60c66a7cddaf03a83afd29e536281916ef3eb6d5
2018-01-01 21:19:52 -08:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
Kunal Mehta
75160bdd3b Use MediaWikiCoversValidator for tests that don't use MediaWikiTestCase
Change-Id: I8c4de7e9c72c9969088666007b54c6fd23f6cc13
2018-01-01 08:28:02 +00:00
jenkins-bot
515363c2b7 Merge "Add tests for ApiCheckToken" 2018-01-01 01:18:52 +00:00
Phantom42
1cdcef8a32 Add tests for ApiCheckToken
Bug: T183768
Change-Id: I63ab0413252c7333f73b881995869454c4881a57
2018-01-01 02:06:59 +02:00
jenkins-bot
7040be4f72 Merge "Revision: Handle all return values of Title::newFromId" 2018-01-01 00:05:25 +00:00
Sam Smith
011b458627 Revision: Handle all return values of Title::newFromId
In Revision::getKnownCurrent, fail early when Title::newFromId returns
null to avoid an uncatchable fatal error being triggered.

RevisionStore#getKnownCurrentRevision requires that the title parameter
be an instance of Title.

This follows on from Ia4c20a91.

Change-Id: I9bddafcc5df630d1dff1e2526194186cab7097e5
2017-12-31 20:44:18 +00:00
Brad Jorsch
b7f75836ee ApiComparePages: Add 'fromsection' and 'tosection' parameters
The deprecated diffing in prop=revisions and such used a 'rvsection'
parameter. To enable migration of things using that, action=compare
needs corresponding section parameters.

Bug: T183823
Change-Id: If1a0e2df614c083b37640418c69cca367ce0e895
2017-12-30 12:59:26 -05:00
jenkins-bot
da84b5ccd1 Merge "Decapitalise services folder in tests/phpunit" 2017-12-30 10:42:38 +00:00
jenkins-bot
949592012e Merge "Append leading \ to BlobStoreFactoryTest covers" 2017-12-30 08:37:47 +00:00
Reedy
2c1c823870 Append leading \ to BlobStoreFactoryTest covers
Change-Id: I9b85aa9808c40aa728c6ef186c50bc8cdda08bc6
2017-12-30 05:02:03 +00:00
Aaron Schulz
336454104d Try to opportunistically flush statsd data in maintenance scripts
This helps to avoid OOMs from buffer build-ups in the statsd
factory object. This piggy-backs on to the same checks used
for deferred update runs. In addition, the output() method
checks if the data size is getting large and emits if needed.

Bug: T181385
Change-Id: I598be98a5770f8358975815e51380c4b8f63a79e
2017-12-30 05:01:21 +00:00
Reedy
e1b7824db6 Decapitalise services folder in tests/phpunit
Change-Id: If3bf8fd704eccdde435cb3bfd99ba1c1d3caee1f
2017-12-30 04:09:52 +00:00
Kunal Mehta
dafe195c28 Verify that all @covers tags are sane when running tests
PHPUnit only verifies that @covers tags are correct when actually
running coverage - but that's too slow to do on every commit. And if
even a single tag is incorrect, the entire coverage job will fail. It
also has some different requirements compared to normal tags, like all
namespaced classes must use their absolute name. All of those things
combined make it easy for developers to accidentally break the coverage
job.

There are some external tools that also do this, but those tools are
incompatible with our unusual PHPUnit setup (the phpunit.php wrapper
script).

The MediaWikiCoversValidator trait just calls the same method that
PHPUnit does to validate @covers tags. It is implemented as a trait so
that test cases that implement PHPUnit_Framework_TestCase directly can
still use this.

Bug: T171899
Change-Id: I1d564bcae2bfbedb004c440b90db6341148ed4ba
2017-12-29 20:19:12 +00:00
jenkins-bot
1a0474fa7b Merge "Add @covers tags API tests without them" 2017-12-28 16:53:39 +00:00
jenkins-bot
5f0080715a Merge "Add @covers tags to languages tests" 2017-12-28 16:47:45 +00:00
jenkins-bot
5d422c4e55 Merge "Add @covers tags to miscellaneous tests (#2)" 2017-12-28 16:45:17 +00:00
jenkins-bot
f70f3f285a Merge "Add @coversNothing in places where @covers does not apply" 2017-12-28 16:39:10 +00:00
Fomafix
04ff65fc69 Simplify autocomplete attribute in HTMLForm
Follows-up 7489a3e8

Change-Id: Ifb17c88e39df7031054b3bee83772172c64d0a6b
2017-12-28 16:41:39 +01:00
jenkins-bot
c9c12a28a6 Merge "Add @covers tags to database tests" 2017-12-28 11:08:09 +00:00
jenkins-bot
5d743b0381 Merge "tests: Complete test coverage of HtmlArmor" 2017-12-28 11:05:51 +00:00
jenkins-bot
41a6af704e Merge "Remove useless StatusTest::testCanConstruct()" 2017-12-28 10:42:14 +00:00
jenkins-bot
ec26fb42a9 Merge "Remove resolved todo from MWNamespace test" 2017-12-28 10:40:10 +00:00
jenkins-bot
fb55cef29a Merge "Improve @covers for TemplateParserTest" 2017-12-28 10:34:47 +00:00