Commit graph

57 commits

Author SHA1 Message Date
Alexander Vorwerk
60c3deaba1 RepoGroup: inject MimeAnalyzer
Change-Id: Ic3009b368b38d307d00dc3bec5c8d46b2dc97f83
2021-08-13 17:02:42 +02:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
Fomafix
356f1b72ef Use IEC prefixes instead of SI prefixes for byte sizes (docs+backend)
This change doesn't change any UI messages.

Bug: T54687
Change-Id: Ia62899a2a6fe8910618c35cd667291e397ddb055
2021-06-28 11:59:09 +01:00
Cindy Cicalese
b242d49a62 Use WatchlistManager in API classes
Change-Id: I7b2016162e86b455c0102742751981c44d7e829c
2021-04-21 04:41:06 +00:00
MusikAnimal
6a898faed2 Add watchlist expiry support to applicable APIs
This introduces an ApiWatchlistTrait that refactors out common code
across APIs that allow you to watch pages. Some methods have been
migrated from ApiBase and changed completely, but codesearch suggests
they aren't being used outside the API modules in this patch.

Bug: T248512
Bug: T248514
Change-Id: Ia18627b9824dca81f44f0571e8420d89b7626cf6
2020-07-13 18:18:15 -04:00
Thiemo Kreuz
5f3a92385b Fix visibility of setUp/tearDown
Change-Id: I636be48eb9f713680abac35d46091f7b49374696
2020-06-16 21:02:05 +02:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
Daimona Eaytoy
ef5ab69629 Replace setExpectedException with two args
Find: ^(\t*)(\$this->)setExpectedException\(\s+(\\?[a-z\\]+::class),\s+('(?:[^'\\]|\\')+'|"(?:[^"\\]|\\")+")\s+\);

Replace: $1$2expectException( $3 );\n$1\$this->expectExceptionMessage( $4 );

+broke long lines manually.

Bug: T192167
Change-Id: I5557b4372625def55a53ac637c2f980f51f12933
2019-10-05 16:14:05 +00:00
Petr Pchelko
4129c7551e Rework ApiUploadTest
Bug: T28169
Change-Id: I923bf82d07db0efce1d0d14cf04e15bb58472f59
2019-08-30 13:50:50 -07:00
Umherirrender
040063a4ba Rename ApiTestCaseUpload
Having *TestCase at end of the class name makes it easier to detect it
as TestCase class

Change-Id: Ic7ae7328e729c0f2d97afcf7c5be793d6a8df58f
2018-03-16 18:40:38 +01:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Kunal Mehta
2c2dc593d2 Add @covers tags API tests without them
Change-Id: Ida0f954cb0a44719af3a3d0c6bda4587c9ca42b6
2017-12-27 17:50:06 +00:00
Aleksey Bekh-Ivanov (WMDE)
cc3c0d2cdf Make ApiUploadTest up to date so it passes
Although the test is still might fail from time to time
and needs refactoring.

Bug: T28169
Change-Id: Ib27a36e0d76495a133eb8941300e4940e5eb670e
2017-09-22 20:49:08 +02:00
Brad Jorsch
4e6810e4a2 API: i18n for warnings and errors
API warnings and error messages are currently hard-coded English
strings. This patch changes that.

With a few exceptions, this patch should be compatible with non-updated
extensions:
* The change to ApiBase::$messageMap will blow up anything trying to
  mess with it.
* The changes to the 'ApiCheckCanExecute' hook will cause a wrong
  (probably unparsed) error message to be emitted for extensions not
  already using an ApiMessage. Unless they're currently broken like
  Wikibase.

Bug: T37074
Bug: T47843
Depends-On: Ia2b66b57cd4eaddc30b3ffdd7b97d6ca3e02d898
Depends-On: I2e1bb975bb0045476c03ebe6cdec00259bae22ec
Depends-On: I53987bf87c48f6c00deec17a8e957d24fcc3eaa6
Depends-On: Ibf93a459eb62d30f7c70d20e91ec9faeb80d10ed
Depends-On: I3cf889811f44a15935e454dd42f081164d4a098c
Depends-On: Ieae527de86735ddcba34724730e8730fb277b99b
Depends-On: I535344c29d51521147c2a26c341dae38cec3e931
Change-Id: Iae0e2ce3bd42dd4776a9779664086119ac188412
2016-12-06 10:20:48 -05:00
addshore
f48f94dfcc Remove uses of deprecated TestUser properties
Change-Id: Ib44c66492e27516dfe205a5e428ebfd6b0fcdfd9
2016-06-22 16:40:31 +01:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +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
Bartosz Dziewoński
1ebc9128d0 Remove putrid remains of $wgAllowAsyncCopyUploads
None of this works and it's been long begging for a mercy kill.
All it does is waste contributor time on updating deprecations
in the dead code. I imagine we wouldn't reuse much of this
code if we're ever going to reimplement it.

