aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/structure
Commit message (Collapse)AuthorAgeFilesLines
* Namespace all remaining files in includes/exceptionJames D. Forrester2025-03-251-0/+1
| | | | | | | | | In MediaWiki/Exception, to follow PSR-4 per plural vs. singular (this can be changed later if people really care). Also, move the couple of exceptions in here that were already namespaced in the MW-top-level into the new space. Bug: T353458 Change-Id: I12ed850ae99effb699a6d7ada173f54e72f0570e
* Merge "REST: Make OpenAPI spec info strings translatable"jenkins-bot2025-03-241-2/+6
|\
| * REST: Make OpenAPI spec info strings translatablebpirkle2025-03-211-2/+6
| | | | | | | | | | | | | | | | | | OpenAPI specs include an "info" section that includes strings such as "title" and "description" that are intended to be human-readable. Make all such strings translatable. Bug: T385855 Change-Id: I15285be6d196c0e7fd7e922f23058d7c09b6b31a
* | tests: Report all missing messages on failure in SkinsTestUmherirrender2025-03-201-3/+7
|/ | | | | | | | | | The assert function stops on first missing message and does not report all missing messages in one go. Make the data provider named with the skin name for better output. This also speed up the tests by reducing assertions. Change-Id: I857f39e61096315b7344dff08ebf6ba6cdc15c19
* Merge "tests: space out Performance budget warning"jenkins-bot2025-03-111-6/+7
|\
| * tests: space out Performance budget warningAntoine Musso2025-03-111-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I found the concatenated sentences to not be standing out and a little bit hard to read. Add the warning triangle emoji and add extra newlines to space out paragraphs. Example output: 1) PerformanceBudgetTest::testTotalModulesSize ⚠️ PLEASE DO NOT SKIP THIS TEST ⚠️ If this is blocking a merge this might signal a potential performance regression with the desktop site. All extensions/skins adding code to page load for an article must monitor their ResourceLoader modules. Read https://www.mediawiki.org/wiki/Performance_budgeting for guidance on how to suppress this error message. The following modules have not declared budgets: ext.socialprofile.responsive ext.socialprofile.whatever Change-Id: I0c4b6e0b3e47be6ab24d8d024f0c9bf49ab4ba01
* | tests: Streamline a few overcomplicated if-else in test codethiemowmde2025-03-111-9/+1
|/ | | | | | | | I believe the code is quite a bit more readable like this. There is less indirection and less duplication. The tests still do the same as before. Change-Id: I501ccee89b37e2338bc07af3024a75f0e45e05b3
* test(ApiStructureTest): use a fresh ApiMain instance for each testMichael Große2025-03-071-30/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | The ApiBase module retains the hookRunner and hookContainer in class fields, which in turn store created hook handlers in class fields. Further, the service container will be destroyed after each test in the \MediaWikiIntegrationTestCase::mediaWikiTearDown. However, that means if these hook handler have anywhere a reference to the service container, for example because they get an Object Factory injected as it is the case with the TaskTypeHandlerRegistry class, then that service container will be destroyed on subsequent test-runs. This is a problem if in a subsequent test-run that ObjectFactory is used to create something that expects to get a service injected. Hence the error observed in T380585. This is fixed in this change by creating a new instance of ApiMain for running the actual test and thus creating all the services fresh from the new service container for each test. At least from my local testing, this does not seem to be noticeably slower than reusing the same object over and over again. Bug: T380585 Change-Id: I3af04966b58c9ed3c7653f8c5c399135aa2ff341
* Tests: Ensure that skins only use messages that existJon Robson2025-02-281-0/+38
| | | | | | Depends-On: I1b1c776865a1cdef926606ae2c7080ed2a8dcebd Depends-On: I5f25693642f0c778bccec2763f093c8daaef4d32 Change-Id: Iea9563b976e851ec5c6fd01c74bbcb6ef936e2fe
* ResourceLoader: Restore data provider names in testRespond()Timo Tijhof2025-02-181-1/+1
| | | | | | | | | | | | | | | Follows-up I804bda0590 (2dc2af1d289), after which information from test failures or slow tests in WMF CI became unactionable with output such as: ``` 1045ms to run ResourcesTest::testRespond with data set #369 1016ms to run ResourcesTest::testRespond with data set #120 663ms to run ResourcesTest::testRespond with data set #623 ``` Bug: T348676 Change-Id: If4eb83e8b4e10fa1bc42d621cf0e4287b4c88539
* PerformanceBudgetTest: Support testing uncompressed as well as compressedJon Robson2025-01-302-16/+41
| | | | | | | | | | | | | | | | | | | Per discussion with Timo and Gergő, monitoring uncompressed size should also be monitored as reducing actual code size and running less code tends to be more impactful to end users then gzip size e.g. compression/stronger minifier. Changes to performance budget: * prints uncompressed as well as compressed * This also moves the markSkipped to the main test so that the amount of kB of scripts is also printed to the report. Changes to BundleSizeBase: * Tests can now add maxSizeUncompressed. If defined it will be used instead of maxSize to support testing uncompressed bundles. Bug: T360590 Change-Id: I690f3872f96207936dbaeba77646fe3df2f75273
* Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-173-6/+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
* Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-161-3/+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
* Tests: Remove hardcoded exclusion list from PerformanceBudgetTestJon Robson2025-01-091-26/+0
| | | | | | Depends-On: I1f47161b3e2c5116a7a1622bed41fba0c44c5f07 Bug: T360590 Change-Id: Ia4acca48cb231cc24f685e373aac1292082dd2cf
* tests: Add WikimediaEvents modules to bundlesize exclusionsLucas Werkmeister2025-01-081-1/+2
| | | | | | | | | | | | | | | | Same as change Ib39a6fd4cb (commit 49d17d73c9): I don’t know why this was left out of the initial hard-coded list, but it’s breaking CI for several extensions (not just WikimediaEvents but also at least Wikibase and EntitySchema), hence add it to unbreak those. A proper fix is available in WikimediaEvents change If60ec1f895, but as it’s been open for 3½ months I don’t feel comfortable just merging it. Instead, add the modules to the hard-coded list for now; MediaWiki core change Ia4acca48cb, which cleans up the hard-coded list, already depends on the WikimediaEvents change anyway. Bug: T360590 Bug: T383221 Change-Id: I2f1996c4e931bcac47e2aab71c1876e8c9e4cde7
* tests: Add ext.wikimediaBadges to bundlesize exclusionsLucas Werkmeister2025-01-081-0/+2
| | | | | | | | | | | I don’t know why this was left out of change Ie8b524240b (commit 88ffcfa634), but it’s breaking tests in other extensions (seen in EntitySchema change Ifb64018bea), and the “real” fix Ic3b24348be is not yet mergeable because of its Depends-On, so add the module to the core exclude list for now to unbreak CI. Bug: T360590 Change-Id: Ib39a6fd4cb8230700a39004cf77f9e4ebc1b11e6
* Tests: Enforce requirement that modules loaded on page load are documentedJon Robson2025-01-072-1/+83
| | | | | | | | | | | | | | | | | | | | | | | | | This provides a second iteration of a recently removed test in Vector, that we removed in I0eb22ebbed67ded008de7ca75f9f8f399a214ef8 * The new test only fails if it detects modules on page load that haven't got associated budgets ie. are unexpected and new - this catches the issue we've had with OOUI being accidentally added to page load. * All budgets are defined in the associated extensions - we defer to maintainers of those extensions to monitor and consider bundle size increases to these modules rather than police it in Vector. * We do not check the size of modules that are tied to wiki pages e.g. site or site.styles - to support this bundlesizes can be defined as null to skip testing The downsides of this approach are: * we are not monitoring overall size and trusting each other to be cautious when we add new dependencies. * we are altering the meaning of bundlesize.config.json to assume that only modules added on page load are declared there, which is not always the case. Bug: T360590 Depends-On: I02e096065432187d3fbb66656946ca52922ce01d Change-Id: Ie8b524240b8eba53a24f5272e44b69a20b0ffba9
* Merge "tests: Disallow unchecked exceptions in SpecialPageFatalTest"jenkins-bot2025-01-021-9/+2
|\
| * tests: Disallow unchecked exceptions in SpecialPageFatalTestDaimona Eaytoy2024-11-191-9/+2
| | | | | | | | | | | | | | | | Uploading this for discussion as I might have missed something. See full proposal on phab. Bug: T380323 Change-Id: Ib7812ab225f186f7129a3ef55de2442b1a5212db
* | Merge "test: Introduce AbstractSchemaTestBase"jenkins-bot2024-12-172-137/+183
|\ \
| * | test: Introduce AbstractSchemaTestBaseDaimona Eaytoy2024-12-142-137/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extensions can extend it to run structure tests on their database schema and schema changes, just like core. In the future, this might be run as part of extension.json tests, when T237839 is completed. Bug: T381981 Change-Id: I8ae59ce6854922c2804d12986c870d3f0e0c3299
* | | Merge "tests: Add structure test for content of abstract schema changes"jenkins-bot2024-12-173-92/+176
|\| |
| * | tests: Add structure test for content of abstract schema changesDaimona Eaytoy2024-12-143-92/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Rename AbstractSchemaValidationTest to AbstractSchemaTest, as we're no longer testing validation only. - Namespace the test and make it extend MediaWikiIntegrationTestCase. - Check that the autogenerated content from each JSON file matches what's in the source tree. For the main schema file, this was done in DatabaseIntegrationTest, so remove it from there. - Whitespace differences are ignored to make future changes easier. - Use separate methods for testing the main schema and schema changes. - Add static methods to provide the SQL paths. The plan is to move this logic to an abstract class, where these will be abstract methods. Bug: T381981 Change-Id: I23bc92da73a5969bb7eb79f2598120d6aa4c41ac
* | | Merge "Tests: Monitor total bundle size of article views"jenkins-bot2024-12-172-0/+136
|\ \ \ | |/ / |/| |
| * | Tests: Monitor total bundle size of article viewsJon Robson2024-12-112-0/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new test tracks combined bundle sizes for article views. It is currently non-blocking and for now prints to the output because of limitations with CI. We are exploring options for making this more visible. This also allows extensions/skins to opt-out of bundle checks by adding a bundlesize.config.json where modules are declared as having null bundle size. Bug: T360590 Change-Id: I67ff5393f8fb5d4e8da58cb2ffbc58207abac2cd
* | | Move SQL schema and schema changes to new sql/ top-level directoryDaimona Eaytoy2024-12-132-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the standard in every extension. DB schema changes are not maintenance scripts, and therefore there's no apparent reason to have the two things together, besides historical reasons. Also, put each DB type in a separate directory, which wasn't the case for MySQL before. For SQLite and Postgres schema changes, we now follow the convention (used everywhere else, including the generateSchemaChangeSql script) of having the DB type as the last part of the path. This lets us generate schema changes for all DB types at once, and without specifying the full file path. Most files are just being renamed, the exceptions being to update references to the old location (sometimes still referencing tables.sql). Note that the old path is still referenced in the autogenerated comment of schema changes SQL files. These will be regenerated in another commit. Instead, the schema files are done now, because they're covered by DatabaseIntegrationTest that would otherwise fail. Bug: T382030 Change-Id: I3b4a614366d0bc629523ac40ce97d001f3b6bcf8
* | | db: Drop AbstractSchemaValidator::$missingDepCallbackDaimona Eaytoy2024-12-111-2/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For starters, the property is really only used by checkDependencies(), which in turn is only called by AbstractSchemaValidationTest. Everywhere else, all this code was a no-op. But for PHPUnit tests, we must not tolerate missing composer dependencies. In fact, our PHPUnit bootstrap even runs the CheckComposerLockUpToDate script and exits immediately if dependencies are not up-to-date, let alone missing. Instead, move the dependency checks to the constructor, so that they're always executed, and throw an exception when they fail, instead of relying on the callback. In practice: - For PHPUnit tests there's no real difference thanks to the composer.lock check mentioned above. - For maintenance scripts, when dependencies are not available, we now fail with a useful exception, instead of a generic "Class X does not exist" message. Bug: T381981 Change-Id: I893dc6a52262f8a63fce3ec5eecdd91dd9f339a5
* | REST: Make structure test for param description messagesdaniel2024-11-261-0/+11
| | | | | | | | | | | | | | | | Adds an assertion to check that the message keys used in parameter descriptions are defines. Bug: T376493 Change-Id: I789a5c2b95a5647a4e8d484c4b069d810478dd6f
* | extension.json spec: allow DomainEventSubscribersdaniel2024-11-221-2/+2
| | | | | | | | | | | | | | | | | | | | This adds DomainEventSubscribers to the JSON schema for extension.json, and fixes the EventSubscription structure test. Bug: T378931 Followup-To: I38ef080c17842790c609c022b31acfa0ebd3c103 Needed-By: I020038da7c02d6c62071cdb3b572a527cee8fbd2 Change-Id: I34c7aca80cfa96306e2c350a5f9bc723713b98c3
* | DomainEventDispatcher: specify subscribers in extension.jsondaniel2024-11-201-0/+76
|/ | | | | | | | Use subscriber objects in extension.json instead of registering listeners directly. Bug: T378931 Change-Id: I38ef080c17842790c609c022b31acfa0ebd3c103
* composer.json: Updated nikic/php-parser from ^4.10.2 to ^5.3.1Reedy2024-11-111-1/+3
| | | | | | Bug: T379508 Change-Id: Ia693d5e3424d925172cd2e4b7cb501a031822f3b Depends-On: Iec814da22ff34810077876d3ee0ad0264cfc54a9
* Merge "Add DumpableObjectsTest to the database test group"jenkins-bot2024-11-081-0/+1
|\
| * Add DumpableObjectsTest to the database test groupBrent Laabs2024-10-241-0/+1
| | | | | | | | | | Bug: T374494 Change-Id: I4a33d3ff43e2e31c77377fb9880a31b25ab39268
* | Drop BundleTestSize aliasDaimona Eaytoy2024-10-311-3/+0
| | | | | | | | | | | | | | | | | | | | | | Deprecated in 1.42 and unused: https://codesearch.wmcloud.org/search/?q=BundleSizeTest%5Cb The name is now used by core's BundleTestSize class. Follow-up to If4a162f3a16e95d0fb7dae902c9b795c9f743ef0. Depends-On: I7c586457e0c368c853566c1e0a5adaceeefc171d Change-Id: I1dbea58ce2f80cf956ac28e1106f008010a2b478
* | Tests: Monitor bundlesizes for core modules in coreJon Robson2024-10-301-0/+11
| | | | | | | | | | | | | | | | | | It does not make sense to monitor these in Vector as the code associated is defined in core and we don't want to block core changes on Vector changes. Bug: T378635 Change-Id: If4a162f3a16e95d0fb7dae902c9b795c9f743ef0
* | ResourceLoader: Simplify DependencyStoreHannah Okwelum2024-10-241-2/+2
|/ | | | | Bug: T343492 Change-Id: Ia581ac107cb139afb0740a36f4f22f047d0de1ad
* tests: Use namespaced classesUmherirrender2024-10-214-0/+10
| | | | | | | | 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
* Merge "tests: Validate Resources.php against ResourceModules schema"jenkins-bot2024-10-141-0/+25
|\
| * tests: Validate Resources.php against ResourceModules schemaBartosz Dziewoński2024-10-071-0/+25
| | | | | | | | Change-Id: I189f5d48e92fa77d15116b2acbcb783f02b522c1
* | tests: Mock IContextSource in RestStructureTestUmherirrender2024-10-111-5/+16
|/ | | | | | | | This avoids creation of session leaking into other tests Also avoids that the session backend stores the session and consuming memory until the end of the tests Change-Id: Ib7a0a5df0f16bb25a6111a4a3f7cfadc489e7e25
* tests: Consistently use class_alias comments like elsewhereJames D. Forrester2024-09-251-1/+1
| | | | | | Found via `[^*][^\\]\nclass_alias`. Change-Id: I9732f75226445f48fb131c432b209d0fd3eba1ba
* REST: Introduce discovery endpointdaniel2024-09-201-11/+50
| | | | | | | | The discovery endpoint provides basic information about accessing the wiki's APIs, as well as a directory of available modules. Bug: T365753 Change-Id: I161aa68566da91867b650e13c8aadc87cd0c428c
* REST: validate JSON in testsdaniel2024-09-201-22/+25
| | | | | | | | | | | | | | | | | | This applies JSON Schema validation in phpunit tests where appropriate: 1) In ModuleSpecHandlerTest, the generated OpenApi specs are validated against the OpenAPI 3 schema. 2) In RestStructureTest, module definition files are validated against the mwapi schema. This patch introduces a new trait to make it easy for phpunit test cases to perform validation. This patch also fixes some issues with the docs/rest/mwapi-1.0.json schema and the includes/Rest/content.v1.json module definition. Change-Id: I966cddb337c9373ed3a369496548a8d8c538ae84
* Fix specifying messages with params as arrays in API documentationBartosz Dziewoński2024-08-211-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Follow-up to 12a4c08ad83ef55e440b88e5f9d511fd224afa6f. I didn't review it carefully enough to notice that when these functions return arrays, they contain a message key and parameters, not a key and fallback keys (while other API documentation message code uses fallback keys). Instead of `$this->msg( $msg )`, this code must be written as `is_array( $msg ) ? $this->msg( ...$msg ) : $this->msg( $msg )` or `$this->msg( Message::newFromSpecifier( $msg ) )`, both of which are ugly, but the latter looks a bit better to me. Bonus changes: * Add documentation to prevent a repeat of this mistake in the future * Remove some unreachable dieDebug() calls (the Message class already throws for bad inputs) It seems that we don't have any definitions using such arrays in the core API classes. There are only a few uses in extensions, e.g. AbuseFilter's 'apihelp-query+abuselog-param-filter' message, which is passed the wrong parameter without this change. Bug: T372988 Change-Id: I44c1c3c7d0c069e500c85a58c27e9b675b0b68ee
* Merge "Deprecate ApiBase::makeMessage"jenkins-bot2024-08-161-1/+1
|\
| * Deprecate ApiBase::makeMessagetheprotonade2024-08-161-1/+1
| | | | | | | | | | | | | | | | | | Replace usages of ApiBase::makeMessage with ApiBase::msg and deprecate the former method Bug: T370240 Change-Id: I9e6e775dad7f3e3cfd78351f87f4732677d90971
* | tests: Add a test for Codex i18n messagesEric Gardner2024-08-121-0/+24
| | | | | | | | | | | | | | | | | | | | | | Adds a new "structure" PHPUnit test, "CodexMessageDefinitionTest.php". This test exists to ensure that every message in the Codex message keys file (produced by the library during build and updated for each Codex release) is defined in the en.json and qqq.json message files for Codex in MediaWiki. Bug: T371330 Change-Id: I01f0888d13122d587bef17043eec46c32e8f534e
* | Add MediaWiki\Registration namespace to registration classesEbrahim Byagowi2024-08-102-1/+5
| | | | | | | | | | Bug: T353458 Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
* | Use MediaWikiIntegrationTestCase::getConfVar in testsFomafix2024-08-063-3/+3
|/ | | | Change-Id: I3a99f24da3d572281b49a8a8b92e006fde3eaa41
* getParamSettings prohibited from using array typeWendy Quarshie2024-07-251-0/+5
| | | | | Bug: T368133 Change-Id: I2af5880fdf4d6fb3f8047e24e3a3d69a08a433f7