Commit graph

69 commits

Author SHA1 Message Date
James D. Forrester
5ad77b9a2b MediaWikiIntegrationTestCase: Hard-deprecate assertType()
Already soft-deprecated in 726f10b, which also removed the
unused assertTypeOrValue() method without deprecation.

Change-Id: I0d417bf79f03e899dccfa469f639c04d4cf999cf
2020-01-20 12:39:15 +00:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
James D. Forrester
5e9fca47b9 Coding style: Auto-fix MediaWiki.Usage.PHPUnit*
Change-Id: I86fc55a4fc8ceafe368692173211bbcd6d8581d7
2020-01-10 10:17:12 +00:00
Gergő Tisza
035db6bb59
Share assertArrayEquals with MediaWikiUnitTestCase
assertArrayEquals is a generic assertion that does not have anything
to do with integration testing, and is quite useful for isolated
testing of classes which return unordered sets.

Change-Id: I45af77402a1bc922579aff14b21874ec8680e765
2020-01-07 16:05:40 -08:00
Daimona Eaytoy
726f10bf5d Deprecate and stop using assertType(OrValue)
*assertType is marked as deprecated, and should ideally be removed soon
(i.e. no hard deprecation to follow)
*Most usages of assertType in core were autofixed by using I8ef556b630812aeea77c5606713f53d9af609f1b
*assertTypeOrValue was removed because only used in SiteTest
(codesearch: https://codesearch.wmflabs.org/search/?q=assertTypeOrValue&i=nope&files=&repos=)
*SiteTest::assertTypeOrFalse was removed because unused

Bug: T192167
Change-Id: Icb3014b8fe7d1c43e64a37e0bdaaffec18bb482f
2019-12-15 00:07:59 +00:00
DannyS712
18647a56cd Fix MediaWikiIntegrationTestCase MWException text for using pages
Should say "When testing /with/ pages", rather than "which"

Change-Id: Id2c1409358349f548fc72ac815812ed0bd2b5c47
2019-12-14 00:27:50 +00:00
jenkins-bot
f6d7b482b3 Merge "Use nullable type in function signature" 2019-11-25 17:50:46 +00:00
jenkins-bot
9b7812f8b8 Merge "phpunit: Remove 6And8Compat trait from base classes" 2019-11-21 18:30:05 +00:00
Daimona Eaytoy
3228629f34 phpunit: Remove 6And8Compat trait from base classes
We've decided to switch to PHPUnit 7 to make things easier. This also
means that we shouldn't suppress PHPUnit 8 warnings, otherwise we cannot
know if tests are already compatible with PHPUnit 8.

Note that the trait is not deleted, because it may still be necessary
for single tests -- we're just not including it by default. However, it
is now deprecated, and its use is discouraged.

Bug: T192167
Change-Id: If90e6b6ffe03dfb117ec2b4b13c79983fe1bd0f2
2019-11-21 17:42:39 +00:00
Florian
d7c72bcbe5 Fix broken running tests locally in IDE
The class PHPMaintClass is meant to be loaded when running phpunit.php
which is only done when running tests with it. When running tests by
using the bootstrap file only, e.g. in an IDE, this class will not be
available. Relying on it in other classes will therefore break them.

Moving the required parts to another outside class and add it to the
test autoloader. My feeling says, that adding the PHPMaintClass to the
autoloader says "NOOOO", that's why I added a new one.

There also seems to be some CI builds failing because of that:
https://integration.wikimedia.org/ci/hob/quibble-vendor-mysql-php72-docker/30642/console

Bug: T151101
Change-Id: I33e27009657a951173694fc847973560a1ce967b
2019-11-21 16:28:12 +00:00
Umherirrender
a1f0be1c21 Use nullable type in function signature
Enable the sniff

Change-Id: I9fff860706b0ffb99bb9e78ff26d15bc7c87bdb4
2019-11-20 19:20:38 +01:00
Max Semenik
830548509d Add PHPUnit6And8Compat trait
This is moved out of the main PHPUnit upgrade commit to allow
extensions to silence their warnings beforehand, to avoid breaking
their tests.

Bug: T192167
Change-Id: I60379a933a3a1b018d9f5ef6b51019002389dda3
2019-11-19 00:48:57 -08:00
jenkins-bot
a677dedf53 Merge "phpunit: Add typehints for PHPUnit 8" 2019-11-18 22:18:19 +00:00
jenkins-bot
2f53343fc3 Merge "phpunit: delete MediaWikiTestResult and TestRunner" 2019-11-18 22:17:49 +00:00
Daimona Eaytoy
1c20e1e032 phpunit: Add typehints for PHPUnit 8
Split from Ic14f5debc53e55d67146dc96279d26dfd52b4000.

Bug: T192167
Change-Id: Iec3b9f6f3702578ac76806e73ff0263aa15ac458
2019-11-17 15:15:24 +01:00
Daimona Eaytoy
a184478c14 phpunit: delete MediaWikiTestResult and TestRunner
These were made final in PHPUnit8. Since there seems to be no easy way
to work around that, partially revert
Ibcaf9ca81c8dc63cce6dc6f6fb1fffee19f8804e and start using static
properties again (cfr. T192167#5550034).

Split from Ic14f5debc53e55d67146dc96279d26dfd52b4000.

Bug: T192167
Change-Id: I3fe163738662ae41eb275a0327cb33187290a70f
2019-11-17 15:02:54 +01:00
Umherirrender
97ed35e2e8 Add missing @param and @return to documentation
Change-Id: I48ee838a7ebf4f25a4883d4c7886b39c2d3916af
2019-11-16 13:45:55 +01:00
Zoranzoki21
5aa721c08b Remove prepareServices function from MediaWikiIntegrationTestCase.php as it is deprecated since 1.32
Change-Id: I985d9bdbf69f7c15ab4175bfdf1ff69045974cfa
2019-11-15 04:41:34 +00:00
Daimona Eaytoy
e8664ff7a7 Remove PHPUnit4And6Compat from Test classes
No repo should be using PHPUnit4 features anymore. Removing this trait
from the test classes is the first step towards the complete removal,
see I84694e32c06f1f0f9fb8398b1f2b92d3df599ddb.

Bug: T192167
Change-Id: I60e66259ea920e84573ae99293b005306876b325
2019-11-10 14:08:09 +01:00
Timo Tijhof
0da1ecfd89 profiler: Remove ProfilerOutputDb and profileinfo.php entry point
Bug: T231366
Change-Id: I211c8192200d9af00914f9847608a6daf2898f91
2019-11-06 15:28:00 -05:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
jenkins-bot
3bef9f4e82 Merge "Drop MediaWikiServices::resetLanguageServices()" 2019-10-30 12:14:25 +00:00
jenkins-bot
a1cc2a6e12 Merge "Hard-deprecate LockManagerGroup::getDefault/getAny" 2019-10-30 12:02:39 +00:00
Aryeh Gregor
27a8523cad Drop MediaWikiServices::resetLanguageServices()
There is no reason this should be necessary. Resetting services should
do the trick, together with Language::$mLangObjCache while it exists.
Resetting only a subset of services is fragile and shouldn't be done,
because one of the reset services might later be injected into a service
that's not reset, resulting in bugs.

Change-Id: I8c72b466ba7337649f9256ee6c078c76163f9785
2019-10-29 15:28:18 +02:00
Aryeh Gregor
a5b6268761 Reset services in setService()
Otherwise bugs can be caused by services that hold stale service
references. These are very annoying to track down.

Change-Id: Id9e5a8a0fa3493af0855f4bf1816175ecff6136a
2019-10-29 15:26:34 +02:00
Aryeh Gregor
b0795a2550 Hard-deprecate LockManagerGroup::getDefault/getAny
These appear to be unused. Moreover, their behavior doesn't match their
documentation. getDefault() claims to return NullLockManager if no lock
manager could be found, but really returns it if there's no lock manager
named 'default'. getAny() claims to throw if no lock manager can be
found, but actually throws if no lock manager is named 'default' or
'fsLockManager'. The behavior can be easily replicated by just using
get() yourself and catching any exception.

Bug: T234227
Change-Id: Iad083847f45d6e017a3f7dbfece1f9c155c5efd6
2019-10-29 14:48:44 +02:00
Lucas Werkmeister
cd7e60a535 tests: Reset $wgContLang consistently in PHPUnit tests (take 2)
This a second attempt at 09407afd74, which was reverted due
to breaking Wikibase integration tests.

The original commit had two separate typos that made it not work at all.
Additionally, some things were apparently expecting $wgContLang to be an
actual Language and not a StubObject. To solve that, we just set it
directly and don't use a StubObject. Initialization should be cheap, and
it would probably have been unstubbed on every test anyway.

Bug: T231799
Change-Id: I6d68a22e53e17458d0a63c13bd97c19baff4d1c7
2019-10-29 13:31:47 +02:00
jenkins-bot
979465a0e1 Merge "Convert FileBackendGroup to service" 2019-10-29 09:46:26 +00:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Aryeh Gregor
0d3d6be18d Convert FileBackendGroup to service
Bug: T234228
Change-Id: I25575f565eba122cdf971a5945572811d17fa3e1
2019-10-25 10:46:20 +03:00
Aryeh Gregor
e787246ce8 LanguageFactory to replace Language::factory()
Languages with variants no longer can override the parent's constructor
(which is now used for injecting services). Instead, they need to
override Language::newConverter().

Bug: T201405
Change-Id: I923400d61763cf1db88cb0c3f684c9c10e58032d
2019-10-23 10:48:23 -07:00
Tim Starling
184676c346 Move MediaWikiTestCase::setUp() and tearDown() to annotation hooks
This removes the requirement that setUp() and tearDown() in the derived
class need to call the parent.

Change-Id: I9d4771c28160356ff58884e3a58fa28c8db4e8a5
2019-10-17 20:22:39 -07:00
Aryeh Gregor
043d88f680 Make LocalisationCache a service
This removes Language::$dataCache without deprecation, because 1) I
don't know of a way to properly simulate it in the new paradigm, and 2)
I found no direct access to the member outside of the Language and
LanguageTest classes.

An earlier version of this patch (e4468a1d6b) had to be reverted
because of a massive slowdown on test runs. Based on some local testing,
this should fix the problem. Running all tests in languages is slowed
down by only around 20% instead of a factor of five, and memory usage is
actually reduced greatly (~350 MB -> ~200 MB). The slowdown is still not
great, but I assume it's par for the course for converting things to
services and is acceptable. If not, I can try to optimize further.

Bug: T231220
Bug: T231198
Bug: T231200
Bug: T201405
Change-Id: Ieadbd820379a006d8ad2d2e4a1e96241e172ec5a
2019-10-07 13:18:47 -07:00
Max Semenik
fb06e4cd85 Update tests to use PHPUnit 6 class names
Bug: T192167
Change-Id: I42b0c8908b4968b95b08f861a40af18dc79fa0a1
2019-10-06 01:01:28 -07:00
Max Semenik
dc3fba4619 tests: Nuke everything HHVM-related
Change-Id: Ieccce5ebba25132b2433fc13a575b65a5bd538f2
2019-10-05 12:51:07 -07:00
daniel
387bd38287 MWTestCase: include table prefix in domain for temp table only mode.
This patch allows PageUpdaterTest and DerivedPageDataUpdaterTest to
function properly. Without this patch, the fail when run by themselves.

See phab ticket for analysis.

Bug: T234031
Change-Id: I0804b503bc8b860343a5141c0bfb25fe6855c87d
2019-09-27 13:10:22 +02:00
jenkins-bot
a99171228d Merge "Refactor MediaWikiIntegrationTestCase::resetDB() for readability" 2019-09-20 12:05:18 +00:00
Thiemo Kreuz
3709096126 Refactor MediaWikiIntegrationTestCase::resetDB() for readability
This was inspired by I1b2a6eb. As far as I can tell this patch does not
change anything in terms of behavior. My main motivation was to get rid
of the (possibly confusing) duplications, and turn them into a loop.

The special case where TestUserRegistry::clear() is executed appears like
it might not do the exact same as before, but I'm pretty sure it does.
Before, the special case was executed whenever any of the user tables was
present in the $tablesUsed array originally passed to the method. The
same still happens.

Additional changes:
* Strict type hints in the method signature.

Change-Id: I7f292095c0dac99b9cc0b0aa5ce10703f24f8bba
2019-09-19 15:39:55 +00:00
David Causse
b3b95c3927 Add assertFileContains to MediaWikiTestCaseTrait
Used by CirrusSearch unit tests.

Change-Id: I1b67a9cddfca7fa06fb0b916981d1efde0764018
2019-09-17 17:24:33 +02:00
Adam Wight
1c5d140761 Reset all logging tables together
For example, leftover cruft in `log_search` will cause spurious
associated_rev links between unrelated revisions and log entries.

Bug: T227849
Change-Id: Ie344522229e4142f2c61a267b4d693051b813236
2019-09-13 13:03:07 +02:00
Lucas Werkmeister
74fbb2c5c4 Improve MediaWikiIntegrationTestCase::resetDB()
Test the intersection of $tablesUsed with each set of tables
separately and only update it afterwards.  Without this fix, overlaps
between the table groups would cause additional groups to be pulled in
unnecessarily.

Change-Id: I1b2a6eb47e061dee8a27fb4779809b4684c05104
2019-09-13 13:01:41 +02:00
Adam Wight
4d02bdf897 Rollback change_tag table for tests
When a change tag row is written during a test, it links to content IDs which
may be reused in future tests.  To maintain test isolation, we should include
this table in the rollback for any tests that touch pages.

Bug: T227849
Change-Id: I98fe17e209f6c685ad87e52886a3526f35645d1e
2019-09-05 16:07:06 +02:00
jenkins-bot
a9fb2b3b06 Merge "FileJournal tests" 2019-09-03 11:22:00 +00:00
Aryeh Gregor
5bbcaef231 FileJournal tests
100% unit test coverage for FileJournal and NullFileJournal. 100%
integration test coverage for DBFileJournal. Unit tests for
DBFileJournal once it supports injection.

I removed FileJournal and NullFileJournal from the list of classes that
FileBackendTest tests. It doesn't actually test them, it just happens to
run code from them without checking its correctness at all.

Depends-On: Ic22075bb5e81b7c2c4c1b8647547aa55306a10a7
Change-Id: I46d10ab7b87c23937aa04d7ec1922abfcf3bd611
2019-09-03 10:12:41 +00:00
jenkins-bot
72fa557f45 Merge "Correctly format null error reporting level" 2019-09-02 16:54:48 +00:00
jenkins-bot
97905cc790 Merge "Revert "Reset $wgContLang consistently for tests"" 2019-09-02 11:28:10 +00:00
Ladsgroup
ab0dfd181a Revert "Reset $wgContLang consistently for tests"
This reverts commit 09407afd74.
Reason for revert: It broke Wikibase on master.

Bug: T231799
Change-Id: Ie347abb24183ce3000af4d653ce2343ec7a63290
2019-09-02 11:03:18 +00:00
jenkins-bot
7dd780846c Merge "phpunit: Add more info to LocalSettings.php error in MediaWikiIntegrationTestCase" 2019-09-02 08:55:51 +00:00
Aryeh Gregor
09407afd74 Reset $wgContLang consistently for tests
We already reset $wgParser to a stub in a number of places where it
might have changed. Let's give $wgContLang the same treatment so we can
avoid special-case code.

This deprecates setContentLang(), which is no longer needed. The magic
of $wgContLang is now handled by setMwGlobals() and setService().

This is a follow-up to e4f69ee, which fixed one case of this problem.

Change-Id: I90925ef8b2a7478cce90d474db1b8b4539e45c15
2019-09-01 23:09:26 +00:00
Timo Tijhof
eccceb8f1d phpunit: Add more info to LocalSettings.php error in MediaWikiIntegrationTestCase
Change-Id: I3df68aab40f4b0bb1d5134330347d77ed3399f02
2019-09-01 21:29:02 +00:00