Bug: T119336
Change-Id: Ibd26a4bea621857aac77823017e9be9b7dc52cca
2016-01-22 00:18:25 +00:00
umherirrender
271da88127 Some bugzilla.wikimedia.org -> phabricator.wikimedia.org changes
Changed some old bugzilla links to new phabricator links in comments,
test data and error message. This reduces the need for redirects from
old bugzilla to new phabricator from our source code.

Change-Id: Id98278e26ce31656295a23f3cadb536859c4caa5
2015-09-24 17:17:25 +02:00
addshore
0273f2d498 Remove use of deprecated TestUser->user
Change-Id: Iec47ea2609b4d407e827cec5bf2a834b75727005
2015-08-07 17:10:26 +01:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
Timo Tijhof
b4bac102b6 tests: Clean up file headers
* Remove redundant @licence/@license from test suite files.
  They already have full licence headers. And @licence raises a
  warning in Doxygen.

* Fix weird messes of comments inside comments and other things.

Change-Id: I38da8ca76330f72b8dc22b0ecf1ea69d5ea55ede
2015-04-01 00:17:12 +01:00
Timo Tijhof
48d715148b Use MediaWikiTestCase methods for tempdir in unit tests
* Use MediaWikiTestCase::getNewTempFile and getNewTempDirectory
  instead of wfTempDir().

  The upload api tests wrote a tempnam() file directly (where
  wfTempDir() is typically shared with other systems and concurrent
  runs). Use MediaWikiTestCase::getNewTempFile and
  getNewTempDirectory instead.

  This also ensures its removal by the teardown handler without
  needing manual unlink() calls. And it doesn't rely on the test
  passing. (Many unlink calls where at the bottom of tests,
  which wouldn't be reached in case of failure).

* For the upload test, the presistent storing of
  'Oberaargletscher_from_Oberaar.jpg' (downloaded from Commons)
  was removed. Note that this didn't work for Jenkins builds anyway
  as Jenkins builds set $wgTmpDirectory to a unique directory
  in tmpfs associated with an individual build.

* For filebackend tests, moved directory creation from the dataProvider
  to the main test.

  Implemented addTmpFiles() to allow subclasses to register
  additional files (created by other means) to be cleaned up also.

  Removed unused $tmpName and $toPath parameters in data
  provider for FileBackendTest::testStore. And fixed weird double
  $op2 variable name to be called $op3.

* Skipped parserTest.inc, MockFileBackend.php, and
  UploadFromUrlTestSuite.php as those don't use MediaWikiTestCase.

Change-Id: Ic7feb06ef0c1006eb99485470a1a59419f972545
2015-02-11 03:49:02 +00:00
umherirrender
aa09312ac0 Remove require_once from some tests by adding classes to TestsAutoLoader
Change-Id: If6d0a72acb98e0971fcce2facb239b67cbe639a5
2014-11-12 20:24:08 +01:00
Siebrand Mazeland
e1d58d9071 Pass phpcs-strict on some test files (8/11)
Change-Id: I138c1f9bf2c3c7e9218d5fa29365e78b309fb459
2014-04-24 13:49:48 -07:00
Siebrand Mazeland
80a8a8e85c Pass phpcs-strict on some test files (5/x)
Change-Id: I690645cd8a9b1165dcc8271b201c695ea9391226
2014-04-24 18:51:45 +02:00
addshore
cad7b8368d General Cleanup of some Tests
Style Fixes, Comment fixes

Change-Id: I675d3f098e81709d5dfd928af6ca54589d3d5fad
2013-11-25 14:17:35 +00:00
aude
2f87f4f311 Add @group medium to ApiUploadTest
api tests require either @group medium or @group large

Change-Id: Iea65c4856579690de234a2a8c01669b282a265f3
2013-11-23 22:53:23 +01:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
MatmaRex
61b3f8ad58 No spaces within (casts)
Per the code conventions ([[mw:CC/PHP]]).

This file appears to be the only outlier.

Change-Id: I634d9927174737ffc99976a97a41ce04c842fc32
2013-08-31 18:17:28 +02:00
umherirrender
24bfde2710 Fix spacing and break some lines
Change-Id: Ia57685d8858e02e399ad5c75ce64d12609d340ac
2013-08-24 17:06:25 +02:00
Timo Tijhof
50e7985d4d phpcs: Fix WhiteSpace.LanguageConstructSpacing warnings
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
2013-05-09 05:56:26 +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
419b02b6df Update formatting
3 of n.

Change-Id: I62ad009018c54da6cf081c334e44eb98a3c72695
2013-02-14 12:56:23 +01:00
umherirrender
2a29335af9 apitests leaks wgUser
1) ParserTests::testParserTest with data set #468 ('pre-save transform:
Signature expansion', '* ~~~
* <noinclude>~~~</noinclude>
* <includeonly>~~~</includeonly>
* <onlyinclude>~~~</onlyinclude>', '*
[[Special:Contributions/127.0.0.1|127.0.0.1]]
* <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
*
<includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
*
<onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>',
'pst', '')
pre-save transform: Signature expansion
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'* [[Special:Contributions/127.0.0.1|127.0.0.1]]
-* <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
-*
<includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
-*
<onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>'
+'* [[User:Apitestsysop|Apitestsysop]] ([[User talk:Apitestsysop|talk]])
+* <noinclude>[[User:Apitestsysop|Apitestsysop]] ([[User
talk:Apitestsysop|talk]])</noinclude>
+* <includeonly>[[User:Apitestsysop|Apitestsysop]] ([[User
talk:Apitestsysop|talk]])</includeonly>
+* <onlyinclude>[[User:Apitestsysop|Apitestsysop]] ([[User
talk:Apitestsysop|talk]])</onlyinclude>'

