Commit graph

233 commits

Author SHA1 Message Date
Alexander Vorwerk a34a51fa47 Avoid using WikiPage::factory()
WikiPage::factory() is deprecated since 1.36 and should be replaced
with WikiPageFactory::newFromTitle().

Bug: T297688
Change-Id: Ie333c616c46a71430f8c18db85bdd64c13379ef0
2021-12-18 16:33:19 +00:00
C. Scott Ananian 1af638f8db Replace use of deprecated ParserOutput::addWarning()
Bug: T293515
Depends-On: I6a7c04c67ac586ab00d4edcbb3d09485a7794e23
Change-Id: Ib51c75e38b9bf490b4ded481ee92ede0949f272e
2021-10-16 01:17:20 +00:00
C. Scott Ananian c0963eced7 Replace use of deprecated ParserOutput::{get,set}Flag()
Depends-On: I39bc58d207836df6f328c54be9e3330719cebbeb
Change-Id: I906a5970088965c187bf653267ac4b369dac9b9b
2021-10-15 23:41:06 +00:00
daniel 1a24ade06c Use mock restriction store in tests
This fixes an incompatibility introduced by Ia73ea587586cb69eb5.

Depends-On: I1f24703b80566220ac6fe8ee500e838ed7fd29af
Change-Id: I31ca0a8987f9694bc3b312a48c2c111ceda6fa3e
2021-09-10 14:50:04 +00:00
libraryupgrader 29f4c03de1 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0

npm:
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* glob-parent: 5.1.0 → 5.1.2
  * https://npmjs.com/advisories/1751 (CVE-2020-28469)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: If0310d25d0380a6d4e936e666729e6a65a90a710
2021-07-23 21:34:32 +00:00
DannyS712 cd885e83cb Use WikiPage::doUserEditContent() instead of ::doEditContent()
::doUserEditContent() is available since 1.36 as a replacement
for ::doEditContent(), which has been deprecated. Bump the
required version of MediaWiki to 1.36 accordingly.

Results in passing a user where previously the fallback
to $wgUser was being used.

Bug: T255507
Change-Id: I11e4a305e66935ea1d1b4692561fb5d49871a729
2021-06-24 05:58:13 +00:00
libraryupgrader 31335d4602 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

npm:
* grunt: 1.3.0 → 1.4.0
* lodash: 4.17.19 → 4.17.21
  * https://npmjs.com/advisories/1673 (CVE-2021-23337)
* hosted-git-info: 3.0.7 → 3.0.8
  * https://npmjs.com/advisories/1677 (CVE-2021-23362)
* postcss: 7.0.35 → 8.2.15
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)

Change-Id: If78d89f465be14d63824f2701daca5a257edba30
2021-05-13 08:26:27 +00:00
C. Scott Ananian 96da9fe0e9 Replace use of Parser::$mStripState, deprecated in 1.35
The replacement, Parser::getStripState(), was added to MediaWiki in
1.34.

The extension.json for this extension already requires MW >= 1.35.

Bug: T275160
Change-Id: I062ac8b69756a7ad35d8cc744b4735fd2e70f13e
2021-02-25 03:03:29 +00:00
Umherirrender f129988d82 Improve function and property documentation in tests
Change-Id: I81e957035175f9fe0dad9494c92ab342283df983
2021-01-29 08:06:12 +00:00
C. Scott Ananian 93662aabf1 TitleLibraryTest: Don't use deprecated InterwikiLoadPrefix hook
Use $wgInterwikiCache to setup interwiki prefixes for testing instead
of the deprecated InterwikiLoadPrefix hook.  This simplifies the test
setup quite a bit as well.

Bug: T270444
Change-Id: Icb772fcee07103a06548011ddd653487477ebfcc
2020-12-22 20:41:24 +00:00
Umherirrender cb39fead91 Add missing @var and improve documentation
Change-Id: Idb7ff848ba702eac2cde31c6198a70311e3bdb69
2020-12-22 01:15:00 +00:00
Derk-Jan Hartman d65c61e49b Error message for formatNum should not refer to formatDate
These new error messages were referring to formatDate instead of
formatNum.

