Commit graph

231 commits

Author SHA1 Message Date
Reedy
8c39aab84b Remove or replace usages of "sanity"
Bug: T254646
Change-Id: Ib192dc5704a14d02c7c374d0ab29bac55c5df24a
2021-11-21 19:35:49 +00:00
jenkins-bot
a8732ab2c5 Merge "ContentHandlerTest: Remove wfGetLangObj and test case from test" 2021-11-12 19:24:01 +00:00
Roman Stolar
5461404d69 Move Content::prepareSave to ContentHandler
Update method name in ContentHandler, soft-deprecate method on Content.
This will require making a semi-backwards-incompatible
change no matter what, we don't really have a great way
of hard-deprecating overriding methods.
Replace all callers of Content::prepareSave in core.

Add tests for ContentHandler::validateSave.

Bug: T287159
Change-Id: I7f23e6e97b1c7d27a6aaefdb88b19b2fc6e8b3a8
2021-11-11 15:40:42 +02:00
Fomafix
da02313ae9 ContentHandlerTest: Remove wfGetLangObj and test case from test
Remove the not needed wfGetLangObj( $expected )->getCode().
This just converts the language code to a Language object and back to a
language code.

Remove the test case [ CONTENT_MODEL_JAVASCRIPT, 'javascript' ].
This test case was successful because CONTENT_MODEL_JAVASCRIPT gets
interpreted as title 'javascript' and 'javascript' gets interpreted as
an invalid language code which gets replaced by
wfGetLangObj( 'javascript' )->getCode() to $wgLanguageCode.

Remove the not needed is_string check. All titles are strings.

Change-Id: I77f6c061190f94e1d6d8b3a0662a497ed2e94795
2021-10-30 12:09:38 +00:00
jenkins-bot
b98d8b6060 Merge "Make SlotRecordTest a unit test" 2021-10-26 14:17:50 +00:00
Roman Stolar
fa5237eb48 Replace Content::getParserOutput call to ContentRenderer::getParserOutput
Bug: T287158
Change-Id: I8a13f45027e08e2d8ddefa140dd47a0c55094934
2021-10-20 12:11:24 +03:00
Petr Pchelko
ac935cb758 Make SlotRecordTest a unit test
Change-Id: I4f5a4bf3703fc490c6c4de45f5a7947b7726aaa1
2021-10-19 20:31:55 -07:00
Roman Stolar
a68e641f9d Move Content::getParserOutput & AbstractContent::fillParserOutput to ContentHandler
Update/Create override classes of ContentHandler.
Soft-deprecate and remove method from Content and classes that override them.

Bug: T287158
Change-Id: Idfcfbfe1a196cd69a04ca357281d08bb3d097ce2
2021-09-29 13:10:51 +03:00
Roman Stolar
642afef215 Hard-deprecate Content::preSaveTransform.
Use ContentTransformer::preSaveTransform instead.
Extensions defining  a content model should override ContentHandler::preSaveTransform.

Bug: T287156
Change-Id: I2a8c60470366fd95d056e0dfa8144f209bb7117e
2021-08-25 16:14:59 +03:00
Roman Stolar
335a3e162c Hard-deprecate Content::preloadTransform.
Use ContentTransformer::preloadTransform instead.
Extensions defining a content model should override ContentHandler::preloadTransform.

Bug: T287157
Change-Id: I766d793881812524fb9762292b7abedeb3cd0769
2021-08-23 13:25:42 +03:00
Roman Stolar
42442e01ff Move Content::preloadTransform to ContentHandler
Update ContentTransformer to access ContentHandler::preLoadTransform through the service.
Prepare object to hold a data that required for ContentHandler::preLoadTranform params.

This is a fully backwards compatible change.
We are doing hard deprecation via MWDebug::detectDeprecatedOverride.

However, with the ContentHandler calling Content and
Content calling ContentHandler, it doesn't matter whether
callers use Content or ContentHandler. This will allow us
to naturally convert all callers.

