Commit graph

104 commits

Author SHA1 Message Date
Daimona Eaytoy
6507d6b2a4 phpunit.php: Move remaining CLI options to env variables
And write release notes for all changes so far.

Note: This should be announced to wikitech-l after merging.

Bug: T90875
Change-Id: I597ed2b5666f4214173609f7e77e23dbc4fd81ae
2021-05-18 12:34:39 +02:00
jenkins-bot
f10562720f Merge "phpunit.php: Remove DB-related options" 2021-05-17 19:15:26 +00:00
Timo Tijhof
e9051b2b99 rdbms: Move setLBFactoryTriggers from doMaintenance to service wiring
This logic is not needed to run on every PHP process and was making
it difficult to run offline maintenance scripts without additional
complexity based on Maintenance::getDbType and DB_NONE.

Instead of skipping this only for DB_NONE, and establishing a pattern
that may spread to other ad-hoc places throughout the codebase, instead
remove this entirely from the eager set up code for all PHP processes
and move it to the service wiring and dependency injection.

That way, it naturally doesn't happen until and unless the DB service
is actually called upon. Scripts and entry point that need to disable
the DB service, can continue to use
MediaWikiServices::disableStorageBackend.

== Impact on SiteStatsUpdate ==

With wgCommandLineMode no longer being read at run-time from a global,
but in service wiring, this means SiteStatsUpdateTest can't change
the behaviour between CLI-like and Web-like, unless it e.g. resets
the 'DBLoadBalancerFactory' service first. Unfortunately, while most
any reset is supported, a reset of the 'DBLoadBalancerFactory' would
be unsupported as that would lose the temporary db clone context and
such, bringing us to either the developer's live db, or a broken set
up altogether. If there is a strong need for toggling oppertunistic
updates off and on at run-time, this could be supported in the
DeferredUpdates class perhaps, but we already have numerous methods
there (incl db begin/commit being a good proxy already), which this
test already used, so for now I've just removed the extra assertion
for this as it wasn't essential to that test.

Bug: T228895
Bug: T238436
Change-Id: Icf29bc484c155f52b6d8f61e5902233a15ba0c6d
2021-04-27 23:35:20 +01:00
Daimona Eaytoy
48ea780132 phpunit.php: Remove DB-related options
I believe we can assume that DB connection options are already specified
in LocalSettings.php, and the 'wiki' option still provides a way to
switch between different credentials.

Bug: T90875
Change-Id: Idc54074307eaafec7314b938ae72cd45b9a3ba78
2021-04-17 13:01:27 +02:00
Umherirrender
cfcb3e4785 Use ::class for class name
This works also for non-existing classes,
because it is resolved on compile time

Change-Id: Id3132341856fb1eb20e8b494bb4acdfe3a394db6
2021-04-08 21:17:42 +02:00
Daimona Eaytoy
4a9ccf222d Simplify / clean up phpunit.php
This wrapper now has two functions:
- Inject MW-specific parameters. This should be resolved somehow.
- Initialize stuff / do sanity checks. This should be moved to the
  PHPUnit bootstrap.

No major step forward can be done until the custom parameters part is
refactored.

Bug: T90875
Change-Id: I49f497e1d7cad5ddb9071bb458e43d0cccdc69e3
2021-04-06 13:49:59 +00:00
Daimona Eaytoy
f85fa939f2 Decouple phpunit.php from Maintenance
This patch makes phpunit.php not inherit from Maintenance, by copying
relevant code directly into this file. Some now-constant conditionals
and other unnecessary pieces of code were removed/simplified.

Some maintenance-generic options were also removed:
- conf, since eventually LocalSettings shouldn't be used at all
- globals, as it doesn't seem useful here
- memory-limit, should be handled separately
- server, doesn't seem useful
- profiler, ditto

'help', 'wiki' and 'db*' were left for now, but might be removed later.

The next step is removing more unnecessary stuff, until this script
won't be needed at all.

As you may notice, there are some leftovers/wrong references in the
script that weren't cleaned up. I didn't want to waste any time doing
that, as they're going to be killed anyway.