Change-Id: Ic20a5a5515ee55d46087449627138cc779909ec3
Follow-up: Ib7706ad40f7ee2da6ab7c6b2dab6ae8d129dab52
Bug: T268758
2020-11-26 14:12:15 +01:00
DannyS712 d3e3124652 Fix a typo: emtpy -> empty
Bug: T201491
Change-Id: I447b318a7d898a083fc4f9129efbf4cac5517972
2020-11-22 14:22:33 +00:00
libraryupgrader 14046a6414 build: Updating mediawiki/mediawiki-phan-config to 0.10.4
Additionally, unbreak master build after core change T10327.

Change-Id: I8fb240c9b8291d907b857f17d6f4960a24de2ef7
2020-11-20 17:01:25 +00:00
C. Scott Ananian 078253bd06 library: Lua formatNum should check that the value is not infinity or NaN
The core formatNum method only works on strings which pass `is_numeric`,
not NaN and +/- infinity.

Bug: T267587
Change-Id: Ib7706ad40f7ee2da6ab7c6b2dab6ae8d129dab52
2020-11-16 17:44:17 +00:00
Reedy 664c866980 Use tab indenting consistently
Change-Id: I7387882d8ece9bb7f2eac8891c010a2fcb0a57b0
2020-10-23 16:39:12 +01:00
C. Scott Ananian 6a999fb6aa Fix a lua test which uses a deprecated Message formatter feature
Message formatters which expect numeric arguments should not be passed
non-numeric arguments; they will emit a deprecation message if they are
given such (core commit 448a51ae083abc1ca9fccb51a5a533e0fe9f8b71).

Change-Id: I431538873083e14dbd85cb1c8889c3a8350aa75a
2020-10-23 11:10:16 -04:00
Umherirrender 99ab75226b phpcs: Fix SuperfluousVariadicArgComment
Change-Id: Ib14f2aa18e43ef7ae621b6281fecd47e8bd3899c
2020-06-27 13:45:24 +02:00
libraryupgrader d10519de40 build: Updating mediawiki/mediawiki-codesniffer to 31.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.VariadicArgument.SuperfluousVariadicArgComment

Additional changes:
* Replaced "jakub-onderka" packages with "php-parallel-lint".

Change-Id: I97d1101854d87f7d0d4c8f14b629bee75df6030d
2020-05-30 06:09:47 +00:00
Brad Jorsch 34fc672f6d Add tests and type checking for mw.addWarning()
Testing was overlooked when this was added in Ibdd2506f.

Change-Id: Ie17020e3082668180dfa1d6532946891ea7951ea
2020-05-08 17:05:11 +00:00
libraryupgrader 9facd741cc build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 29.0.0 → 30.0.0

npm:
* eslint-config-wikimedia: 0.15.0 → 0.15.3
* grunt-stylelint: 0.14.0 → 0.15.0
* stylelint-config-wikimedia: 0.9.0 → 0.10.1

Change-Id: I684372efb0248862700184546a5172bfd6d81ae0
2020-04-22 19:07:11 +00:00
C. Scott Ananian a73ac7bd4e Don't invoke Parser::__construct directly
This has been deprecated since 1.34.  Modern code should use the Parser or
ParserFactory service.

Change-Id: I74efda708470efeb82f8f80346ec1ee7e9fd8f2b
2020-04-16 16:32:58 -04:00
James D. Forrester 4a9b2e61e7 tests: Mark non-LuaSandbox tests as @group Standalone
This means that these tests are only run for test runs on this repo,
and will not be run when this repo is included in CI as a dependency
of any other repos, or the Wikimedia-wide gate. Any changes to other
repos are implicitly assumed to be unable to break these tests.

Bug: T125050
Change-Id: I7b77c0627f3fbe9dfbbf3d63cbd57e943d328555
2020-04-09 12:59:56 -07:00
C. Scott Ananian 5565d3d3d2 Update parserTests to v2 (tidy by default)
Bug: T174199
Bug: T249194
Change-Id: I23ccb612c940b98ca9da46a2e0848ccfe70e695d
2020-04-02 13:50:52 -04:00
Umherirrender 92587641dc Use MediaWikiServices::getContentLanguage()
This required MediaWiki 1.32