Change-Id: Ia72f9242deb5c6109d38b56dd46ef92fa6386278
2013-02-08 18:57:16 +01:00
Antoine Musso
da8ba7c544 Regroup all API tests in the 'API' PHPUnit group
That will let us tests all the API tests by using PHPUnit group
filtering such as:

 php phpunit.php --group API

Also cleaned some whitespaces

Patchset-4: skipped files that had only whitespace changes

Change-Id: I51e03d910521b061f505e3a9b11a08c7b95f1538
2012-04-02 16:55:31 +02:00
Antoine Musso
c9c00ef397 disable ApiUploadTest
ApiUploadTest gives inconsistent results which trigger false alamrs to all
the ops team. We are disabling those tests for now.

See https://bugzilla.wikimedia.org/26169
2012-02-06 21:39:56 +00:00
Jan Gerber
63030e19b5 Add phpunit tests for chunk upload api.
Follow up r104687
2011-12-27 05:06:41 +00:00
Aaron Schulz
5275f9b097 Merged FileBackend branch. Manually avoiding merging the many prop-only changes SVN likes to sprinkle in (easy to spot from the change list). Did not add SwiftFileBackend.php as it still is in development. 2011-12-20 03:52:06 +00:00
Platonides
a469cf2c95 Mark as FIXME. This three calls leak a png filename in sys_get_temp_dir() each,
tempnam() like, not the two-words filenames of RandomImageGenerator::getRandomFilenames()
They aren't produced by ApiTestCaseUpload::fakeUploadFile() either.
2011-11-08 22:27:25 +00:00
Alexandre Emsenhuber
681523d5ad Fix for r100905:
* Make tests work again
* Added ApiTestCase::doApiRequest() and related to pass it to the context and removed override of $wgUser where possible
* Fix ApiLogin to get the correct User object (i.e. the logged in one)
* Fix ApiBase to feed a RequestContext to setContext() so that ApiLogin can call setUser()
2011-10-27 18:46:40 +00:00
Antoine Musso
7f2e429c17 we must have a session when testing Api upload.
For some reason, the ApiUploadTest::testLogin method no more returns a valid
session. Since most, if not all, of the ApiUploadTest tests depends on it
we want that testLogin method to fail so we can skip the rest of the tests.

Test command:
  ./phpunit.php --filter ApiUpload --tap

BEFORE:
=======

TAP version 13
array(0) {
}
ok 1 - ApiUploadTest::testLogin
ok 2 - ApiUploadTest::testUploadRequiresToken
not ok 3 - Error: ApiUploadTest::testUploadMissingParams
not ok 4 - Error: ApiUploadTest::testUpload
^C

AFTER:
======

TAP version 13
not ok 1 - Failure: ApiUploadTest::testLogin
  ---
  message: 'API Login must return a session'
  severity: fail
  ...
ok 1 - # SKIP This test depends on "ApiUploadTest::testLogin" to pass.
ok 1 - # SKIP This test depends on "ApiUploadTest::testLogin" to pass.
^C ... more skips
2011-10-27 10:28:25 +00:00
Chad Horohoe
e018780327 Fixes for r92251:
* Move Imagick check into getImageWriteMethod(), adjust exception catching. Previously this was bailing on the test if you have convert but not the PHP Imagick extension. Now all these tests are passing for me again.
* Rm unused member variable, whitespace, etc
2011-08-04 22:33:04 +00:00
Ian Baker
9d4fd0c567 Refactored UploadStash and related classes to use the database for file metadata storage instead of the session, see bug 26179
Tweaked the UploadWizard to work properly with the new backend code, updated tests
2011-07-12 21:11:43 +00:00
Chad Horohoe
732e3f1271 Remove notes about being destructive. We work properly on cloned tables now 2011-07-06 17:52:27 +00:00
Chad Horohoe
25bf6f5b43 Fixed a long-standing broken test:
1) ApiUploadTest::testUploadStash
Failed asserting that <boolean:true> is false.

Did this by copying the correct stuff from $_SESSION to our local $session we're using for the test. Not sure if this is strictly correct, but hey it passes ;-)

Currently at: Tests: 1622, Assertions: 32090, Incomplete: 8, Skipped: 5.
2011-06-30 20:11:45 +00:00
Mark A. Hershberger
4e9b2c5c53 Apply modification of mdale's patch from Bug #28420: “Re-factor upload tests to support extensions extending upload test case” 2011-04-06 19:50:54 +00:00
Chad Horohoe
b661588c1f Followup r83140: FakeMemCachedClient -> EmptyBagOStuff in tests 2011-03-03 12:55:22 +00:00