Bug: T287157
Change-Id: I89537e1e7d24c6e15252b2b51890a0bd81ea3e6b
2021-08-17 15:17:34 +00:00
Petr Pchelko
b782a7e66d Move Content::preSaveTransform to ContentHandler
Create ContentTransformer to access ContentHandler::preSaveTransform through the service.
Prepare object to hold a data that required for ContentHandler::preSaveTranform params.

This will require making a semi-backwards-incompatible
change no matter what, we don't really have a great way
of hard-deprecating overriding methods.

However, with the ContentHandler calling Content and
Content calling ContentHandler, and with the ProxyContent
trick to stop infinite recursion, it doesn't matter whether
callers use Content or ContentHandler. This will allow us
to naturally convert all callers. But won't really allow
hard-deprecation.

Bug: T287156
Change-Id: If6a2025868ceca3a3b6f11baec39695e47292e40
2021-07-29 18:06:02 +03:00
Roman Stolar
891cb86882 Remove Content::getSecondaryDataUpdates() and all usage of it.
Bug: T285729
Change-Id: I22d4e93b3eae652323c8527673d00103f2590bc7
2021-07-22 06:44:09 -07:00
Roman Stolar
b915e23d46 Remove Content::getDeletionUpdates() and all usage of it.
Bug: T285730
Depends-On: Iab6916134308c73f97c2c4fce2c11a08eab95442
Change-Id: If65db7bc768c6991935982d738f8a3a20d8b4c18
2021-07-22 12:40:18 +03:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
DannyS712
b45ddb2ab3 Use WikiPage::doUserEditContent() instead of ::doEditContent()
Results in passing a user where previously the fallback
to $wgUser was being used, mostly in tests.

Bug: T255507
Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
2021-06-28 00:11:30 -07:00
Alexander Vorwerk
623c9561cc Hard deprecate ContentHandler::getForTitle()
ContentHandler::getForTitle() is deprecated since 1.35.

Depends-On: I52c40084d96e88b2edab46c15a10b83b7decf192
Change-Id: I9b3967a59714e231467a08e5a603f600ff1ab7c2
2021-06-20 12:10:40 +02:00
James D. Forrester
64898405cb build: Upgrade mediawiki-codesniffer from v35.0.0 to v36.0.0
Change-Id: I8905d0d69738a1cd6997c104080fdf128d315e8b
2021-04-29 13:00:15 -07:00
jenkins-bot
89b00fcfbe Merge "Remove unnecessary ->equalTo() from tests" 2021-04-23 14:43:04 +00:00
Thiemo Kreuz
c1ee8250e9 Remove unnecessary ->equalTo() from tests
This is the default anyway when using ->with(). The test code
becomes so much more readable without this, I would like to
argue. Let it just say "with these values".

Because of the way I split my changes into multiple patches
there are a few other changes in this patch I could not split,
e.g. removing unnecessary ->any(). This is the default anyway
and doesn't make the test more specific.

Change-Id: I34990799fa9258ba8dc64c7e78ec43f7903b7681
2021-04-23 12:02:42 +02:00
Thiemo Kreuz
b95a07380a Remove meaningless ->expects( $this->any() ) from all tests
It is not entirely meaningless. It might be an indicator that
the number of calls to a method is intentionally unlimited.
This is similar to e.g. an @inheritDoc PHPDoc comment that
marks a method as being "intentionally undocumented".

However, what's the meaning of being "intentionally
unconstrained"? Let's just not have any constraint then.

I feel all these ->expects( $this->any() ) bloat the test
code so much that it's never worth it.

Change-Id: I9925e7706bd03e1666f6eb0b284cb42b0dd3be23
2021-04-23 11:58:58 +02:00
Thiemo Kreuz
40764d277c Replace PHPUnit ->returnValue() with ->willReturn() shortcut
It's the same and makes the test code much more readable, I
would like to argue.