Bug: T90875
Change-Id: Id6d7e9dbfe4bc83a6bc8238d048d3b8634e832e4
2021-03-21 13:26:11 +00:00
Tim Starling
20d06b34bb Safer autoloading with respect to file-scope code
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
2021-01-11 11:59:36 +11:00
Tim Starling
bd5420da23 Call ob_start() before running tests
The policy introduced for T206476 creates a subtle failure mode: any test
writing to stdout will cause headers to be sent, causing later tests to
fail when they try to call header().

Instead, call ob_start() to intercept test output. Any buffered output is
still seen when PHPUnit exits.

Bug: T206476
Change-Id: Id085efeab67d1e700ffcbf37868b5107e3a7e5d5
2020-05-25 13:55:28 +10:00
Ammar Abdulhamid
61ff46196e Use class keyword for classname resolution
Change-Id: I149abf837c6bd79f05648b1acbfaf45dc900125e
2020-03-27 09:33:01 +01:00
daniel
d996d69cd4 phpunit: fix parameter mangling
Options intended for MediaWiki must be removed from the argument list
including any arguments that follow them.

Bug: T243523
Change-Id: I8c29ca8c11a16bd43f534310a34bd1cc1f595287
2020-01-23 18:02:53 +01:00
James D. Forrester
7911fa1c38 phpunit: Drop "debug-tests" command, no-op, now unused in Quibble
Bug: T192167
Depends-On: If252e32163b6d75826437ab3b5078ee7aefd401e
Change-Id: Icc0a973a857e2dd9da0786e3fa84db975bf83379
2020-01-15 18:02:37 +00:00
jenkins-bot
fdfa0e9a6a Merge "Fixes for PHPUnit 8 compatibility" 2019-12-11 17:07:21 +00:00
mainframe98
ac48c84224 Allow specifying autoloaded classes for tests
This introduces two new keys to the extension schema, analogous to
the existing autoloader keys: TestAutoloadNamespaces and
TestAutoloadClasses.

The classes and namespaces defined by these keys are only loaded by
the registry when ExtensionRegistry::setLoadTestClassesAndNamespaces
is called. The phpunit wrapper does this in PHPUnitMaintClass::setup.
The unit test bootstrap file calls
ExtensionRegistry::exportTestAutoloadClassesAndNamespaces instead,
similar to how it loads the regular classes and namespaces.

Bug: T196090
Change-Id: I88cf69663362fd599c20649b1df641907a02678d
2019-12-10 21:39:30 +00:00
Daimona Eaytoy
7c9e3db1e6 Fixes for PHPUnit 8 compatibility
Bug: T192167
Change-Id: Ic14f5debc53e55d67146dc96279d26dfd52b4000
2019-12-10 17:02:06 +00:00
Tim Starling
15e058d46e Show the PHPUnit help in phpunit.php --help
Split Maintenance::showHelp() from Maintenance::maybeHelp(), and
override it in phpunit.php. Expose PHPUnit's protected method
Command::showHelp() in our subclass and call it, so that running
"phpunit.php  --help" causes the MediaWiki options to be shown, followed
by the PHPUnit options.

Change-Id: I4687d484e322a465af0492789645819cd8a7b67c
2019-11-25 17:19:20 +11: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
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
Max Semenik
dc3fba4619 tests: Nuke everything HHVM-related
Change-Id: Ieccce5ebba25132b2433fc13a575b65a5bd538f2
2019-10-05 12:51:07 -07:00
Timo Tijhof
29e0183a56 phpunit: Repair GLOBALS reset in MediaWikiUnitTestCase
This code didn't work because the $GLOBALS array is exposed by reference.
Once this reference was broken by unset(), the rest just manipulated a
local array that happens to be called "GLOBALS". It must not be unset or
re-assigned. It can only be changed in-place.

Before this, the execution of a MediaWikiUnitTestCase test stored a
copy of GLOBALS in unitGlobals, then lost the GLOBALS pointer and
created a new variable called "GLOBALS". As such, the tearDown() function
didn't do what it meant to do, either – which then results in odd
failures like T230023

Rewrite it as follows:

* In setup, store the current GLOBALS keys and values, then reduce
  GLOBALS to only the whitelisted keys and values.

* In teardown, restore the original state.

* As optimisation, do this from setUpBeforeClass as well, so that
  there are relatively few globals to reset between tests.
  (Thanks @Simetrical!)

The following tests were previously passing by accident under
MediaWikiUnitTestCase but actually did depend on global config.

