Commit graph

113 commits

Author SHA1 Message Date
Umherirrender
45da581551 Use ::class to resolve class names in tests
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
2018-01-26 22:49:13 +01:00
Kunal Mehta
2eb14eb453 Add @covers tags to filerepo tests
Change-Id: I696e03f9ab3934b6cd04e88e1d611060846d32a4
2017-12-27 17:44:47 +00:00
Timo Tijhof
447ce7e39a phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat
The default will remain PHPUnit 4.x due to PHP 5.5 support.

But, we should allow developers to run tests with newer PHPUnit
versions which are noticably faster (especially for code coverage
reports).

* <https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0>
  PHPUnit 5 deprecates the getMock() shortcut for getMockBuilder()->getMock().
  It instead introduces the shortcut createMock() which has better defaults
  than getMockBuilder(). For example, it sets 'disableArgumentCloning' and
  other things by default.

  Going forward, code should either use getMockBuilder directly and configure
  it using the setter methods (instead of the confusing variadic arguments
  of getMock) or simply use the new minimalistic createMock method. This patch
  backports the createMock method to MediaWikiTestCase so that we can start
  using it.

Change-Id: I091c0289b21d2b1c876adba89529dc3e72b99af2
2017-04-06 00:44:32 +00:00
Timo Tijhof
f14c11f1b5 Remove left-over references from comments to removed FSRepo class
Follows-up 8b18ae7b5.

Change-Id: I10badb3e4648b2b32168a8aaad35855b2f6ae35e
2017-01-07 16:00:07 +00:00
Antoine Musso
75b54a58c0 tests: mock should not __clone Database
The Database __clone relies on a connLogger which is set in the
constructor.
However, when creating a mock of Database, PHPUnit 5.x does a __clone
which uses a connLogger. That leads to a fatal error.

The sole caller is FileBackendDBRepoWrapperTest, have its mock to skip
invoking __clone().

Change-Id: I2ee3b561104bdacc0232ba5e90b3eae3fbaa6f8f
2017-01-03 17:48:41 +01:00
Seb35
ec215d010c Replace mocks of DatabaseMysql by DatabaseMysqli
The class DatabaseMysql corresponds to the PHP extension 'mysql' which is
deprecated since PHP 5.5, and the class DatabaseMysqli corresponds to the
PHP extension 'mysqli' which is the current MySQL driver. Given the class
DatabaseMysql is likely to be removed in the future, this change is a
first step towards this.

Bug: T120333
Change-Id: I7b8363838449cae09b360221d8f50ace3a008f11
2016-12-31 12:52:16 +01:00
Aaron Schulz
c4d275b7d5 Remove FileRepoStatus references
Change-Id: I03190273670f5c255423cf59019cbf12220c5498
2016-12-21 19:07:33 +00:00
Aaron Schulz
f7e3ac3f95 FSFile and TempFSFile cleanups
* Remove wf* function dependencies. This includes wfTempDir().
  Callers now should specify the directory, though it will try to do
  most of the wfTempDir() logic anyway if they do not.
* Update callers to inject wfTempDir() so $wgTmpDirectory is used by
  TempFSFile instead of it probing to find a valid directory itself.
* Move most of the wfTempDir() logic to TempFSFile::getUsableTempDirectory().
* Remove unused getMimeType() method.

Change-Id: Idd55936b07f9448a6c90577708722b7b52b8fe66
2016-09-19 19:55:09 +00:00
Seb35
0bd95a94cf Typo in a test: '+' instead of '.' to concatenate strings
I found it by executing tests with PHP 7.1.0RC1, but even
if PHP 7.1.0 is still a RC, this is a typo in PHP language.

Change-Id: Ia97f881f8c80a23c51512189d9ca5a012612c532
2016-09-03 16:29:13 +02:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Reedy
1834ee3d8e Fix numerous class/function casing
Change-Id: I23982bfa0548c9ea3bdb432be7982f1563930715
2016-03-18 23:14:49 +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
Timo Tijhof
fbab4fecef tests: Clean up use of mt_rand()
* ApiQueryTest: One random is enough.

* FileBackendTest: More consistent and idiomatic via wfRandomString()

* MigrateFileRepoLayoutTest: Use getNewTempDirectory(). Similar to
  what FileBackendTest used already.
* UploadFromUrlTestSuite: Use getNewTempDirectory().

Change-Id: I772de2134be41506d8ed08367be8c18f354bfc72
2015-12-03 13:45:55 +00:00
Amir E. Aharoni
3cd3b7ac9f Make lines short to pass phpcs in 3 files under tests/phpunit/includes/
Bug: T102614
Change-Id: I8f3d570fb6e9866d4376f42d4efa05f9c5e7f14d
2015-10-01 19:00:40 +00:00
umherirrender
c572d18661 Fixed spacing
- Removed space after cast
- Removed spaces in array index
- Removed double spaces
- Added spaces around string concat
- Fixed mixed tabs and spaces at begin of line

