Also clean up the other cache settings to match their order
as defined in DefaultSettings.php.
Don't disable MessageCacheType, ParserCacheType etc. This could
prevent bugs from happening during tests. They are enabled by default
in MediaWiki with CACHE_ANYTHING. At least let them use 'hash'
during tests to resemble a more realistic environment.
Change-Id: Id9edf33c600db3ac4d837e1674a8eb2f5363a4f8
If phpunit is installed via composer, it will already be present in the
autoloader, so including other paths won't do anything.
Also add some output to make it easier to figure out where phpunit is
being loaded from.
Change-Id: Id6d23626b158779f6ff56e6d0f20d519f2f4ad18
MediaWiki Codesniffer warns that "Silencing errors is discouraged".
Assuming this was done with good reason, this patch surrounds the
offending line with comments asking codesniffer to ignore the line.
Ironically, silencing errors about silencing errors.
Change-Id: Ib811b03b0a53735ce0da38bc8861ff38f9d1a666
* Remove use of 'error' where it's redundant.
* Remove call to logException from responsibility of MWException.
Call from exception handler instead.
Change-Id: I8764cf5df87b226813c9b9cf99f9b4f3fa4b7c92
- Removed spaces around array index
- Changed else if to elseif
- Added space after foreach/if/function
- include_once is not a function
Change-Id: I7745ae791d1b7e60cfebec6d268513a9cc071bdd
The code that attempts to load PHPUnit is simpler and clearer when rewritten as
a loop that iterates through a set of possible include paths for PHPUnit,
ordered from most to least desirable, and which tries each include path in turn
and then checks if the requisite classes are now loaded.
Also simplify check for PHP version: MediaWiki requires 5.3+, so might as well
assume it.
Change-Id: I9e25d69c1381cf3a87e7df2baf346bc6bb5aa052
MediaWiki tends to assume installation of phpunit via PEAR.
Distribution of phpunit via PEAR will eventually be discontinued,
in favor of distribution via PHAR or composer. PEAR installation
of phpunit 4.0 essentially distributes a phar.
https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.0.0
This patch allows phpunit.php to work with a phpunit.phar file,
as long as it's in the include path. --with-phpunitdir can be used
to add a directory to the include path.
With composer install, no options are needed and it works.
Bug: 58881
Change-Id: Ibac9b36bbb9614d990c697a091947a64c8987d1d
This also slightly refactors MediaWikiPHPUnitTestListener
so we can pass it into phpunit directly using the
--printer option
Change-Id: I6a19e3902130eeba6a0941f24a4f440b712058e5
- use tab as indent instead of spaces
- Added space after closures "function"
- Added spaces around string_concat
- Added newline inside empty blocks
- Removed four spaces after comma
Change-Id: I4425b0c6a69b36f40acfea6511b8950cf09ce2b2
- Added/removed spaces around parenthesis
- Added space after switch/if/foreach
- changed else if to elseif
Change-Id: I99cda543e0e077320091addd75c188cb6e3a42c2
This adds a new generic library class IPSet, which precomputes
a reasonably-efficient data structure from the input list of
addresses and CIDR net/mask specs for fast runtime matching,
and then uses it to check trusted XFF-setters.
See also: 32b4f19f173fc5cff1029eedee63a39a2d72dd3a
Bug: 57021
Change-Id: Ia3b12fb90c3e7e492374a128943b014481cc2730
assertContainsOnlyInstancesOf has been added in PHPUnit 3.7.0, so we need to
have that version for running the tests.
Bug: 59759
Change-Id: I25dbd377b97ec0b9062d3c8cf495ba3f06956ac4
iPart of program to remove underscores from class names. Checked core and
600+ extensions for occurrences. All uses are in core, and are updated in
this change.
Change-Id: I432dc249d22053728013ae7d0d56c3c398021c5e
"phpunit/phpunit" already exists inside our composer.json's "require-dev" however this has been
entirely useless as we don't include the autoloader which would load composer's PHPUnit.
This change begins including composer's autoloader when present and also tweaks phpunit.php
to ensure PHPUnit isn't double loaded. As a result besides supporting PHPUnit via composer this
also means that we're ready to make use of any library we add to our composer.json in the future.
Change-Id: I891740e8fd3d237c5f473862027205d951f564b9
We used to inject the test autoloader from the global space after the
Maintenance class has been initialized. That prevents us from using
tests classes (such as Mock) during the Maintenance setup.
This patch move the TestsAutoLoader.php require() at the beginning of
finalSetup() which would let use Mock classes.
Change-Id: Ia402eafae8407d1516e3d200ac97539e3681fdc6
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.
Also updated usage in text in documentation and the
installer LocalSettingsGenerator.
Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;
Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
Squiz.WhiteSpace.LanguageConstructSpacing:
Language constructs must be followed by a single space;
expected "require_once expression" but found
"require_once(expression)"
It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.
Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.
It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.
Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
Also update some previous inconsistencies pointed out by Krinkle in change IDs:
* Ide20743a2e84ff68549286120e6cff9d9f396f54
* I811ca957b6588085d67606ebc0cd4033a1e53839
Change-Id: Ife33b931870d0d7e04fcb40974997436d27f528f
The ApiAccountCreationTest is attempting to send an email to the newly
created user. The tests should really never send any email. This patch
register a noop callback for the 'AlternateUserMailer' hook which would
disable email entirely in our test suite.
This is generic version of 2025a89 which was only disabling mail for the
ApiAccountCreationTest test and that Antoine reverted.
Change-Id: I7b3ba4f7563a5818c988d6f8da165cc3c984f160
· Use env(1) in shebangs instead of hardcoding paths.
· $IP is already set in the constructor of Maintenance classes.
· Add sapi guard to some phpunit files.
Change-Id: I6c6fd6c61e2861b5992f2ccd67a4e3f62e2c445e
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)
Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
This forces $wgDevelopmentWarnings to true for phpunit tests.
Note that wfWarn uses the E_USER_NOTICE level per default, which may or may not
actually cause test cases to fail, depending on the phpunit configuration.
Change-Id: I36583fb063436cc8474873b468fc983d28377cbd
The new --with-phpunitdir let us specify a git checkout of PHPUnit. That
will ease regression testing of the upstream new version. Usage is
straightforward:
Checkout PHPUnit from git as instructed on:
https://github.com/sebastianbergmann/phpunit#readme
Invoke our test suite with:
$ cd maintenance/tests
$ php phpunit.php --with-phpunitdir /path/you/just/checked/out
Change-Id: I8a9af0deac4dd74e3c8bde73535555c54ac83766
* Added $wgLanguageConverterCacheType global to control LC cache type. We can use it to enable direct apc use for language converter (to match the live hack).
* Added $wgLangConvMemc object, available via Setup.php
Change 1:
* Updated unit tests
* Minor documentation cleanup in DefaultSettings.php
Change-Id: Icd5dd28407e9759ce294c784ec41d9ca15c89616
As Setup.php assigns variables based on the cache config, bootstrap.php was late on reseting them, as some objects were already created.
So we could end up with a SqlBagOStuff created there, which when later accessed (such as trying to invalidate the cache for a user) would
-as any non-sqlite SqlBagOStuff- open a new db connection. Which is precisely what we shall not be done when dealing with temporary tables
(and would indeed fail miserably due to not finding unittest_objectcache table).
In summary, reenabling temporary tables disabled in r79411.
lack of fuzz testing and other parser test options, and the DB creation is still a little flaky.
A MediaWikiPHPUnitCommand class had to be created to allow for custom CLI parameters.