Commit graph

214 commits

Author SHA1 Message Date
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
Umherirrender
0347fd0631 Improve some function documentation in tests
Also fix some whitespaces

Change-Id: Ibed50a4f07442d3f299cf545c16f5dbb5f27a411
2021-01-14 22:13:55 +01:00
DannyS712
25db391d53 ParserOptions: Deprecate fallback to $wgUser
Emit deprecation notices in the constructor
if falling back to $wgUser, and fix core
calls

Bug: T246861
Depends-On: I51117931d527a3bdda468b48de577a7faafbcd69
Change-Id: Ibd0a8ffd0494c17a378cc43e6b6164166130adf4
2020-12-16 09:03:29 +00:00
Aaron Schulz
ec86a370e1 Make WikitextContentTest set the context title to avoid failures
This avoids failures due to WikitextContent::isCountable() erroring
out when no title is set for the main RequestContext.

Bug: T257009
Change-Id: I70274e3876c5b7c273110f9afa713a85edcc6339
2020-10-20 16:13:42 -07:00
C. Scott Ananian
36da9ef204 Remove all methods of MWTidy except for MWTidy::tidy()
These methods were either @internal or deprecated in 1.35

Bug: T198214
Change-Id: Ica1d1fdfd2a23a2040eac90c71f6211a4513c916
2020-08-17 18:15:37 +00:00
daniel
a67cad6d0f Create fallback for undefined content models.
This causes RevisionStore to use FallbackContent instances to represent
content for which no content handler is defined.

This may happen when loading revisions using a model that was defined
by an extension that has since been uninstalled.

Bug: T220594
Bug: T220793
Bug: T228921
Change-Id: I5cc9e61223ab22406091479617b077512aa6ae2d
2020-07-22 19:59:09 +02:00
addshore
959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00
jenkins-bot
5f0b7b59e5 Merge "Remove minor pieces of unused code from TextContentTest" 2020-06-08 16:24:13 +00:00
Thiemo Kreuz
6aa6d10e86 Replace all call_user_func(_array) in all tests
There is native support for all of this now in PHP, thanks to changes
and additions that have been made in later versions. There should be no
need any more to ever use call_user_func() or call_user_func_array().

Reviewing this should be fairly easy: Because this patch touches
exclusivly tests, but no production code, there is no such thing as
"insufficent test coverage". As long as CI goes green, this should be
fine.

Change-Id: Ib9690103687734bb5a85d3dab0e5642a07087bbc
2020-06-06 18:41:20 +02:00
DannyS712
d6a38d0f10 Add ContentModelChangeFactory, implemented by PageCommandFactory
Bug: T253080
Change-Id: I62eda1163cd5b0472af912e8dbd5843df8303b8d
2020-05-30 22:36:16 +00:00
Thiemo Kreuz
48c7ac0530 Remove minor pieces of unused code from TextContentTest
* Some function parameters are not used (any more).
* Prefer the much cheaper makeTitle(), if possible.

Change-Id: If6fe444175db843c1839880212673d0b0edefb27
2020-05-29 11:19:19 +02:00
DannyS712
ae2ea61bd0 Add @author tags I forgot to include
Added to files I originally authored; forgot to include at the time

Change-Id: Ibb619352ad346b4cb0ee4d4e60ee21e510ff3e04
2020-04-11 08:13:48 +00:00
jenkins-bot
1afd5f4cb3 Merge "Add tests for ContentHandler::getPageViewLanguage" 2020-03-31 15:18:25 +00:00
DannyS712
cf2c2a0778 Tests: Replace ::doDeleteArticle with WikiPage::doDeleteArticleReal
Not including WikiPageDbTestBase, which is testing the method

Bug: T248000
Change-Id: I1848a79be9e25759654053e88ef956269342f588
2020-03-25 11:34:17 -07:00
Peter Ovchyn
3683e98fcf Add tests for ContentHandler::getPageViewLanguage
Bug: T243744
Change-Id: I69c7618459d9a10cb4ee104b505a1544f4025ddf
2020-03-25 11:37:37 +02:00
DannyS712
3275ef7f5e Tests: Remove unneeded uses of global $wgUser
Tests still pass -> wgUser isn't needed

Bug: T243708
Change-Id: I931f01bc132a5777c27a4296a14fd734a23ca099
2020-03-12 00:52:43 +00:00
jenkins-bot
e005e08768 Merge "Add a ContentModelChange helper, and an api module that uses it" 2020-03-11 22:10:01 +00:00
Thiemo Kreuz
e1dd371e11 Make use of PHPUnit's assertCount feature where possible
… and avoid assertEmpty() on arrays, in favor of a much more strict
assertSame( [] ).

Change-Id: I20266b0b1fc38a3a87666ba1b0793cb2b37d94a9
2020-03-02 15:58:41 +00:00