* Use yield in data providers.
* Use consistent inline comment syntax.
* Provide a description of the value in assertion.
This should not be a negated error message, which can be
confusing at times when it describes the opposite of what is
expected. PHPUnit is in charge of explaining the error for most
assertions.
Change-Id: Ib0e138aa029f00ce7f4ce53cf2cb480045e5e8d2
The code didn't properly handle requests for info about non-existing
pages.
Bug: T271804
Bug: T271815
Change-Id: If4e56ff5ecb4a048767833c89847bb58269cad43
This reverts commit 900c6663b0.
Reason for revert: breaks Parsoid CI. Instead of fixing the test in presence of the FlaggedRevs hook, I would rather convert DefaultPreferencesFactory to Authority and fix the tests once instead of doing it twice.
Change-Id: Iaa440a9804c9ed97339e737162ef64ccf29ceb51
Make the caching logic use getWithSetCallback() and simplify
the code given that there is only one Preprocessor subclass.
Also, keep the cached values JSON serializable but rely on
the serialization in BagOStuff instead for simplicity.
Add related class constants for injecting preprocessor flags.
Bug: T254608
Change-Id: I72f9f0c0bc352ed5120469090c71294ff0c24999
Many files were in the autoloader despite having potentially harmful
file-scope code.
* Exclude all CommandLineInc maintenance scripts from the autoloader.
* Introduce "NO_AUTOLOAD" tag which excludes the file containing it
from the autoloader. Use it on CommandLineInc.php and a few
suspicious-looking files without classes in case they are refactored
to add classes in the future.
* Add a test which parses all non-PSR4 class files and confirms that
they do not contain dangerous file-scope code. It's slow (15s) but
its results were enlightening.
* Several maintenance scripts define constants in the file scope,
intending to modify the behaviour of MediaWiki. Either move the
define() to a later setup function, or protect with NO_AUTOLOAD.
* Use require_once consistently with Maintenance.php and
doMaintenance.php, per the original convention which is supposed to
allow one maintenance script to use the class of another maintenance
script. Using require breaks autoloading of these maintenance class
files.
* When Maintenance.php is included, check if MediaWiki has already
started, and if so, return early. Revert the fix for T250003 which
is incompatible with this safety measure. Hopefully it was superseded
by splitting out the class file.
* In runScript.php add a redundant PHP_SAPI check since it does some
things in file-scope code before any other check will be run.
* Change the if(false) class_alias(...) to something more hackish and
more compatible with the new test.
* Some site-related scripts found Maintenance.php in a non-standard way.
Use the standard way.
* fileOpPerfTest.php called error_reporting(). Probably debugging code
left in; removed.
* Moved mediawiki.compress.7z registration from the class file to the
caller.
Change-Id: I1b1be90343a5ab678df6f1b1bdd03319dcf6537f
Refactor the database setup code to share more code between
ParserTestRunner and MediaWikiIntegrationTestCase. Made
`::setupAllTestDBs` static so it can be reused from
ParserTestRunner.
Made ParserTestRunner::addArticle more like
MediaWikiIntegrationTestCase::addCoreDBData(). Some additional
refactoring work could be done here in the future to share more code.
After the refactoring the ParserTestTables hook is no longer necessary
and so has been (soft) deprecated. MediaWikiIntegrationTestCase
clones all database tables, so ParserTestRunner no longer needs to ask
extensions for a list of specific tables it should clone. Cleaning up
the handful of extensions which define this hook will be left to a
future patch set.
Change-Id: I5124789fac333a664b73b4b4a1e801ecc0a618ca
The message cache is originally meant for mw.messages in JS,
which expects non-existent messages to be cleanly omitted.
There is minimal server-side and client-side handling in place for this.
For LESS, however, we were assuming that the blob is complete,
thus not feeding anything to the LESS compiler, thus leading to
a run-time failure where the LESS file can't be parsed at all
due to an undeclared variable.
This could happen sometimes during development or after upgrading
a wiki with a stale LocalisationCache that is still being updated
at that time.
Bug: T267785
Change-Id: I60ff4eb7dce1fee56470acc177afd29ee14b764f
These were left behind during the initial sprint (344481f60d) for
UnitTestCase as it used a global variable. Since then, UnitTestCase
has gained support for resetting these automatically for simple
cases like this. No need to bring in IntegrationTestCase for it.
Change-Id: Id8717c1f4148510ae4a67aec7a2dc0d23679a5ac
In order to break up cyclic dependency between UserGroupManager
and PermissionManager, introduce a lightweight service for checking
group permissions.
Bug: T254537
Depends-On: I99ab3a69c41b3ec6721f9504ad6c77d3122df591
Change-Id: I1acd55c07d07b4a0d43fd838e11374b6d9be98d9
Mutating the interwiki table invalidates the Title codec and in
general leads to a bunch of complications. Easier to just use the
`wgInterwikiCache` mechanism, as a lot of other phpunit tests do.
Bug: T271287
Change-Id: Id1899a89ae6b55e7032befe73990d215370828d8
The expiry is returned as a separate key, 'watchlistexpiry', to match
other APIs, and because some clients might expect 'watched' to be a
boolean (or blank string depending on the formatversion).
Bug: T268834
Change-Id: I227d6ed42e70ba1ddec0139e8198f536dfba0b46
WikiPage::getContentModel() gets called several times per request via
Action::getActionName(), triggering memcached I/O on each call. Excimer icicle
graphs for index.php indicate about 1.26% of time is spent in this method, so
let's add process caching to avoid redundant memcached fetches on subsequent
invocations.
Change-Id: Icdb9ffb849a0a0a264083957431495f8f4fb783e
The previous logic obsfucates the issue about these remaining args
and the fact that they are all deprecated.
This patch makes it clear what's deprecated and the remaining
acceptable args count and position.
Change-Id: Ia7cef161fb990fac700fd2360c170d6ff1c4a8d0
This implementation is based on the upstream code in
\PHPUnit\Framework\TestSuite -- but upstream only calls the
beforeClass/afterClass methods.
Bug: T192167
Bug: T270777
Followup-To: Ia12658554c94497a204b7f65f1a6f7b1fa0310ac
Depends-On: I9eee817abb35f5bd3650d93a11ca208b1e3d8bf0
Change-Id: I9c4d89f9f54808b0415c9af7e7b0ac9df69c2389
Also fix two places where we were using `$this->` in a corner case.
Using `static::` lets subclasses override these method definitions,
at least in theory.
Change-Id: I76a6d10ce463a5bc79e14051a31f469668924494
* parent::setUp() should be first, and ::tearDown()
should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
to /unit
Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
This allows us to move Parsoid-specific extension code from the
Parsoid repo into the extension's own repository and still have
Parsoid parser tests run on it via core's mechanism for running
extension tests.
Factored out some common ParserOptions setup into a common helper
function. There are a number of features still missing from the
Parsoid test runner, which are marked with @todo comments and
phab task numbers.
Bug: T254181
Change-Id: Ifaf53862b96e9127d8f375ad8dd0cc362cba9f5b