* MainSlotRoleHandlerTest (…, ContentHandler, $wgContentHandlers)
* SlotRecordTest (…, ContentHandler, $wgContentHandlers)
* WikiReferenceTest (wfParseUrl, $wgUrlProtocols)
* DifferenceEngineSlotDiffRendererTest (DifferenceEngine, wfDebug, …)
* SlotDiffRendererTest (…, ContentHandler, $wgContentHandlers)
* FileBackendDBRepoWrapperTest (wfWikiID, "Backend domain ID not provided")
* JpegMetadataExtractorTest (…, wfDebug, …, LoggerFactory, …)
* ParserFactoryTest (…, wfDebug, …, LoggerFactory, InvalidArgumentException)
* MediaWikiPageNameNormalizerTest (…, wfDebug, …, LoggerFactory, …)
* SiteExporterTest (SiteImporter, wfLogWarning, …)
* SiteImporterTest (Site::newForType, $wgSiteTypes)
* ZipDirectoryReaderTest (…, wfDebug, …, LoggerFactory, …)

Bug: T230023
Change-Id: Ic22075bb5e81b7c2c4c1b8647547aa55306a10a7
2019-09-02 20:58:34 +01:00
Aryeh Gregor
383a925f68 Output only to stderr in unit tests
Otherwise, session tests don't work in PHP 7.2 because headers are
already sent: https://bugs.php.net/bug.php?id=75628

Bug: T206476
Change-Id: Ie88db4a61a56b756c6445d2579a2f30da22c3ee8
2018-10-08 21:04:12 +03:00
Tim Starling
65adc37348 Make phpunit.php less hackish, and install the listener unconditionally
* Instead of rewriting $argv, add a Command subclass called
  MediaWikiPHPUnitCommand which overrides the configuration using the
  stub functions in Command which were provided for that purpose.
* Revert c804a0b5b9, which added redundant debug output to tests,
  and instead install the MediaWikiPHPUnitTestListener listener
  unconditionally. Deprecate and make non-functional the --debug-tests
  option. If you don't want tests to produce debug output, you can
  always turn the channel off.
* Because I added our listener to the listener array instead of making
  it override the printer, it's no longer necessary to derive from
  PHPUnit\TextUI\ResultPrinter. Instead we derive from BaseTestListener.
  So we don't need to call the (empty) parent methods.
* Remove the --with-phpunitclass feature since it doesn't work with this
  scheme.
* Instead of passing CLI args to MediaWikiTestCase via a public static
  variable, inject it non-statically by overriding the TestRunner and
  TestResult.
* Remove --file, which has been non-functional since my 2016 refactor.

Change-Id: Ibcaf9ca81c8dc63cce6dc6f6fb1fffee19f8804e
2018-09-04 15:30:20 +10:00
Tim Starling
5322107191 Reset services before every test
Trying to avoid resetting services introduces a lot of complexity and
several bugs. We were doing a reset for 70% of @group Database tests
anyway.

Instead:

* Reset services at the start of MediaWikiTestCase::run().
* Capture the actual original service container instead of making a
  special shared service container.
* The test-isolated local service container can now only be initialised
  non-statically. Revert the recent conversion of overrideMwServices()
  to static.
* Store a reference to the local service container in the test case
  object. In MediaWikiTestCase, always use the original or local service
  container directly, to avoid confusion about which one is active at
  the time.
* Remove a lot of unnecessary teardown
* Always call ServiceContainer::destroy() before forceGlobalInstance()
  since the memory is not otherwise freed.

Change-Id: I4a17c1c7ec92c14e3bc471f0216473ebe19477b9
2018-09-03 16:38:58 +00:00
Bill Pirkle
2bd7259a2c Make maintenance scripts fail on unknown parameters
Passing parameters not registered via standard mechanisms
(addOption/$optionsWithArgs/$optionsWihtoutArgs) will now
cause an error, unless, the script opts out via the new
setAllowUnregisteredOptions/$allowUnregisteredOptions.

Bug: T110209
Change-Id: I21957837f10852169ca3e1eeca9bf1f4052f8c0b
2018-08-06 14:37:49 -05:00
Reedy
45a0f99734 Allow PHPUnit 6 optionally in require-dev
MediaWiki uses a back-compat layer to preserve most of the PHPUnit 4
runtime, so existing tests will continue to run fine with minimal
modification. Once PHP < 7.0 support is dropped, we can drop PHPUnit 4
support, and adapt tests to use PHPUnit 6 features directly.