Change-Id: I38e849723f055d2d4c05cba72f5c245a28e8d5da
2015-09-26 20:44:54 +00:00
jenkins-bot
4ad0cdad5e Merge "Re-enable Squiz.WhiteSpace.SemicolonSpacing.Incorrect" 2015-09-26 17:01:07 +00:00
jenkins-bot
c3a5d76d19 Merge "Re-enable MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceBeforeCloseParenthesis" 2015-09-26 16:53:03 +00:00
Reedy
062af78957 Re-enable Squiz.WhiteSpace.SemicolonSpacing.Incorrect
Change-Id: Ie86c512fbca07f41b252d95de3ab92da3a050e72
2015-09-26 17:41:22 +01:00
Reedy
8e8368ca65 Re-enable MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceBeforeCloseParenthesis
Change-Id: I8482f5dd9d79e4946e862b0ac03bd027d62e8646
2015-09-26 17:38:35 +01:00
Reedy
3a6fc5e96c Re-enable Squiz.WhiteSpace.ScopeClosingBrace.Indent
Change-Id: I743c4ce019321d631c0a11ee2112fe9aa8ba4c5d
2015-09-26 16:09:54 +00:00
umherirrender
37543eed0c Fix spaces in MigrateFileRepoLayoutTest::tearDown
Use tabs for indent

Change-Id: I021b7ff41be23e46fe49dc552e697c7b8f78622e
2015-08-27 21:03:32 +02:00
Aaron Schulz
f1e1313a16 Support for storing files under SHA-1 names
* Added a "storageLayout" flag to LocalRepo config (supports "sha1")
* Added a simple migration script to copy files the SHA1 paths
* Currently works with img_auth.php + thumb_handler.php for URLs
* Added visibility to some LocalFile methods
* Simple tests for the wrapper class.

Co-Authored-By: Gilles Dubuc <gdubuc@wikimedia.org>
Change-Id: Iad46ad669c8ae3c02d10da10c3f7a16fe161663f
Bug: T1210
2015-07-21 16:19:22 +02:00
Kunal Mehta
790eb5810f LocalFileTest does not require database access
Change-Id: Iea4a2758a1169b212c15ceb4445b2e2a0458df1a
2015-03-26 17:36:14 -07:00
Timo Tijhof
9bd8dc6e2d filerepo: Use standard method for creating temp dir in unit test
Previously, the unittests-thumb directory (and its hashed subdirectories,
and the .htaccess and index.html files) were being left behind.

While that may be a bug in the FileBackend class, the unit test
shouldn't rely on that for its teardown. If we want to assert that,
that can be a separate test.

Bug: T89085
Change-Id: Ided46b71ace82159864145b76d98bb10da5d0311
2015-02-11 01:42:12 +00:00
umherirrender
1d8b52fbfd Move Test files under same folder structure where class is (/includes/)
Change-Id: I95f1aa6f0ed2cc3306aa6e588a11f359854315c1
2014-12-16 21:56:44 +01:00
umherirrender
26837cd280 Cleanup some docs (tests)
- Swap "$variable type" to "type $variable"
- Fixed spacing inside docs
- Makes beginning of @param/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: Ia041964250d8b7c0349d79dc9b131c5b8696e795
2014-08-11 20:06:52 +02:00
addshore
892a992ab8 Remove MediaWikiPHPUnitCommand
All functionality has been moved to other places

Change-Id: I6b6b0ef846bc63108c4dff9e17098432fd9d1697
2014-08-02 21:35:34 +00:00
umherirrender
d15f1cc5e1 Break some long lines in maintenance, skins, tests
Change-Id: I5d86ad3e0c90e09440268a670f5af3e2bf080612
2014-07-24 19:03:17 +02:00
umherirrender
3ea699368f Reformat function chains in FileTest.php
This makes the mock code more readable.
Also break a long line phpcs mentioned.

Change-Id: I6de5f05e5ab3fb18bd15518409334d39beba71cb
2014-07-20 20:06:35 +00:00
jenkins-bot
3fb5b3c16f Merge "Merge two FileTest.php files" 2014-07-20 20:02:22 +00:00
umherirrender
82d970e356 Tests: setMWGlobals -> setMwGlobals
Change-Id: I6441668fdbc62596efba21d736a73071a46bfe45
2014-07-20 21:50:34 +02:00
umherirrender
d4d15843f3 Merge two FileTest.php files
The correct folder is /file not /files