Because of the was I split all the changes I made into smaller
patches this patch contains some other changes in the same
lines where I could not split them off. E.g. removal of
->any(), which is the default anyway and doesn't do anything.

Change-Id: Ib297b989d4aec33b31a4e33fe9d5032865b39be0
2021-04-22 10:37:45 +02:00
Daimona Eaytoy
535d7abf59 phpunit: Mass-replace setMethods with onlyMethods and adjust
Ended up using
  grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g'

special-casing setMethods( null ) -> onlyMethods( [] )

and then manual fix of failing test (from PS2 onwards).

Bug: T278010
Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
2021-04-16 20:15:00 +02:00
jenkins-bot
f2de7593eb Merge "ContentHandlerTest: merge single use private method" 2021-04-01 05:31:51 +00:00
DannyS712
7d398ffde6 Split FallbackContentHandlerTest into separate unit tests
Only testGetSlotDiffRenderer() requires integration
Clean up the code that is being moved, and fix
the remaining covers in the integration test

Change-Id: Ic5926b23daf6738c44d9a5aacb75276f81c51f7a
2021-03-30 14:23:00 +00:00
DannyS712
bd1ca06a5e Delete ObjectFactoryMakeContentHandlerWithSpecsToTest
Its a test for the ObjectFactory code that is underlying
the ContentHandlerFactory class, but that code is already
tested elsewhere extensively - these tests add nothing
for the library, and don't cover the actual ContentHandlerFactory
code either.

Change-Id: I74a141d592a2582be8f6b2b81a392e5eebc27ec4
2021-03-28 14:03:46 -04:00
jenkins-bot
41456132c2 Merge "Revert "Add change tags for media additions/removals"" 2021-03-26 15:42:17 +00:00
Urbanecm
5519a25cf2 Revert "Add change tags for media additions/removals"
This reverts commit 5a0bfa9d98.

Reason for revert: caused a train blocker (T278429) plus Daniel says it's "super expensive"

Bug: T278429
Bug: T266067
Change-Id: I6724b4bc02d29c12c3fe18cc1e8fa17a443257d5
2021-03-26 15:16:08 +00:00
jenkins-bot
e3cdbbdbaf Merge "Add change tags for media additions/removals" 2021-03-22 17:51:04 +00:00
Petr Pchelko
932fbe2464 Convert ContentModelChange to Authority
Change-Id: I76de8e9d4e0ff45fa818409f2af26a1dffc28c60
2021-03-18 20:31:40 +00:00
jenkins-bot
4cc7d1af66 Merge "Split WikitextContentHandlerTest into separate unit tests" 2021-03-16 05:46:01 +00:00
DannyS712
6c19357c6c Split JsonContentTest into separate unit tests
Only testFillParserOutput() and testPreSaveTransform()
require integration

Also cleanup the left behind code

Change-Id: I0e0638eb5ff71374a1103f2d197b75b09e518662
2021-03-16 00:29:32 +00:00
DannyS712
49d1d4e88c Split WikitextContentHandlerTest into separate unit tests
Not everything requires integration
Clean up the code that is being moved

Change-Id: I045641a8b72fa07f21f3a41d84bb24aca55374a0
2021-03-15 23:12:02 +00:00
Matthias Mullie
5a0bfa9d98 Add change tags for media additions/removals
This introduces 3 new tags to track changes in media usage
across articles. These tags are both hidden & disabled by
default.

Bug: T266067
Change-Id: I3e7acafe0b2266cf6e253dfef42fa6c666424469
2021-03-10 09:08:39 +00:00
DannyS712
6e82d0f256 Decouple CssContentTest and JavaScriptContentTest
Hopefully without reducing code coverage

Change-Id: Ib292450eff8296cd788b4bcce2ef8c4670c75a9c
2021-03-09 18:10:45 +00:00
DannyS712
92013e58a3 ContentHandlerTest: merge single use private method
No need for separate getMockContentHander()

