Commit graph

20 commits

Author SHA1 Message Date
DannyS712
29e8f74b5c GenderCacheTest: fix call to overrideMwServices()
MediaWikiIntegrationTestCase::overrideMwServices() is not static
and should not be called statically

Change-Id: I9d1f07b5bca8a39b82017e59978f2b28c399803e
2021-05-12 07:37:19 +00:00
Umherirrender
63eaa9ae89 Use DefaultOptionsLookup for default option in GenderCache
Change-Id: I778d2c4cd8de2aee138566fe82d658d046edf3f4
2020-06-28 16:53:24 +02:00
Umherirrender
5bd311b1a2 Add public as visibility in tests folder
Add public, protected or private to function missing a visibility
Enable the tests folder for the phpcs sniff

Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
2019-10-10 21:55:37 +02:00
Thiemo Kreuz
8a4e15db7f Add missing newline between <?php and namespace/use section
The rest of the codebase is using this code formatting standard.

Change-Id: I4d2ba61757a7e28d40096d9dc5915005c340d4f2
2019-06-03 13:36:48 +00:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
addshore
7dd1600e9c Get GenderCache from MediaWikiServices
Change-Id: I752a65d93ec49ea6c44306eb18a6641ef86f7b5c
2016-11-22 23:14:43 +00:00
Ori Livneh
e638075936 Whenever possible, reuse User objects in unit tests
The unit tests spend nearly half of their run time resetting the user table for
each test. But the majority of tests do not depend on the user table having the
exact value that the setup code resets it to, and do not need to modify the
user objects they require to run.

Fix that by providing an API for tests to get User objects, and to indicate
whether the User object will be subject to destructive modification or not.
This allows User objects to be reused across multiple unit tests.

Change-Id: I17ef1f519759c5e7796c259282afe730ef722e96
2016-05-26 20:42:31 +00:00
Reedy
1834ee3d8e Fix numerous class/function casing
Change-Id: I23982bfa0548c9ea3bdb432be7982f1563930715
2016-03-18 23:14:49 +00:00
daniel
a8995619c1 Avoid rebuilding database fixtures for every test run
This reduces the runtime of database-bound tests by about 40%
(on my system, from 4:55 to 2:47; results from Jenkins are
inconclusive).

The basic idea is to call addCoreDBData() only once, and have
a addDBDataOnce() that is called once per test class, not for
every test method lie addDBData() is. Most tests could be
trivially be changed to implement addDBDataOnce() instead of
addDBData(). The ones for which this did not work immediately
were left out for now. A closer look at the tests that still
implement addDBData() may reveal additional potential for
improvement.

TODO: Once this is merged, try to change addDBData() to
addDBDataOnce() where possible in extensions.

Change-Id: Iec4ed4c8419fb4ad87e6710de808863ede9998b7
2016-03-10 23:44:34 +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
Brad Jorsch
3d0b4fea3d User: Mostly remove password handling
AuthManager is coming, which will make it easier to add alternative
methods of authentication. But in order to do that, we need to finally
get around to ripping the password-related bits out of the User class.

The password expiration handling isn't used anywhere in core or
extensions in Gerrit beyond testing for expired passwords on login and
resetting the expiry date on password change. Those bits have been
inlined and the functions removed; AuthManager will allow each
"authentication provider" to handle its own password expiration.

The methods for fetching passwords, including the fact that mPassword
and other fields are public, has also been removed. This is already
broken in combination with basically any extension that messes with
authentication, and the major use outside of that was in creating
system users like MassMessage's "MediaWiki message delivery" user.

Password setting methods are silently deprecated, since most of the
replacements won't be available until AuthManager. But uses in unit
testing can be replaced with TestUser::setPasswordForUser() immediately.

User::randomPassword() and User::getPasswordFactory() don't really
belong in User either. For the former a new PasswordFactory method has
been created, while the latter should just be replaced by the two lines
to create a PasswordFactory via its constructor.

Bug: T47716
Change-Id: I2c736ad72d946fa9b859e6cd335fa58aececc0d5
2015-10-13 16:10:41 -06:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
umherirrender
181d5f6fd6 Use mergeMwGlobalArrayValue in GenderCacheTest
Also move the global setting to addDBData to let the test work
correctly, because the global is used indirectly in User::saveSettings.

Change-Id: I986d3a28e4fcc82ed84886c2970571e9fa6128be
2014-11-13 17:56:22 +00:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
addshore
339d8cef81 Add @covers for GenderCache + MessageCache tests
Change-Id: I379f2788c1b308354a3dbb73c889aa4a90b2cd20
2013-10-18 13:06:08 +02:00
Siebrand Mazeland
9f77245218 Update formatting
4 of n.

Change-Id: I23e2409ce9eff14c3434154d236de83c93a92440
2013-02-14 14:10:38 +01:00
Timo Tijhof
181c7cdc8e Clean and repair many phpunit tests (+ fix implied configuration)
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.

Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...

Either way they won't have to anymore with setMwGlobals.

Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)

(Matching the function signature with PHPUnit/Framework/TestCase.php)

Replaces:
 * public function (setUp|tearDown)\(
 * protected function $1(

 * \tfunction (setUp|tearDown)\(
 * \tprotected function $1(

 * \tfunction (data|provide)\(
 * \tpublic static function $1\(

Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.

Fixes:

TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).

MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...

FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"

HttpTest
* Added comment about:
  "PHP Fatal: Call to protected MWHttpRequest::__construct()"
  (too much unrelated code to fix in this commit)

ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
  because regardless of whether wgExternalStores is true or false
  it only uses it if it is an array.

Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-09 03:01:51 +02:00
Platonides
fdc857b73e Change CRLF line ending in GenderCacheTest.php
Edited in windows with no autocrlf set?

Change-Id: I955f0ed1fad9c4e5c143324b163a4b3c81a3f733
2012-04-28 17:18:22 +02:00
Platonides
1ceb4b671f Really use the global variable. Fixes bug in c4507 (4989dd)
Change-Id: I4733a3d8949d76044ba90e672395299f6623cecf
2012-04-28 17:12:38 +02:00
umherirrender
4989ddd423 strip off subpages direct in GenderCache
LinkBatch can also give subpages to the GenderCache and therefor it is
easier to do it always in GenderCache, than in LinkBatch and Title

Add unit tests for GenderCache

Change-Id: Ia936ff8bb639a197b0b3a8e07c97a66edd57dd10
2012-04-21 10:34:22 +02:00