aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/filebackend
Commit message (Collapse)AuthorAgeFilesLines
...
* Replace uses of DB_MASTER with DB_PRIMARYJames D. Forrester2021-04-292-3/+3
| | | | | | Just an auto-replace from codesniffer for now. Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
* Allow x-delete-at and x-delete-after expiry headerskalle2021-04-261-0/+30
| | | | | | | | | | | | | | From: https://docs.openstack.org/swift/latest/overview_expiring_objects.html The swift-object-expirer offers scheduled deletion of objects. The Swift client would use the X-Delete-At or X-Delete-After headers during an object PUT or POST and the cluster would automatically quit serving that object at the specified time and would shortly thereafter remove the object from the system. Bug: T280496 Change-Id: I886f3cea51f80d820841f8548941ca02a0a514c3
* Tests: Start marking some closures as staticReedy2021-02-061-1/+1
| | | | | Bug: T274036 Change-Id: Ib738ecd3bc23d34900bc268c8246702ac3655746
* build: Update mediawiki/mediawiki-codesniffer to 35.0.0Umherirrender2021-01-311-3/+3
| | | | Change-Id: Idb413be4b8cba8611afdc022af59810ce1a4531e
* More misc test cleanupDannyS7122020-12-241-36/+0
| | | | | | | | | * parent::setUp() should be first, and ::tearDown() should be last * Move tests that directly extend PHPUnit\Framework\TestCase to /unit Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
* Merge "Make unit tests assertion about assertNotEquals more strict"jenkins-bot2020-11-021-7/+7
|\
| * Make unit tests assertion about assertNotEquals more strictUmherirrender2020-11-011-7/+7
| | | | | | | | | | | | | | Originally an autofix of PHPUnitAssertEquals sniff, but manually updated. Change-Id: I78efc6f7997f0b7227b40d7eab1495cc7a1d7da5
* | [FileBackendIntegrationTest] Set logger and add notnull assertsUmherirrender2020-10-301-1/+25
|/ | | | | | | | | | | The logger helps to see all the log output in the phpunit log extract for each failing test. The asserts helps to understand the tests better. On my windows the getFileList is returning null and than the foreach emits a php warning. Now there is an assert error. Change-Id: Idb5c94392aff024506b4e92f226eab3a263dbab2
* filebackend: Fix index error in SwiftFileBackendThiemo Kreuz2020-07-281-0/+4
| | | | | | | This fixes a regression introduced by If3d2f18. Bug: T259023 Change-Id: I654b1bcf0ff65f68ed7d92d51a6b39325da731f3
* Reduce nesting by turning big if-else into guard clausesThiemo Kreuz2020-07-241-1/+1
| | | | Change-Id: If3d2f18af0cc7d0f8fe9f764bd4d0e4bae70e440
* MediaWikiTestCase to MediaWikiIntegrationTestCaseaddshore2020-06-301-1/+1
| | | | | | | | | | | | | 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
* build: Bump mediawiki-codesniffer to 31.0.0Daimona Eaytoy2020-05-301-1/+1
| | | | | | | | | Done with `composer fix` and suppressing the rest (i.e. sniffs for global variables, which for core should be suppressed anyway). Additionally, add `-p` to `phpcbf`, as otherwise it just seems stuck. Change-Id: Ide8d6cdd083655891b6d654e78440fbda81ab2bc
* tests: Make static/non-static functions matchMax Semenik2020-04-291-1/+2
| | | | | | | PHP 8 is stricter about this. Bug: T248925 Change-Id: I0e9c736d0e2a28ce4a1e096a8ec63321d8b41635
* Set logger to null when connecting to DB in DBFileJournalIntegrationTest.phpNikki Nikkhoui2020-04-131-2/+3
| | | | | | | | | | The code is appropriately logging when it encounters a database connection error. However, the CI interprets that as an actual exception being thrown. Setting the logger to null allows the CI to complete. Bug: T248194 Change-Id: If8be607e93082202551d3e8b5421fc2e07268243
* Replace all `new stdClass()` with identical `(object)[]`Thiemo Kreuz2020-03-041-1/+1
| | | | | | | | | | | | This should be the exact same. Its more a style change than anything. So why do it then? * I believe this is much less confusing than code mentioning a weird "standard class". Barely anybody knows what this is, and what the difference between "object" and "stdClass" is. * The code is shorter. * It's even faster. In my micro benchmark it's twice as fast. Change-Id: I7ee0e8ae6d9264a89b6cd1dd861f0466ae620ccc
* Make use of PHPUnit's assertCount feature where possibleThiemo Kreuz2020-03-021-3/+3
| | | | | | | … and avoid assertEmpty() on arrays, in favor of a much more strict assertSame( [] ). Change-Id: I20266b0b1fc38a3a87666ba1b0793cb2b37d94a9
* Coding style: Auto-fix MediaWiki.Usage.PHPUnit*James D. Forrester2020-01-101-44/+47
| | | | Change-Id: I86fc55a4fc8ceafe368692173211bbcd6d8581d7
* Deprecate FileJournal::factoryAryeh Gregor2019-11-042-4/+6
| | | | | | | | | Instead, the constructors for FileJournal and NullFileJournal should be treated as stable. I would have added @stable, but our linting doesn't recognize it yet and doesn't let. Bug: T235066 Change-Id: I7741055b4f00197d1346ebbfebc14f20238a06f3
* Merge "tests: Add explicit return type void to setUp() and tearDown()"jenkins-bot2019-11-013-3/+3
|\
| * tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-303-3/+3
| | | | | | | | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* | 100% unit test coverage for FileBackendAryeh Gregor2019-10-301-115/+0
|/ | | | | Bug: T234227 Change-Id: I2bfd975e9af78f4ee792d024ad7c1dd06902a284
* Unit tests for FileBackendAryeh Gregor2019-10-301-1/+1
| | | | | | | | | | | Currently 62.79% coverage, 108/172 lines. One oddity discovered during testing was that the "quick" variants of most methods don't have an $opts parameter. It seems like just an oversight, so I added it. Bug: T234227 Change-Id: If2978065392cd6dcf693a588bb1ce6b5d43828f2
* Convert FileBackendGroup to serviceAryeh Gregor2019-10-252-6/+12
| | | | | Bug: T234228 Change-Id: I25575f565eba122cdf971a5945572811d17fa3e1
* Add public as visibility in tests folderUmherirrender2019-10-101-2/+2
| | | | | | | Add public, protected or private to function missing a visibility Enable the tests folder for the phpcs sniff Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
* tests: Replace PHPUnit's loose assertEquals(false) with assertFalse()Thiemo Kreuz2019-10-041-20/+19
| | | | | | | | | | | | | assertEquals( false, … ) still succeeds when the actual value is 0, null, an empty string, even an empty array. All these should be reported as a failure, I would argue. Note this patch previously also touched assertSame( false ). I reverted these. The only benefit would have been consistency within this codebase, but there is no strict reason to prefer one over the other. assertFalse() and assertSame( false ) are functionally identical. Change-Id: Ic5f1c7d504e7249002d3184520012e03313137b4
* Expand testDoQuickOperations() tests for FileBackendAaron Schulz2019-09-291-57/+117
| | | | Change-Id: I0633f13f07b5a3234b9bbae4840b064972f68fd9
* tests: Replace PHPUnit's loose assertEquals(null) with assertNull()Thiemo Kreuz2019-09-271-3/+3
| | | | | | | | | | | | | assertEquals( null, … ) still succeeds when the actual value is 0, false, an empty string, even an empty array. All these should be reported as a failure, I would argue. Note this patch previously also touched assertSame( null ). I reverted these. The only benefit would have been consistency within this codebase, but there is no strict reason to prefer one over the other. assertNull() and assertSame( null ) are functionally identical. Change-Id: I92102e833a8bc6af90b9516826abf111e2b79aac
* tests: Prefer assertSame() when comparing the integer 0Thiemo Kreuz2019-09-191-1/+1
| | | | | | | assertSame() is guaranteed to not do any type conversion. This can be critical when acciden tially comparing, for example, 0 to 0.0. Change-Id: Iffcc9bda69573623ba14af655dcd697d0fcce525
* Make doTestLockCalls() fasterAaron Schulz2019-09-131-1/+1
| | | | | | | This was mostly doing many runs just to test for random lock errors in versions of Windows from a few years back. Just do three quick rounds. Change-Id: I2ec2a8ce66a5c14bfc9338b60f8a57b2de8eaece
* filebackend: rename and simplify header sanitizing methods in SwiftFileBackendAaron Schulz2019-09-081-76/+17
| | | | | | | | | In addition: * Remove restriction that Content-Type was ignored in 'copy' and 'move'. * Fix failing tests due to copy/move not respecting 'ignoreMissingSource' when using doQuickOperations(). Change-Id: Id1befeefeaaf75f0a6bf0e68b1e62271d432f953
* filebackend: optimize 'move' in FSFileBackend to avoid is_file() callsAaron Schulz2019-09-071-7/+16
| | | | | | Also, remove clearstatcache() call that is redundant with moveInternal() Change-Id: I56e6c3d91427e7d0b49011f884b77daa5eb0b61c
* filebackend: optimize 'delete' for FSFileBackend to avoid is_file() callsAaron Schulz2019-09-071-5/+6
| | | | | | This also should reduce the chance of warnings due to race conditions Change-Id: I06b6bcc5e0f009bb3d5135591d13ff098710a5b3
* filebackend: improve internal use of FileBackend constantsAaron Schulz2019-09-031-197/+261
| | | | | | | | | | | | | | | | | | | | | | Add more result constants and split up FileBackend::UNKNOWN for clarity. This follows up 5719815f3b, which added that constant. Make internal FileBackendStore::doGet* methods distinguish I/O errors from missing files; the return types of public FileBackend methods are unchanged. Avoid process caching any mtime/size/sha1 values in the case of I/O errors. Use error constants consistently for stat methods when given invalid paths. Also: * Factor out FileBackendStore::processCacheAndPersistStatEntries() method to reduce significant code duplication. * Consolidate duplicated isPathUsable() checks in FileOp subclasses to FileOp::precheck(). * Remove null process cache value check from FileBackend::getFileStat() as null values are never stored in the process cache to begin with. * Reformat some oddly wrapped lines to look cleaner. Change-Id: Id0e4b0da0bb2ed3184847b35142d587c7f3d953d
* FileJournal testsAryeh Gregor2019-09-032-2/+237
| | | | | | | | | | | | | 100% unit test coverage for FileJournal and NullFileJournal. 100% integration test coverage for DBFileJournal. Unit tests for DBFileJournal once it supports injection. I removed FileJournal and NullFileJournal from the list of classes that FileBackendTest tests. It doesn't actually test them, it just happens to run code from them without checking its correctness at all. Depends-On: Ic22075bb5e81b7c2c4c1b8647547aa55306a10a7 Change-Id: I46d10ab7b87c23937aa04d7ec1922abfcf3bd611
* Fix FileBackendGroup test for some configurationsAryeh Gregor2019-08-291-1/+5
| | | | | | | | | | | | | The expected value of FileBackendGroup::config()['srvCache'] was being obtained from MediaWikiServices::getLocalServerObjectCache(), but the class actually used ObjectCache::getLocalServerInstance( 'hash' ). It happens these are often the same, so it passed the gate-and-submit jobs, but it's causing failures on Travis CI. Follow-up to bd2a4395025, which added the failing test. Thanks to Krinkle for pointing out the failures on CI. Change-Id: I17651766f4ee2752dfcae9574d2538269dec4ebe
* Merge "Integration tests for FileBackendGroup"jenkins-bot2019-08-281-0/+57
|\
| * Integration tests for FileBackendGroupAryeh Gregor2019-08-281-0/+57
| | | | | | | | | | | | | | 100% coverage except for one bit of the code that I didn't understand. Unit tests to come, together with rewrite as a service. Change-Id: Ib01758d994a9e5587a4fcb5edc3d80010ef05615
* | LockManagerGroup tweaksAryeh Gregor2019-08-281-1/+1
|/ | | | | | | | | | | One small change that was supposed to be in 5a6c18a0863 but didn't make it into the patch version that got merged, and removal of some long-dead code. phan objected to the use of new $class without being explicitly reassured that $class is, in fact, a string. I don't know why. Change-Id: Ifa00c59ab4464109414f21db37e3a6db21decdf3
* Some integration tests for LockManagerGroupAryeh Gregor2019-08-221-0/+84
| | | | Change-Id: Ide94a260e5f96c4cfcf76c1ee9b8dcf486976263
* Add helper for HTTPFileStreamer header syntaxGergő Tisza2019-07-111-0/+36
| | | | | | | | Adds a helper function for transforming an intuitive header array to the peculiar syntax expected by HTTPFileStreamer and the related FileRepo/FileBackend streaming methods. Change-Id: Idac9281b0f1b3c93f4ec1d1c3f336db110e5d260
* Revert "Separate MediaWiki unit and integration tests"Legoktm2019-06-131-0/+216
| | | | | | | | This reverts commit 0a2b996278e57a8b8c5377cd3a3eaa54f993d4a9. Reason for revert: Broke postgres tests. Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
* Separate MediaWiki unit and integration testsMáté Szabó2019-06-131-216/+0
| | | | | | | | | | | | | | | | | | | | | This changeset implements T89432 and related tickets and is based on exploration done at the Prague Hackathon. The goal is to identify tests in MediaWiki core that can be run without having to install & configure MediaWiki and its dependencies, and provide a way to execute these tests via the standard phpunit entry point, allowing for faster development and integration with existing tooling like IDEs. The initial set of tests that met these criteria were identified using the work Amir did in I88822667693d9e00ac3d4639c87bc24e5083e5e8. These tests were then moved into a new subdirectory under phpunit/ and organized into a separate test suite. The environment for this suite is set up via a PHPUnit bootstrap file without a custom entry point. You can execute these tests by running: $ vendor/bin/phpunit -d memory_limit=512M -c tests/phpunit/unit-tests.xml Bug: T89432 Bug: T87781 Bug: T84948 Change-Id: Iad01033a0548afd4d2a6f2c1ef6fcc9debf72c0d
* tests: Remove use of wfRandomString() for test fixturesTimo Tijhof2019-05-061-5/+3
| | | | | | | | | | | | | | | | | | | | | | | This reduces confidence in the test. There is no guruantee that it won't return the same value twice during the duration of a full PHPUnit run of all test suites, whether twice in a row or 20 minutes apart. For a test that needs a string of any kind, use an explicit, consinstent and cheap literal value. For a test that specifically needs some kind of uniqueness compared to something else within the same test case, do so explicitly. Tests that require something globally unique (for some undefined/vague definition of "global") were not found, and should not exist anyway. Also, in libs/objectcache tests, fix order of parameters in some assertions (expected first, then actual), and use assertFalse/assertSame instead of assertEqual for cases where false is expected to remove tolerance of other loosely equal values. Change-Id: Ifc60e88178da471330b94bfbf12e2731d2efc77d
* Deprecate the Http classAryeh Gregor2019-05-061-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | All methods got moved to HttpRequestFactory or MWHttpRequest or dropped. I made the return value of the new HttpRequestFactory::request/get/post methods null on error instead of false, so that when we drop PHP 7 support, we can use a "?string" return value. This could theoretically change behavior of code that was switched from the old Http methods, but probably won't. I kept the old behavior for the deprecated methods. I changed the default value of $wgHTTPProxy from false to ''. This way it should be usable directly without a trivial wrapper method. For the benefit of anyone who might have set it to false in LocalSettings.php, I also recommend casting to string just in case. Http::$httpEngine is deprecated. Eventually it will be removed along with the curl and PHP engines, leaving only the Guzlle engine. I also added deprecation of MWHttpRequest::factory, which occurred in 1.31, to the release notes for 1.34. Now hopefully we can hard-deprecate it in another couple of versions. Bug: T214390 Change-Id: I2a316a758d793857f248bd251b90f5e9a6440e3a
* Remove a few obscure "done" and "empty" commentsThiemo Kreuz2019-01-301-2/+2
| | | | | | | These don't add any knowledge to what is already obvious from the code, I find. Change-Id: Ia613b6a059f78dbeefdfd020899bd1a6e239a731
* Disallow empty paths in LockManagerAaron Schulz2018-07-261-20/+21
| | | | | | Fix broken FileBackend test that had paths normalizing to null. Change-Id: I8a7e88ae44118cc9578e1b306a5a008ccefc23af
* Update suppressWarning()/restoreWarning() callsReedy2018-02-101-2/+2
| | | | | Bug: T182273 Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
* Use ::class to resolve class names in testsUmherirrender2018-01-262-9/+9
| | | | | | | This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
* Do not strip Content-Type header for POST requests to swiftCormac Parle2017-11-281-0/+65
| | | | | | | | | | | | libcurl adds 'Content-Type: application/x-www-form-urlencoded' to a POST request if the 'Content-Type' header is not set manually. Because data in swift is updated via POST, the Content-Type header must be set explicitly to stop a run of refreshFileHeaders.php from changing the Content-Type of all files in swift to application/x-www-form-urlencoded Bug: T178849 Change-Id: I43c21bc1b73e37104cf07cd5f1c1557f472b9898
* Switch to librarized version of TestingAccessWrapperGergő Tisza2017-04-202-0/+4
| | | | | | | | | | | | | | | Replaces \TestingAccessWrapper (defined in core) with \Wikimedia\TestingAccessWrapper (defined in the composer package wikimedia/testing-access-wrapper). See https://gerrit.wikimedia.org/r/#/q/topic:librarize-testing-access-wrapper for downstream patches. The core version of the class is kept around for a while to avoid circular dependency problems. Bug: T163434 Change-Id: I52cc257e593da3d6c3b01a909e554a950225aec8