Change-Id: Ib6c5d6f2081403c34a48587bdb8e6665d879ee45
2021-03-09 17:29:19 +00:00
jenkins-bot
720edebbba Merge "ObjectFactoryMakeContentHandlerWithSpecsToTest: remove extra line" 2021-02-28 13:18:46 +00:00
jenkins-bot
d4aa1e55c4 Merge "WikitextStructureTest: combine single use methods" 2021-02-27 21:10:23 +00:00
jenkins-bot
07ac805d7c Merge "Make TextContentHandlerTest a pure unit test" 2021-02-27 20:34:39 +00:00
DannyS712
db32346ccd WikitextStructureTest: combine single use methods
Change-Id: Ibdcd4d800a00c2b6c3fc3b9f64bff8e3ba47de32
2021-02-27 00:48:21 +00:00
DannyS712
4a3e5e614e Make TextContentHandlerTest a pure unit test
No integration needed

Change-Id: Ib0c251130f3a4c9a43c0f833eed8b76be05b1def
2021-02-27 00:44:15 +00:00
DannyS712
01f00d8892 ObjectFactoryMakeContentHandlerWithSpecsToTest: remove extra line
Change-Id: I8d59281c0c00d757559fce75081f1bf365ff16fa
2021-02-27 00:41:19 +00:00
DannyS712
db5412962f Make FileContentHandlerTest a pure unit test
No integration needed

Change-Id: I79192e556220e09fc2fc973dbf25d80c0712864f
2021-02-27 00:19:16 +00:00
jenkins-bot
5d66187122 Merge "Make WikiPage a (non-proper) PageIdentity" 2021-02-16 15:51:49 +00:00
Daniel Kinzler
65f89072e3 Make WikiPage a (non-proper) PageIdentity
This is a step towards introducing PageRecord.

We allow WikiPage to be a "non-proper" PageIdentity for now,
but this should be changed to a ProperPageIdentity as soon as
possible.

Bug: T272424
Change-Id: I194c55ec757e655117bccfeb7d6f5d8487b559e5
Signed-off-by: daniel <dkinzler@wikimedia.org>
2021-02-10 11:24:05 +01:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
Umherirrender
62002cdcf1 build: Update mediawiki/mediawiki-codesniffer to 35.0.0
Change-Id: Idb413be4b8cba8611afdc022af59810ce1a4531e
2021-01-31 13:34:38 +00:00
Umherirrender
7691dbeca9 Add missing @param and @return to documentation in tests
Change-Id: Ic663e81cca0bf007804a70772250914a85f1fef4
2021-01-22 19:57:25 +01:00
Petr Pchelko
816e02ae51 Convert RevisionRecord to Authority and PageIdentity
As we convert the RevisionRecord to using Authority,
we no longer need Title instances, so we can convert
that to PageIdentity.

Ideally, we'd part away from using Title at all, but:
1. For foreign wikis PageIdentity has stronger validation,
so calling PageIdentity getId() on Title will break things.
There's still a lot of code depending on lax Title guarantees,
so we keep it.
2. A lot of code still depends on Title, so we try to pass it
through even if we don't nesessarily need to, to save cost
on recreating it later on.

Bug: T271458
Depends-On: I287400b967b467ea18bebbb579e881a785a19158
Change-Id: I63d9807264d7e2295afef51fc9d982447f92fcbd
2021-01-21 13:37:01 -06:00
Thiemo Kreuz
2f66b3754f tests: Remove @param docs from test code that just repeat the signature
These are not only 100% identical to the actual code, but also:
* It's error-prone. Some are already wrong.
* These test…() functions are not meant to be called from
  anywhere. What is the target audience for this documentation?
* There is a @dataProvider. What such @param tags actually do is
  document the provider, but in an odd place. Just looking at
  the provider should give the same information.
* The MediaWiki CodeSniffer allows to skip @param when there is
  a @dataProvider, for the reasone listed.

Change-Id: I0f6f42f9a15776df944a0da48a50f9d5a2fb6349
2021-01-21 03:41:23 +00:00