aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/upload
Commit message (Collapse)AuthorAgeFilesLines
* tests: Use namespaced classesUmherirrender2024-10-211-0/+1
| | | | | | | | Changes to the use statements and some additions are done automatically via script This also updates @covers tag for the namespaced classes Change-Id: I859ba6d05018c99710b744e2becab432410d3bca
* Remove meaningless @var documentation from constantsthiemowmde2024-10-091-1/+0
| | | | | | | | | A constant is not a variable. The type is hard-coded via the value and can never change. While the extra @var probably doesn't hurt much, it's redundant and error-prone and can't provide any additional information. Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
* Add namespace to remaining parts of Wikimedia\Mime and Wikimedia\StatsJames D. Forrester2024-09-271-0/+1
| | | | | Bug: T353458 Change-Id: If0137003ab625017d322d57870448a02569668c3
* upload: Add missing documentation to class propertiesUmherirrender2024-09-041-0/+2
| | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: I07ce1f37d1bfb18d6e73dd008a712b3ca60a80e9
* tests: Use namespaced classes (1)Umherirrender2024-06-141-0/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: Iae45fa269363be8ee05c598ea6926514ce817762
* Add getCacheKey static method to UploadFromUrlGiuseppe Lavagetto2024-02-281-0/+11
| | | | | | | This will be useful in making the upload async and allow us to retrieve the status of an upload remotely. Change-Id: I7279185b3c5ece5f4177c0550ca0852810c8f052
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-163-9/+9
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Merge "UploadBaseTest: Add const for path used for test uploads"jenkins-bot2023-08-081-11/+14
|\
| * UploadBaseTest: Add const for path used for test uploadsReedy2023-07-121-11/+14
| | | | | | | | Change-Id: Ic8c210e9223f93ecf66ad2e09de7838f0cd79f70
* | Replace usages of ApiTestCase::$usersDaimona Eaytoy2023-07-251-1/+1
| | | | | | | | | | | | | | Ideally we'd use Authority, but that doesn't always work, so just call the getTest* methods directly. Change-Id: I7f8393bb754beeb319b5555b5dac05265e376a22
* | Deprecate MediaWikiIntegrationTestCase::$usersDaimona Eaytoy2023-07-251-20/+0
|/ | | | | | | | | | | | | | | | | This property shouldn't be needed in modern code, where most things can use Authority. So much so because TestUser adds a dependency on the database, but many tests that use TestUser don't even need the database. ApiTestCase, in particular, sets this property in setUp, thus adding a database dependency to all API tests, including those that don't need users or the database at all. Deprecate the property and replace existing usages in core. The one in ApiTestCase is much harder to migrate, but this patch replaces the array with an anonymous ArrayAccess class to allow lazy initialization and remove DB dependencies. Bug: T155147 Change-Id: I59c4ed1f6a7572d3a92387b15b8e56625bc376a2
* API tests: Assert error codes, not error messagesBartosz Dziewoński2023-04-261-9/+4
| | | | | | | | | | | | | | | Error messages are not guaranteed to be stable, and these tests prevent us from improving them. Error codes are supposed to be stable, so we should be asserting that they do not change (especially since many of them are dynamically generated by the dodgy code in ApiMessageTrait). Introduce helpers assertApiErrorCode() and expectApiErrorCode() to be used instead of the usual PHPUnit assertions/expectations for this case. Change-Id: I752f82f29bf5f9405ea117ebf9e5cf70335464ad
* tests: Make some PHPUnit data providers staticTim Starling2023-03-241-1/+1
| | | | | | | | | | | | | Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
* Follow-up 0f13e81a1: Fix namespace of FileDeleteFormJames D. Forrester2023-03-091-1/+1
| | | | Change-Id: I1587380f669d5434c7f32ed359ab48fc6f79ce6b
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* Reorg: Move five page-related classes to page/ out of includes/Amir Sarabadani2023-02-231-0/+1
| | | | | | | | | | | | These classes: - MergeHistory - MovePage - ProtectionForm - BadFileLookup (to MediaWiki\Page\File) - FileDeleteForm (to MediaWiki\Page\File) Bug: T321882 Change-Id: Ibeb488ba322c62a34042a0307bbb5562773bcad1
* upload: Allow attributes starting with "on" in inkscape SVG namespaceDerk-Jan Hartman2023-02-131-0/+12
| | | | | | | | Inkscape has an attribute only-selected in it's namespace which is not interpreted by browsers and should be safe upload. Bug: T288186 Change-Id: I044f225aef813efc708eb96f588fc55733d165f3
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-281-0/+2
| | | | | | | | | | | | | | | Redoing I5ea70120d74 but without moving WebRequest that caused issues with phan-taint-plugin. Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequestUpload Bug: T321882 Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
* Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-271-2/+0
| | | | | | | | | This reverts commit 2bdc0b2b7209441a42a784157633a8a01b321922. Reason for revert: T166010#8349431 Bug: T166010 Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-261-0/+2
| | | | | | | | | | | | | Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequest - WebRequestUpload Bug: T166010 Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
* Use short array destructuring instead of list()Tim Starling2022-10-211-1/+1
| | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* tests: Migrate away from `setMwGlobals()` to `overrideConfigValue(s)()`Derick Alangi2022-08-142-28/+31
| | | | Change-Id: I1b0e8e2cf4d85ae5ce8ad090cfc47f5086350702
* Add us-ascii to safeXmlEncodingsDerk-Jan Hartman2022-04-271-0/+1
| | | | | | | | | UTF-8 is a strict superset of us-ascii, so any us-ascii file is a valid UTF-8 file. So therefore it should be a safe encoding to use as it does not allow you to hide JavaScript, unlike with UTF-7. Bug: T278386 Change-Id: I0e52120812e3a0bd5112fe2c240ebb2d5d00ebc7
* Allow managing upload-by-url allowlist as a system messageTaavi Väänänen2022-03-231-0/+46
| | | | | | | | | | | This patch introduces a new system message, MediaWiki:copyupload-allowed-domains, which lets sysops to define which domains can be used with the upload-by-url tool. This feature is behind an off-by-default feature flag, which lets system administrators disable this feature if it is not wanted. Bug: T300407 Change-Id: Iae7dafbd71182695444210409d550e5b6d10928b
* Add convenience methods for asserting status.daniel2022-03-161-2/+2
| | | | | | | This ensures that assertions work in a uniform way, and provides meaningful messages in cause of failure. Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
* phpcs: Disable `Generic.Files.LineLength` for test filesTimo Tijhof2022-02-181-1/+0
| | | | | | | | | | | There is a common and reasonable need for longer lines in tests. The nudge for shorter lines doesn't seem valuable here. The natural breaks will likely still fall in 80-100 given the enforced practice for non-test code, e.g. whether through habit, or 80-100 column markers in text editors, or the finite width of diff and code review interfaces. Change-Id: I879479e13551789a67624ce66f0946d2f185e6ee
* Merge "Replace deprecated JobQueueGroup::singleton()"jenkins-bot2022-01-271-2/+3
|\
| * Replace deprecated JobQueueGroup::singleton()Umherirrender2022-01-271-2/+3
| | | | | | | | Change-Id: Icdb301d352d302f70fefba9b40df2368cb217fd2
* | phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-5/+3
|/ | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* tests: Replace usages of deprecated WikiPage::doDeleteArticleRealDaimona Eaytoy2022-01-171-2/+2
| | | | | | | | | Add a new helper to MediaWikiIntegrationTestCase, since deleting pages seems to be pretty common in tests. Some calls to WikiPage::factory were also updated to use WikiPageFactory. Change-Id: I5b5100273a00ac292a1900022ca79708fa254347
* Revert "Use CsrfTokenSet as CSRF token source"Kunal Mehta2021-08-051-7/+11
| | | | | | | This reverts commit 0d75fdb4f73ddbf4ad5f29e14258d58e507d55b4. Bug: T287542 Change-Id: Iedd3461869f973f8d621a39e6ad4674cbb577551
* Hard deprecate User group methodsvladshapik2021-07-231-2/+2
| | | | | | | | | | | | | | | | 1) The following methods were hard deprecated: - User::addAutopromoteOnceGroups - User::getEffectiveGroups - User::getAutomaticGroups - User::getFormerGroups 2) User ::getGroups, ::getGroupMemberships, ::addGroup, ::removeGroup were replaced in the production code, but they were not hard deprecated because of conflict with UserRightsProxy class. Bug: T275148 Change-Id: Ia69598316f5dc5dd9511f6112b5b13e1aa07575a
* build: Updating dependencieslibraryupgrader2021-07-223-3/+3
| | | | | | | | | | | | | | 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
* Use CsrfTokenSet as CSRF token sourcePetr Pchelko2021-07-121-15/+8
| | | | Change-Id: I079d2c802d9b48d6abf7f37fa9ef7dafac631345
* Remove some more comments that literally repeat the codeThiemo Kreuz2021-06-181-1/+1
| | | | | | | | | | | | | … including PHPDoc tags like `@return <type> $variableName`. A return value doesn't have a variable name. I can see that some people do this intentionally, repeating the variable name that was used in the final `return $var;` at the end of a method. This can indeed be helpful. I leave a lot of these untouched and removed them only when it's obviously wrong, or does not provide any additional information in addition to what the code already says. Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
* Add missing @param and @return to documentation in testsUmherirrender2021-01-221-0/+3
| | | | Change-Id: Ic663e81cca0bf007804a70772250914a85f1fef4
* Deprecate InterwikiLoadPrefix hookC. Scott Ananian2020-12-211-6/+6
| | | | | | | | | | | | | | | The InterwikiLoadPrefix hook isn't compatible with Parsoid, as it is unidirectional and doesn't support enumerating all valid prefixes (T270444). Set/reset $wgInterwikiCache to mock the interwiki table for parserTests and other unit tests instead. This is a soft deprecation, as the used-in-production Extension:Interwiki still uses InterwikiLoadPrefix, although not in a way that would break Parsoid (since $wgInterwikiCache is set in production). Bug: T270444 Change-Id: If2507017c99c4ee42c104a0890bc45a84d7239d5
* Fix tests assume badaccess-groups message in singular formUmherirrender2020-10-301-1/+4
| | | | Change-Id: I63476388655ae317453b9ebca793329a23519a4c
* Revert "PHPUnit: prevent HTTP requests"Kosta Harlan2020-10-081-0/+2
| | | | | | | | This reverts commit b35ab283b223c64705ccffa56af9c3be129126fb. Bug: T265024 Bug: T262443 Change-Id: I65ddf30805ba8a2932af57ee28fc2c4700c3490f
* PHPUnit: prevent HTTP requestsdaniel2020-09-301-2/+0
| | | | | | | | | Tests should not make real HTTP requests. Mock out the HTTPRequestFactory service to prevent this. Bug: T262443 Depends-On: I63bfd54c3de55d678e8b862b85c0adfb5fc94d91 Change-Id: I1702c11928f8760bb41b41f4c7c04d7af03f62e2
* Introduce MockHttpTraitdaniel2020-09-281-84/+2
| | | | | | | | | | | MockHttpTrait can be used by tests that need to simulate HTTP requests. Bug: T262443 Needed-By: I1832cb1858ef4cf42ec34cb7fda509ce5b951c27 Needed-By: I390856b4609635cee22253071f21ce63ff716791 Needed-By: Iff24b55dfaf7a4e02a4c80aaeaf0366de5660ef1 Needed-By: Ia8213725839e4b697c4985060bc35593fea622bc Change-Id: I8ce17da7315b87b8dd0e502e601b9ac488089456
* Manually redirect in UploadFromUrlHolger Knust2020-09-141-13/+61
| | | | | | | | | | | The upload function saved the redirect page(s) content together with the upload file content which would produce an incorrect MIME type (text/html instead of actual upload MIME type). Disabled the automatic redirect and reset the file content until the final file location or the maximum number of redirect is reached. This patch also touches WatchedItemQueryServiceIntegrationTest to make it more robust. Without this change, UploadFromUrlTest interfered with WatchedItemQueryServiceIntegrationTest in some way, causing it to fail. Bug: T258122 Change-Id: I1de709576c02ce5b31b356751680cbd23689a3fa
* UploadFromUrlTest: don't make a real requestdaniel2020-09-101-0/+89
| | | | | | | | This test currently fails if it cannot download a file from http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png Bug: T262443 Change-Id: I3d0438f6f47e129b2a7b52833f7ab9fb0781bf48
* MediaWikiTestCase to MediaWikiIntegrationTestCaseaddshore2020-06-302-2/+2
| | | | | | | | | | | | | The name change happened some time ago, and I think its about time to start using the name name! (Done with a find and replace) My personal motivation for doing this is that I have started trying out vscode as an IDE for mediawiki development, and right now it doesn't appear to handle php aliases very well or at all. Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
* Merge "upload: Modernize callback code to make use of PHP7 syntax"jenkins-bot2020-06-161-2/+2
|\
| * upload: Modernize callback code to make use of PHP7 syntaxThiemo Kreuz2020-05-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | * Update the two "processing_instruction_handler" and "external_dtd_handler" callbacks to use a syntax for the callback that doesn't stuff the class name in a string, but actually references the class. * We don't need call_user_func() in modern PHP7 any more. * Add and update a few type hints in UploadBase to make the code easier explorable. Change-Id: I0ab3cfbe4f0bf15b1da4ab10fd9ffc1986d968d0
* | Stop throwing an exception in UploadStash::getExtensionForPathReedy2020-05-311-29/+0
|/ | | | | | | | | | | | | | | | | | | The exception serves no purpose, and can only really be triggered via a test. The API prevents no file extension at all, as does UW js. This function (for whatever reason, probably a seperate bug) cannot get the extension from a stashed stl file (seems to work fine for other types). With what/how it's actually used, it doens't really matter if we can't get the extension, we get it by more robust methods later on. This partially reverts 0a82600a27. Before the changes in that commit, the exception was unreachable. Bug: T254078 Change-Id: I0a7bd13fe8e08c7d4a75b4a3709661dbbf53d6cb
* upload: Fix incorrect handling of missing file extension in UploadStashOri Livneh2020-05-221-12/+2
| | | | | | | | | | | | | | | | | The problematic code: $extensions = explode( ' ', $magic->getExtensionsForType( $mimeType ) ); if ( count( $extensions ) ) { $extension = $extensions[0]; } If $mimeType is not known to MediaWiki, $magic->getExtensionsForType($mimeType) will return null. explode( ' ', null ) is [""]. (Thank you so much, PHP!) This means $extensions is nonempty (it contains the empty string), so $extension is set to ''. Change-Id: Icf387a9c93cb7351c2f48c69f413e7ad2224ba6b
* Tests: Replace ::doDeleteArticle with WikiPage::doDeleteArticleRealDannyS7122020-03-251-1/+1
| | | | | | | Not including WikiPageDbTestBase, which is testing the method Bug: T248000 Change-Id: I1848a79be9e25759654053e88ef956269342f588
* Use MediaWikiServices::getRepoGroup in file related classesUmherirrender2020-03-142-3/+10
| | | | Change-Id: Iceec961de4f0cc689f7d3b981afac923b46c98f6