aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | parser: Gracefully handle invalid ParsoidRenderID keysMáté Szabó2025-02-041-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - ParsoidRenderID::newFromKey() validates incoming keys and throws an InvalidArgumentException if a required key component was missing. - It does so by eagerly destructuring the return value of explode(), which causes a PHP Notice for invalid inputs as the expected offsets won't exist then. What: - Check the count of key parts before destructuring. - Add unit tests. Bug: T385567 Change-Id: I1d936ae038f85ffa2e5d1d3d8a75fdc75e4c8ef8
* | | | | Merge "Replace wfDeprecatedMsg with trigger_error in ScalarParam.php"jenkins-bot2025-02-031-3/+26
|\ \ \ \ \ | |_|_|/ / |/| | | |
| * | | | Replace wfDeprecatedMsg with trigger_error in ScalarParam.phpDoğu Abaris2025-02-021-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wfDeprecatedMsg was replaced with trigger_error for better alignment with non-MediaWiki environments. Change-Id: Icc5a58cb2eccf26def393a9715ab5089cf4b7951
* | | | | Merge "Save results cache files to log folder for later analysis"jenkins-bot2025-02-031-2/+4
|\ \ \ \ \
| * | | | | Save results cache files to log folder for later analysisArthur Taylor2025-01-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: T378797 Change-Id: I3f0177e85d71dd5c1526cdd42fbee69d8d1f6eca
* | | | | | Merge "Revisions: Rewrite a RevisionRecordTests for readability"jenkins-bot2025-02-031-20/+30
|\ \ \ \ \ \
| * | | | | | Revisions: Rewrite a RevisionRecordTests for readabilitythiemowmde2025-01-291-20/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I find the code quite surprising and hard to read because it assumes that a variable will continue to live outside of the scope of the "catch". This might work in PHP but not necessarily in other languages and can be confusing because of this. PHPUnit does have standard utilities to work with exceptions: * In the first example we don't need to catch the exception just to make the test fail. PHPUnit already does this. * In the other two examples the PHPUnit way to do this is with expectException. The extra assertions in the end don't do much but are needed to not have the tests marked as risky. Change-Id: I62220a93ac176c42d4a44724484d05db89fb601c
* | | | | | | Merge "build: Updating mediawiki/mediawiki-codesniffer to 46.0.0"jenkins-bot2025-02-022-4/+4
|\ \ \ \ \ \ \ | |_|_|/ / / / |/| | | | | |
| * | | | | | build: Updating mediawiki/mediawiki-codesniffer to 46.0.0libraryupgrader2025-01-312-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: I0f8a8cac36015bba52aea3ee2affd92f83d3574a
* | | | | | | Add TransactionProfiler::getExpectationDreamy Jazz2025-01-311-0/+19
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: * Code in the CheckUser extension needs to know when the expectations of a request are defined as POST-nonwrite. ** This is because CheckUser may need to make writes to the DB as a result of an auto-creation of an account made during a POST-nonwrite API request. * This code cannot currently query the TransactionProfiler to see the expectations for a request, and cannot also easily see if the API request is non-writing. ** Allowing the CheckUser code to see the expectations for the number of writes in the request will allow it to instead insert the data using a job when writes are not expected but still insert in the usual way when in a POST request that allows writes. What: * Add TransactionProfiler::getExpectation which returns the TransactionProfiler::FLD_LIMIT value for a given event name ** The method throws an InvalidArgumentException if the event name provided is not recognised. * Add tests for the new method. Bug: T384915 Change-Id: I54dc388557c3b0cb4fd73625132fb64b14f4ddd0
* | | | | | Allow translation of nested response body descriptionsfrankie2025-01-301-11/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend translation functionality to translate nested parameter properties. Bug: T383790 Change-Id: I22e95764971a4d886136d227016ce36192b41b7f
* | | | | | Merge "Introduce ParsoidExperimentalParserFunctionOutput config flag"jenkins-bot2025-01-301-0/+1
|\ \ \ \ \ \
| * | | | | | Introduce ParsoidExperimentalParserFunctionOutput config flagSubramanya Sastry2025-01-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Plumb this value into Parsoid's SiteConfig so that the Parsoid library code can access this. Bug: T373253 Bug: T385129 Change-Id: If119ff94e65325fc446ca068e0b2d2434c070a2e
* | | | | | | Stats: Add support for chaining TimingMetric->start()Timo Tijhof2025-01-301-3/+6
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: T240685 Bug: T364240 Change-Id: Id1fe4ac6127894c9861b0d904c7a55f21deb7455
* | / / / / objectcache: Require a TracerInterface in ObjectCacheFactoryMáté Szabó2025-01-281-0/+13
| |/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - Ief4258ef6d46fb237837907c6ecb96bb3afe6d81 has implemented tracing support for ObjectCacheFactory via an injected TracerInterface instance. - This new parameter is typehinted as TelemetryHeadersInterface, which TracerInterface extends, but in practice always receives a TracerInterface implementation. What: - Make it require TracerInterface. - Add a test. Bug: T340552 Change-Id: I653a48ab9d904816ae062896454e7c3193e94fa4
* | | | | ObjectCacheFactory: use Tracer telemetryChris Danis2025-01-271-1/+3
| |_|/ / |/| | | | | | | | | | | | | | | Bug: T340552 Change-Id: Ief4258ef6d46fb237837907c6ecb96bb3afe6d81
* | | | tracing: lowercase headers before processing themChris Danis2025-01-231-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This seems the cleaner fix, since we do want to emit output headers in lowercase, as that's what the rest of mediawiki/core emits nowadays, as well as basically the rest of the world. Bug: T384629 Change-Id: I8ea568e316c6e06b8c3d6f370b04be57dcbddc0a
* | | | Fix broken redirect warning showing for special or interwiki targetsSomeRandomDeveloper2025-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using Title::exists does not account for special or interwiki pages which are also valid redirect targets. Using Title::isKnown instead does no longer cause the warning to appear when redirecting to a special page or an interwiki link. Bug: T384393 Change-Id: I35e4c72b0e21aaa36c1f8b1ac85fa819d353945e
* | | | Merge "resourceloader: Minor documentation corrections"jenkins-bot2025-01-221-17/+4
|\ \ \ \ | |/ / / |/| | |
| * | | resourceloader: Minor documentation correctionsBartosz Dziewoński2025-01-201-17/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issues spotted while working on I03a9a6945ab27e9888ea21b03985ed713f0a9b50. Some code style improvements too. Change-Id: I409d0a1805aa7430cc86e53633f4f85ef8a76dcf
* | | | ParamValidator: reject expiry dates that don't fit in 14 charsTim Starling2025-01-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In ExpiryDef::normalizeExpiry(), throw an InvalidArgumentException if the expiry string indicates a date outside of the years 0 - 9999. Such timestamps fail in various exotic ways, so it's best to reject them early. Bug: T384241 Change-Id: Ic2110421e8ff1a8892d02b600a0dce965b36c82d
* | | | Merge "Add a warning when trying to create a double redirect"jenkins-bot2025-01-211-0/+99
|\ \ \ \
| * | | | Add a warning when trying to create a double redirectSomeRandomDeveloper2025-01-171-0/+99
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | Shows a warning when trying to create a redirect that points to another redirect. Bug: T326056 Change-Id: Ieb51dde88ce6c23753f74191a85cd40f0bfbd864
* | | | DomainEvent: Support type hierarchiesdaniel2025-01-211-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - It's useful to be able to listen to sets of compatible event types. What: - Make DomainEvents aware of a list of types they are compatible with. - Make EventDispatchEngine dispatch to all compatible listeners, registered for any of the supported types. - Move all page events to their own namespace Bug: T384330 Change-Id: I96bde2cfaf198e409a6ef3a24101ee7d02d57959
* | | | Merge "Add RestCheckCanExecute hook"jenkins-bot2025-01-203-16/+45
|\ \ \ \ | |/ / / |/| | |
| * | | Add RestCheckCanExecute hookGergő Tisza2025-01-203-16/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a REST API hook that allows disabling specific endpoints or rejecting specific requests, similar to ApiCheckCanExecuteHook. Bug: T383011 Change-Id: I8518cb1ad7f00594c9f31d7bf934b1ce74f18da9
* | | | phpunit: Fix ScrambleMappingTest skip conditionMáté Szabó2025-01-171-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - ScrambleMapping requires either the gmp or bcmath PHP extensions, and throws an error if neither is loaded. - One of the test cases in ScrambleMappingTest skips itself if neither PHP extension is available, but the other doesn't. What: - Move the check to a PHPUnit setup function so that it is performed before every test case in the class. Change-Id: I2141b06e85d11ba78a713b9ff35af6e9313b9ffc
* | | | Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-1711-42/+0
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* | | Merge "Remove trivial 1-line PHPDocs that just repeat the code"jenkins-bot2025-01-165-11/+0
|\ \ \
| * | | Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-165-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I assume these are all either auto-generated by an IDE or the language-level type declarations have been added later. In any case the comments don't add any new information to what the code already says. This is just extra clutter that makes the code harder to read, I would argue. There are many, many more comments like this. In this patch I intentionally focus on the most trivial 1-line comments. Change-Id: Ia294bf4ce0d8a77036842fe25884bc175c2b0e7d
* | | | Merge "ConditionalDefaultsLookup: Move the hook call to the service itself"jenkins-bot2025-01-161-6/+20
|\ \ \ \
| * | | | ConditionalDefaultsLookup: Move the hook call to the service itselfMartin Urbanec2025-01-141-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of T383701, I am planning to add a new hook to the service, to allow extensions to modify ConditionalUserOptions. That hook would be cubersome to call from ServiceWiring. In order to maintain a single pattern, this patch refactors the service to contain the call. Bug: T383701 Change-Id: Idf5e84543f996a500a66c72b6bac97d188995de9
* | | | | Merge "telemetry: Add propagator tests"jenkins-bot2025-01-164-0/+199
|\ \ \ \ \ | |_|/ / / |/| | | |
| * | | | telemetry: Add propagator testsMáté Szabó2025-01-154-0/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - Some of the newly implemented propagator functionality is missing unit tests. What: - Add relevant test cases. Bug: T340552 Change-Id: I63333310f7ca49321768958c6be7a0da1fb73916
* | | | | Merge "Message: Delay constructing Language objects"jenkins-bot2025-01-151-2/+4
|\ \ \ \ \ | |/ / / / |/| | | |
| * | | | Message: Delay constructing Language objectsBartosz Dziewoński2025-01-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having these huge objects attached to every Message makes it difficult to compare them in serialization tests, because they indirectly hold references to a bajillion services, which are different in the test providers and the tests, so all comparisons fail unless you reset each of the bajillion of services or delay constructing the objects. Bug: T373719 Bug: T376565 Change-Id: I373cc9ec6d44ff2c82ccf143ede12969d7ff8203
* | | | | Merge "block: Fix HideUserUtils error when user is hidden twice"jenkins-bot2025-01-141-1/+2
|\ \ \ \ \
| * | | | | block: Fix HideUserUtils error when user is hidden twiceTim Starling2025-01-101-1/+2
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a limit to the HideUserUtils subqueries to avoid error "Subquery returns more than 1 row". We really want to know if at least one row exists. * Fix outdated doc comment * Add tests. Bug: T382399 Change-Id: Ib3bc22e0b3080b3ae6e1d2591ac7f2a1ef57c6b3
* | | | | Merge "DomainEventSource: introduce dispatch modes"jenkins-bot2025-01-132-47/+45
|\ \ \ \ \
| * | | | | DomainEventSource: introduce dispatch modesdaniel2025-01-132-47/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces support for invoking listeners before commit, in addition to after commit. This also removes the dependency on HookContainer and adds automatic discovery of the correct invocation mode to EventSubscriberBase. Bug: T379775 Change-Id: I16510738477b37129872a887163ec0b84647c94e
* | | | | | Merge "config schema: Improve validation for array types"jenkins-bot2025-01-131-1/+6
|\ \ \ \ \ \
| * | | | | | config schema: Improve validation for array typesAmmarpad2025-01-031-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does two things: 1. Be forgiving about associative arrays with numeric keys. This is because lists can unintentially become associative arrays (as a result of side effect) and discarding the keys is not a problem. 2. Correct the spurious error message for truly associative arrays with non-numeric string keys. Bug: T322131 Change-Id: I870218023093305a8f414d4de1a73282b5f53b9a
* | | | | | | telemetry: Factor out context propagationChris Danis2025-01-102-8/+50
| |_|/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also condition using incoming span context upon $wgAllowExternalReqID Bug: T340552 Change-Id: Ib1cf361dd800c81a7943231441d58c790191ef5a
* | | | | | Merge "objectcache: Move internal StorageAwareness to ObjectCache namespace"jenkins-bot2025-01-091-12/+12
|\ \ \ \ \ \
| * | | | | | objectcache: Move internal StorageAwareness to ObjectCache namespaceTimo Tijhof2025-01-031-12/+12
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * The LightweightObjectStore namespace was experimentally adopted for two classes in 2020 with change Ia862c5111a3daf10a34fc78163301629, however in 2024 when we namespaced the BagOStuff component as a whole, we went with ObjectCache namespace in change Ie01962517e. * The StorageAwareness class is internal since I836735b1fec8dfd, so it can be freely renamed. * Similar to I836735b1fec8dfd, further reduce direct use of it, keeping it only as effectively an internal trait for adding a consistent set of constants to 3 classes (Bag, Wan, MemcClient). Bug: T353529 Bug: T364652 Change-Id: Ib10db39a91274e84a51a2eead94560b8d9137019
* | | | | | Merge "rdbms: Check for duplicate and conflicting fields in SelectQueryBuilder"jenkins-bot2025-01-091-2/+2
|\ \ \ \ \ \
| * | | | | | rdbms: Check for duplicate and conflicting fields in SelectQueryBuilderBartosz Dziewoński2025-01-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoids weird-looking queries when the same field(+alias) is provided twice, and throws an exception for potentially incorrect queries when the provided fields(+aliases) conflict. Change-Id: I03ba16fc3fce3f1468e518fb08dd65e705ca461f
* | | | | | | Merge "rdbms: Add more tests for adding SelectQueryBuilder fields"jenkins-bot2025-01-091-0/+24
|\| | | | | |
| * | | | | | rdbms: Add more tests for adding SelectQueryBuilder fieldsBartosz Dziewoński2025-01-071-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When you add the same field to the query builder more than once, weird things happen. Change-Id: I5cb51b262ec954624f531943ff011091102295ae
* | | | | | | Merge "filebackend: Remove dependencies on MediaWiki code"jenkins-bot2025-01-081-0/+4
|\ \ \ \ \ \ \