Change-Id: Iff717eba8f4fad1e80229ebcf317ceec81667846
2020-03-16 17:58:26 +00:00
DannyS712 fb850e853c Don't fall back to global $wgUser when creating ParserOptions
Pass a user when relevant, or use ParserOptions::newFromAnon()

Bug: T246861
Change-Id: I44adb6d5c037de2fb05573cde3c7356cb73e8b42
2020-03-07 02:33:24 +00:00
Brad Jorsch 66f83331db Record vary-page-id when ID is accessed via mw.title
This triggers a needed reparse when a new page is created using a module
that accesses the page ID.

Bug: T237746
Change-Id: I5564c2e896dd2a025c5a886ca478c377fac83e74
2020-02-13 17:24:41 +00:00
Brad Jorsch 633ff1ff2d LuaStandaloneInterpreterTest: Use assertEqualsWithDelta
Using the $delta parameter to assertEquals was deprecated in PHPUnit 8.

Change-Id: Iab5ead5a075bf7481a972b3b9e94cc3e754f1cd3
2020-01-23 11:53:33 -05:00
Daimona Eaytoy 2e1306fa45 Kill hack for the PHPUnit migration
Bug: T192167
Change-Id: Ic86f6fc67555d2e678ce46f6ad34a25236b560af
2020-01-23 16:22:40 +00:00
Brad Jorsch 3a19bb8b0c Document a lot of methods
Clear up a bunch of phpcs ignores by documenting many methods.

Also remove Scribunto_LuaError::setLineMap(), which has apparently never
been used since it was added in Ia51f439e.

Change-Id: I763bcdbc7edbbb8e4600495a03acca3439fc0ec9
2020-01-17 23:03:03 +00:00
Max Semenik 0d6a4da3d5 Make tests pass on PHPUnit 8
Bug: T192167
Change-Id: Idf87f4c0f0d74848a0cc8f131a84c87e8eeb7809
2020-01-16 16:04:33 +03:00
libraryupgrader 6adb1c423b build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.WrongStyle

Change-Id: Ifa2c7a7febc1e06c28318305cfef0b0103c6e8eb
2020-01-14 14:49:35 +00:00
Brad Jorsch 8a8e51d8c7 Set $wgFragmentMode for UriLibraryTest
It affects the behavior of mw.uri.anchorEncode()

Change-Id: I3a704507cda79a2a48ec58ce9b7500667ea0dda3
2020-01-02 14:51:11 -05:00
Umherirrender ef8aff71ec Use class name resolution to refer to class names
::class is validated by phan and avoids misspelled class names

Change-Id: I613d5df56fcee6099e4294f5c6df078aafad1210
2020-01-02 16:59:55 +00:00
Umherirrender 9c6f6f905a Split all classes in own files
Move autoload entries for test to TestAutoloadClasses key

Change-Id: Ie705db0e7225600b7b498cfa134733a65f1ae1c9
2019-12-21 10:20:18 +01:00
Florian b0103abfed Fix type after upgrading to phpunit 7
See I77ea560f4a5344bd1c356ecc3e7857968ad829b8

Change-Id: Ie9c83cf44e6555a9ae1f3182fdc3cc4269329fa7
2019-11-21 17:55:05 +01:00
Brad Jorsch 0ee41431c2 Don't error if someone returns a built-in function from their module
This is getting close to the point of "don't do that, just wrap the
built-in". But since it's a regression in a recent patch, let's restore
the old behavior here.

Bug: T236092
Change-Id: Ieddc23d942bc91fd0246ae14d8a4af7719e3834f
2019-10-23 08:41:40 +00:00
James D. Forrester de636b2bc6 Collapse uses of now-deprecated wfGetRusage()
It can no longer return false.

Depends-On: Ibab4825b53cd76053f1e4ce8986dfac8054a04f8
Change-Id: Ic70d0304e9cd04d4011671e498146e4b5994cbe9
2019-10-22 11:34:35 +01:00
Brad Jorsch 1617bb3deb Return correct frame from mw.getCurrentFrame in certain edge cases
When an #invoke is passed as an argument to another #invoke,
mw.getCurrentFrame() at module scope will return the wrong frame.