Follow-Up: Id03e1a0e1c151d3c575a695a42c54b709187d10a
Change-Id: If3d896aa792e77ba8198b8eb8ad2d874e52584fb
2014-07-20 21:48:26 +02:00
jenkins-bot
b15bfd99a9 Merge "Generate thumbnails based on buckets" 2014-07-09 14:09:02 +00:00
Gilles Dubuc
7036e7b68d Generate thumbnails based on buckets
Instead of always generating thumbnails based on the original,
this adds the ability to generate thumbnails based on
references buckets. The buckets themselves have their
generation chained following the same process (smaller bucket
generated based on bigger bucket). In situations where no
suitable bucket is found, the original is used, like it used to.

This is entirely optional, as most non-WMF wikis would probably prefer
to keep generating all thumbnails based on originals.

The quality implications have been verified through a survey
aimed at Commons users and people actually preferred the chained version.
Presumably due to the multiple passes of sharpening which maintained
visual details better for small thumbnail sizes.

Change-Id: I285d56b2024c81365247338f85c1e0aa708cb21e
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/600
Bug: 67525
2014-07-08 20:03:38 +00:00
Brian Wolff
2897061d1e Fix RepoGroup::hasForeignRepos() and RepoGroup::forEachForeignRepo()
Also add unit tests for those methods.

Change-Id: Ic72be60d13820492efc90b5925bb5cfc1813d28a
2014-07-03 03:12:27 -03:00
Brian Wolff
3a4bfb597e Fix misnamed SVGHandler::canAnimateThumb()
Caused the animation warning to not be present on
image description pages

Also add unit tests. Since I'm adding an animated svg file for
this unit test, also add a metadata extraction test for animated
svgs, since we're missing one.

Change-Id: Id03e1a0e1c151d3c575a695a42c54b709187d10a
follow-up: 876128f8c9
2014-06-10 21:15:53 -03:00
Bartosz Dziewoński
fd718959b6 Copy various random files used by tests to tests/phpunit/data
The tests currently depend on them never being renamed, which is bad.
(Actual file data in git is de-duplicated automatically AFAIK.)

Change-Id: Id2440326981218f9e7d51541a168db59183fdadf
2014-06-03 22:52:51 +02:00
Siebrand Mazeland
896bda7c85 Pass phpcs-strict on some test files (7/11)
Change-Id: Ia0ceea60e7ef43959f868378f3fcd463a3adf782
2014-04-24 18:27:12 +00:00
umherirrender
092cd8ee31 Fixed some @params documentation (tests)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: Ic8aaf0a93796b97d0fa4617c1f86ff59f4b36131
2014-04-17 20:43:42 +02:00
Aaron Schulz
2aa84651ca filebackend: cleaned up the FileBackend constructor
* Added some b/c code with deprecation warnings

Change-Id: Ifceffbc0a37a223bcd7cd3dc60181fc85765bc46
2013-12-03 13:57:01 -08:00
Aaron Schulz
2f29c7551b Revert "filebackend: cleaned up the FileBackend constructor"
Actually this messes with the implicit backend made for things like Math (when unconfigured), which uses the "new" operator.

This reverts commit 1f129a22cb.

Change-Id: I4c72c4f7c8b82e38df5496cf2b90fc9e19c40334
2013-12-03 20:40:24 +00:00
Aaron Schulz
1f129a22cb filebackend: cleaned up the FileBackend constructor
* Moved some of the graph construction work to FileBackendGroup.
  This helps the code in not depending on the rest of MW so much.
* Updated tests and FileBackendMultiwrite, which are the only things
  directly constructing FileBackend objects.

Change-Id: I188a053c70ce088ce34613d5db40e6708e3ea9b7
2013-11-23 20:21:53 -08:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
addshore
4e941cf4ca Add @covers tags for more tests
Change-Id: Iff3af78e9b41c445b7f066b6c0d0f4a87d2d6c4e
2013-10-21 11:28:39 +02:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Siebrand Mazeland
483e29277f Remove unused local variables in tests
Change-Id: I71318eb7d8c00bfc1ce6d2fc636b498f7a695f42
2013-04-26 09:48:46 +02:00
Siebrand Mazeland
de04f37ef1 Update formatting
5 of n.

Change-Id: I811ca957b6588085d67606ebc0cd4033a1e53839
2013-02-15 12:35:50 +00:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
Aaron Schulz
963c4a265f Moved FileBackend tests to /filebackend.
Change-Id: Ieb789ac1c9803f74bad3a4fef3a57587d6dd6260
2012-11-02 12:12:36 -07:00
Aaron Schulz
24a6e8eab6 [FileBackend] Support "ignoreMissingSource" for copy and move operations.
* This lets callers use "copy if exist" semantics more easily and avoids extra stat
  queries to the backend (since the cache is cleared before doOperations()).
* Tweaked FileOp::fileSha1() to reduce backend stat requests as 404s are not cached.

Change-Id: Icb5ca14b3316f273d53593f48979d14e113990e1
2012-10-31 04:24:05 +00:00