Bug: T177132
Depends-On: I884b240307e3fcad253aa64eeae9944ed4eb7d50
Change-Id: I497712c7693d137be197a69873baa58383ce9646
2018-04-12 20:46:56 -07:00
Umherirrender
63d96c15fd build: Updating mediawiki/mediawiki-codesniffer to 16.0.0
Change-Id: I59b59f79bbf3ce4feff3b3a20c1c31bc16370531
2018-02-17 13:29:13 +01:00
Timo Tijhof
fdb7d36903 tests: Commit initial version of DevelopmentSettings.php
* Store in the includes/ directory.
* Use by default in Travis CI builds.
* Add command-line option to phpunit.php to use it.
* See commit ## for use by Jenkins jobs, which will load it directly
  from LocalSettings.php (instead of via phpunit) so that it applies
  to web entry points and other maintenance scripts as well.

Bug: T177669
Change-Id: I6e5dc5f0dddc1960761980552ed2bb31e6ae9fd9
2017-12-27 22:13:24 +00:00
Gergő Tisza
1cd91412e7 phpunit.php: omit --quiet in help
Bug: T176060
Change-Id: Iee7a0df6ba9fadf92d8e2d9f170cdfc66244d3d5
2017-09-17 06:15:38 +00:00
Tim Starling
6117fb244f Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.

Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.

General:

* Split out the pre-Setup.php global variable configuration from
  phpunit.php into a new class called TestSetup, also called it from
  parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
  Maintenance.
* In Setup.php improved "caches" debug output.

PHPUnit frontend:

* Delete the entire contents of NewParserTest and replace it with a
  small wrapper around ParserTestRunner. It doesn't inherit from
  MediaWikiTestCase anymore since integrating the setup code was an
  unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
  instantiable TestSuite class instead of just a static method. Got rid
  of the eval(), just construct TestCase objects directly with a
  specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
  support them anymore. Note that --filter now works just as well as
  --regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
  for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
  once, as is implied by the documentation.

parserTests.php frontend:

* Made parserTests.php into a Maintenance subclass, moved CLI-specific
  code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
  backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
  to the old default behaviour

Test file reading and interpretation:

* Rename TestFileIterator to TestFileReader, and make it read and buffer
  an entire file, instead of iterating.
* The previous code had an associative array representation of test
  specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
  unnecessary now that all extensions use ParserFirstCallInit. Resurrect
  an old interpretation of the feature which was accidentally broken: if
  a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
  human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
  articles in them. This greatly speeds up execution time when --regex
  matches a small number of tests. It may possibly break extensions, but
  they would have been randomly broken anyway since there is no
  guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
  link formatting, life is complicated enough already. It can go in
  OutputPageTest if that's a thing we really need.

Result recording and display:

* Make TestRecorder into a generic plugin interface for progress output
  etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
  a long inheritance chain. All test recorders now directly inherit from
  TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
  frontend. Most events are ignored since they are never emitted in the
  PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.

Setup and teardown:

* Introduce a new API for setup/teardown where setup functions return a
  ScopedCallback object which automatically performs the corresponding
  teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
  here which was simply copied from Setup.php without review, and had
  nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
  performance, give staticSetup() precedence in cases where they were
  both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
  from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
  don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
  I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
  customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
  handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
  now! Also, the relevant parser tests were removed from the Math
  extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
  allows setup/teardown to be done once for each batch of articles
  instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
  copied in from Setup.php in 2010, and are redundant since we do
  actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
  this alone.

Fuzz tests:

* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
  where they used to reside.

Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-12 16:11:42 +10:00
Tim Starling
df29a359f8 Renames preparatory to parser tests refactor
Since in several cases, with an all-in-one commit, git's file rename
detection failed, I split the renames out into their own commit to
make review easier. Some changes here won't make complete sense without
the following commit.

* Moved TestsAutoLoader to tests/common/. It will be joined by a friend.
* Renamed ParserTest to ParserTestRunner, since the former name was
  overly generic.
* Renamed TestFileIterator to TestFileReader. Please see the subsequent
  commit for rationale.