On the PHP side, we need to always reset the frame when processing
an #invoke, not just when there's no frame already. I don't remember why
I82dde43e wasn't done that way, but changing it doesn't make any tests
fail and Scribunto tends to have good tests.

On the Lua side, we need to do the same. The logic wih mw.getCurrentFrame()
using a global that gets stored, modified, and reset in several places
was getting confusing, so this patch reworks the logic to inject a
globalless mw.getCurrentFrame() into each #invoke's cloned environment
instead.

Bug: T234368
Change-Id: I8cb5bc4dc14c9b448c9f267e0539daa75e72af4c
2019-10-14 02:39:13 +00:00
James D. Forrester 4a93593abf build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: Ie4cb4cbee163943cd159eb0ad1d7deaac10e68d8
2019-10-11 11:31:29 -07:00
Max Semenik ba2d2655c4 Remove HHVM check
Change-Id: I15f607a9558c73e92bf4187f56eaad9e15d86dae
2019-10-06 03:02:01 -07:00
Max Semenik 8d9e489778 Update to use PHPUnit 6 class names
Bug: T192167
Change-Id: Ia342080fb1935e54ac42c2b3a07ab9b2a23dde42
2019-10-05 20:17:05 -07:00
Amir Sarabadani 167e4cb60f Clean up most of b/c for phpunit4
We don't support phpunit4 anymore:
https://w.wiki/9UT

Change-Id: I13a4a09e21a13c8f1e29b9e0ca29f05d1eac997d
2019-10-06 00:11:37 +02:00
Amir Sarabadani 248dcae392 Split LuaEngineTestBase to LuaEngineUnitTestBase and LuaEngineTestBase
And use the unit test base on most of the tests, except the ones that need
database. This makes tests considerably faster.

Bug: T230701
Change-Id: Ifbede1e2610c672b4d8a83ce41f74200e0c97be9
2019-08-31 10:51:26 +02:00
Amir Sarabadani 013d57f98c Avoid using MediaWikiIntegrationTestCase on unit tests
MediaWikiIntegrationTestCase (formerlly know as MediaWikiTestCase)
is a very heavy class that resets the database, caches and services between
every test.

Bug: T229180
Change-Id: I3d328d6ba7009e87c0f432a4f8d84d774ea57e5f
2019-08-14 12:31:47 +00:00
Amir Sarabadani 2fd7287512 Add group database to TitleLibraryTest
This test writes to the database (like $page->doEditContent())
so it needs group database

Change-Id: I13316432048090e8d1fd5416eda1c7707f589270
2019-08-03 20:07:09 +02:00
Amir Sarabadani 5be8a76d0f Reduce CPU timeout time in testTimeLimit
This makes these tests the slowest ones to run

Change-Id: Ibfb021d63432f556d1eb5de31341a5bc64d76a85
2019-07-23 14:47:14 +00:00
Brad Jorsch 88be4ec461 LuaInterpreterTest: Limit the busy loop
The test currently runs a busy loop that does string operations 1
billion times, when really it just needs something that takes more than
2 seconds of CPU time. On the other hand, there's another test that uses
the same method to run only 100 string operations for a different test.

Add a second parameter to have it exit early if enough CPU time has been
used, and use it in the first test.

Bug: T220685
Change-Id: I32309f049bcfb2e1310651818ff8674f0a311f40
2019-06-20 12:11:40 -04:00
Brad Jorsch 2e79d0a719 mw.uri: Support IP-Literal syntax
RFC 3986 allows IPv6 literals (and future IP versions) by having the
"host" enclosed in brackets, like `http://[2001:db8::]`. mw.uri should
handle these appropriately.

Bug: T223267
Change-Id: I6f712b87bc376cf606c6c2ebbe80176037d6dddb
2019-05-19 07:55:29 +00:00
Kunal Mehta 8328acb9b1 Upgrade to newer phan
Bug: T216940
Change-Id: If8c2027f6bb7b91504fb51a3d2668b6d929b5da1
2019-03-20 21:19:37 -07:00