* Moved parserTests.php to tests/parser/. It was the only file left in
  tests/, and it should have been moved to tests/parser years ago,
  analogous to phpunit.php.
* Renamed NewParserTest to ParserIntegrationTest. This was a tricky one,
  apparently the name has to end in "Test" or else the structure test
  will fail. Analogous to ParserMethodsTest etc. Rationale: because it's
  not new anymore.
* Renamed MediaWikiParserTest to ParserTestTopLevelSuite and moved it to
  the suites directory. A more descriptive name. Being in suites/
  shields it from StructureTests, and is correct anyway.

Change-Id: Iddc6eaf815fdd64b3addb8570b4b6303ab99d634
2016-09-12 15:46:15 +10:00
Tim Starling
2c93a08212 Allow --profile to be used in phpunit.php
This requires running PHPUnit from within execute() -- we're calling a
function so it doesn't benefit from being in global scope.

Change-Id: I4b6a3613bc89047a9f32505afabaff98b3655e1a
2016-09-08 09:06:45 +10:00
Gergő Tisza
854a462dc0 Remove $wgDisableAuthManager
Change-Id: I2b2c9693a275fcc026916bd97f303e7a5c8df341
2016-08-09 23:00:27 +00:00
Ori Livneh
acca48094c Make number of PBKDF2 iterations used for deriving session secret configurable
The intent is both to allow the number of iterations to be dialed up (either as
computational power increases, or on the basis of security needs) and dialed
down for the unit tests, where hash_pbkdf2() calls account for 15-40% of wall
time. The number of iterations is stored in the session, so changing the number
of iterations does not cause existing sessions to become invalid or corrupt.
Sessions that do not have wsSessionPbkdf2Iterations set (i.e., sessions which
precede this change) are transparently upgraded.

Change-Id: I084a97487ef4147eea0f0ce0cdf4b39ca569ef52
2016-05-28 07:06:30 -07:00
Brad Jorsch
d245bd25ae Add AuthManager
This implements the AuthManager class and its needed interfaces and
subclasses, and integrates them into the backend portion of MediaWiki.
Integration with frontend portions of MediaWiki (e.g. ApiLogin,
Special:Login) is left for a followup.

Bug: T91699
Bug: T71589
Bug: T111299
Co-Authored-By: Gergő Tisza <gtisza@wikimedia.org>
Change-Id: If89d24838e326fe25fe867d02181eebcfbb0e196
2016-05-16 15:11:02 +00:00
daniel
d7410db0fd Allow reset of global services (redux).
(This is part of I6ec374ac9 wich was a re-submit of Ie98bf5af5
which got reverted by Ide7ab563)

This change provides a mechanism to reset global service instances
in an orderly manner. There are three use cases for this:

* the installation process
* integration tests (which most of the existing phpunit tests are)

In contrast to I6ec374ac9, this change does not cause singeltons
of legacy services to be reset. It is assumed that legacy services
use global state to access services and configuration, so any
change in confuguration would affect them immediately.

NOTE: the original I6ec374ac9 would cause session information to
get lost if the user session was creatsed before initialization
was complete. This was apparently triggered by the MobileFrontend
extension under some circumstances. Check with Addshore and Catrope.

Change-Id: Ie06782ffb96e675c0aa55dc26fb8f22037e8517d
2016-05-04 19:18:29 +02:00
Catrope
1162ed5f88 Revert "Allow reset of global services."
Completely breaks login.

This reverts commit 8e7a0a0912.

Change-Id: Ide7ab5632e987e81374c21173df6ab3998649df7
2016-04-11 13:40:28 -07:00
daniel
8e7a0a0912 Allow reset of global services.
This change provides a mechanism to reset global service instances
in an orderly manner. There are three use cases for this:

* the installation process
* forking processes
* integration tests (which must of the existing phpunit tests are)

Depends-On: I5d638ad415fc3840186a0beaa09ac02ea688539b
Change-Id: Ie98bf5af59208f186dba59a9e971c72ea0b63e69
2016-04-11 16:22:40 +02:00
Brad Jorsch
6c0abf937a Use ::class in place of string constants
This takes advantage of namespacing, and avoids having
double-backslashes all over the place.

Change-Id: I450fe4e9b1c4cf4e24fced3932fe796cbbadf3a3
2016-03-28 14:53:45 -04:00
Adrian Heine
110dc4d9a2 Add --with-phpunitclass arg to phpunit.php
This would allow to easily use stuff like
https://github.com/fiunchinho/phpunit-randomizer.

Change-Id: I28e8b1d261de0395366b18465a0adc4d7c4fde4a
2016-03-17 13:58:17 +01:00
Max Semenik
b61be67549 Remove support for non-Composer PHPUnit
Composer is now a standard way to install MediaWiki's PHP dependencies,
no reason for it not to be the same for PHPUnit.

Change-Id: Ibd977eb3480dafaf270ff63abc43c413d7b72144
2016-03-14 11:29:34 -07:00
Timo Tijhof
dbe3499113 Upgrade from PHPunit 3.7.x to PHPUnit 4.8.x
Major changes:

* (4.0.0) Limited support for stubbing and mocking static methods was removed.
          (introduced in PHPUnit 3.5)
* (4.0.0) The addRiskyTest() was added to the PHPUnit_Framework_TestListener interface.
          Classes that implement this interface MUST implement this method.
* (4.5.0) The "--strict" catch-all option was deprecated. Use specific options instead.

Notable changes:

* (4.6.0) Tests not annotated with @small, @medium, or @large are no longer default
          to matching in group @small.
* (4.6.0) Result printer now checks hasColorSupport().
* (4.8.0) The name of the default group was changed from "__nogroup__" to "default".
* (4.8.0) This is the last release to support PHP 5.3, PHP 5.4, and PHP 5.5.
          PHPUnit 5 will require PHP 5.6 or higher.

PHPUnit 3.7.17 was released March 2013.
PHPUnit 4.8.0 was released August 2015.
PHPUnit 4.8.23 was released January 2016.

Details:

* https://github.com/sebastianbergmann/phpunit/wiki/ChangeLog-for-PHPUnit-3.7
* https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.0.0
* https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.1.0
* https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.2.0
* https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.3.0
* https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.4.0
* https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.5.0
* https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.6.0
* https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.7.0
* https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.8.0

Bug: T99982
Change-Id: I70ad81513812aa76a84fa55be14135aac94d55e8
2016-02-23 00:57:48 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Reedy
9d19133bad Remove < PHP 5.4 register_shutdown_function() from phpunit.php
Change-Id: Ic4efeca82762b3c50cd2e1b45e43a6f1ef0f5710
2016-02-10 22:06:45 +00:00
Kunal Mehta
82c6f0ff03 Output PHP version before running PHPUnit tests
For sanity checking CI changes, as well as to match the PHPUnit
version output.

Change-Id: Ib807f8650992adada97226cd96282484392f71e8
2016-02-07 17:43:33 -08:00
Aaron Schulz
3592f8cea3 Add simple JobQueueMemory class for testing
Change-Id: I1acce43dbab3b12393d6dc4675850695c619d88a
2016-01-14 00:23:05 +00:00
Aaron Schulz
95ebc3d956 Fix undeclared global $wgMainStash
Change-Id: I95d4194199a064221a56e0b10b236dd2564d1855
2016-01-12 21:56:26 -08:00
Brad Jorsch
a73c5b7395 Add SessionManager
SessionManager is a general-purpose session management framework, rather
than the cookie-based sessions that PHP wants to provide us.

While fallback is provided for using $_SESSION and other PHP session
management functions, they should be avoided in favor of using
SessionManager directly.

For proof-of-concept extensions, see OAuth change Ib40b221 and
CentralAuth change I27ccabdb.

Bug: T111296
Change-Id: Ic1ffea74f3ccc8f93c8a23b795ecab6f06abca72
2016-01-12 21:57:01 +00:00
Florian
be60ba4cb4 Use wikimedia/at-ease insteaad of @
Change-Id: Icba412dd5db11b596ad1cf740b8408823297bc86
2015-12-27 21:51:16 +01:00
Reedy
cc7fca0c14 Support phpunit-old.phar
Bug: T122485
Change-Id: Ic21c6c1ca5afaac0e298cf0259f5dc273dfec128
2015-12-27 20:26:05 +00:00
umherirrender
54c1e18eec Remove various double empty newlines
The double empty newline is not needed between functions, variable or at
end of file

Change-Id: Ib866a95084c4601ac150a2b402cfa184ebc18afa
2015-12-27 18:55:12 +00:00