aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/skins
Commit message (Collapse)AuthorAgeFilesLines
* Namespace all remaining files in includes/skinJames D. Forrester2025-03-251-1/+1
| | | | | Bug: T353458 Change-Id: I3e829e35c93bcaae75e401b1801bddf93c0b416c
* Skin: Support responsive footer iconsJon Robson2025-02-081-0/+73
| | | | | | | | | | | | | | | This allows footer icons to declare different images at different media queries via the picture element e.g. $wgFooterIcons['poweredby']['mediawiki']['sources'] = [ [ "media" => "(max-width: 720px)", "srcset" => "https://en.wikipedia.org/static/images/mobile/mediawiki.png", ]; Bug: T384619 Change-Id: Ib325690906bc7fd9c0668cf2f77f0690d826d98e
* Skins: Pass icon data to link data for skinsJon Robson2024-11-041-0/+73
| | | | | | | | | | Make sure icons are passed to user-menu When viewing any page with ?useskin=json the items inside data-portlets data-user-menu always have icon = null because of a bug in the method. Add some much needed tests for this component. Change-Id: I727f7635f03481039f228764c048863b791281de
* tests: restore test for deprecated skin methodsAmmarpad2024-10-291-0/+12
| | | | | | | | We are not yet removing the methods, so the test should stay Bug: T377521 Follow-Up: I4c249acb1fcd0848428c99b8d3badebbc38b5dac Change-Id: Ic912559fde9c135561c2a0075637cebc873b1e25
* Hard deprecate soft deprecated skin methodsJon Robson2024-10-231-12/+2
| | | | | | Bug: T377521 Depends-On: I4f66ce9929e0240e1c89f59ef781d0a378263322 Change-Id: I4c249acb1fcd0848428c99b8d3badebbc38b5dac
* tests: Use namespaced classes (2)Umherirrender2024-06-131-0/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: I4ff4d0c10820dc2a3b8419b4115fadf81a76f7a2
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-161-1/+1
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Namespace Config-related classes under \MediaWiki\ConfigJames D. Forrester2023-09-211-0/+2
| | | | | Bug: T166010 Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
* Reorg: Move three output related classes to includes/Output/Amir Sarabadani2023-09-051-0/+1
| | | | | | | | | | And namesapce them: - StreamFile - OutputHandler - OutputPage Bug: T321882 Change-Id: Iedf8d88c595e580f2d8f0734c92aa5c45618ba33
* Skin: Use different single-id for edit/create and (un)watch links沈澄心2023-07-301-3/+1
| | | | | | | | | * Move the logic in Linker::updateWatchstarTooltipMessage() to SkinTemplate::getWatchLinkAttrs() and fix missing accesskey in tooltip. * Use different tooltips for "Edit", "Create", "Edit local description" and "Add local description" links. Bug: T341422 Bug: T341424 Change-Id: Ie79cac1e7ef5b2139cfa9c3f4ddf34555191cb0d
* skins: Widen `@covers` annotations in unit testsTimo Tijhof2023-07-242-10/+2
| | | | | | | | | | | | | | | | | | | | | | | Follows-up I7555c9b6b510, I6d845bdfbb80, I69b5385868, I4c7d826c7e, I1287f3979ab, which widened the `@covers` annotations of other suites: > We lose useful coverage and spend valuable time keeping these tags > accurate through refactors (or worse, forget to do so). > > I've audited each test to confirm it is a general test of the > subject class, where adding any called methods would be an accepted > change, thus widening it is merely a no-op that clarifies intent > and reduces maintenance. I am not disabling the "only track coverage > of specified subject" benefits, nor am I claiming coverage in > in classes outside the subject under test. > > Tracking tiny details per-method wastes time in keeping references > in sync during refactors, time to realize (and fix) when people > inevitably don't keep them in sync, time lost in finding uncovered > code to write tests for only to realize it was already covered but > not yet claimed, etc. Change-Id: I98d2ecc9870d893845c14e09b15fa19f4f258250
* Tests: add ObjectFactory to DummyServicesTraitDannyS7122023-01-231-12/+7
| | | | | | | | Mocks a ContainerInterface to support a specific list of services, with has() and get() working correctly, and uses that for a real ObjectFactory object. Change-Id: Ie49b5a34e0f449cc4b9f6b31d6cc1bc943d04b43
* Generate/set/get TOCData/SectionMetadata objects instead of arraysSubramanya Sastry2023-01-191-14/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ParserOutput::setSections()/::getSections() are expected to be deprecated. Uses in extensions and skins will need to be migrated in follow up patches once the new interface has stabilized. * In the skins code, the metadata is converted back to an array. Downstream skin TOC consumers will need to be migrated as well before we can remove the toLegacy() conversion. * Fixed SerializationTestTrait's validation method - Not sure if this is overkill but should handle all future complex objects we might stuff into the ParserCache. * This patch emits a backward-compatible Sections property in order to avoid changing the parser cache serialization format. T327439 has been filed to eventually use the JsonCodec support for object serialization, but for this initial patch it makes sense to avoid the need for a concurrent ParserCache format migration by using a backward-compatible serialization. * TOCData is nullable because the intent is that ParserOutput::setTOCData() is MW_MERGE_STRATEGY_WRITE_ONCE; that is, only the top-level fragment composing a page will set the TOCData. This will be enforced in the future via wfDeprecated() (T327429), but again our first patch is as backward-compatible as possible. Bug: T296025 Depends-On: I1b267d23cf49d147c5379b914531303744481b68 Co-Authored-By: C. Scott Ananian <cananian@wikimedia.org> Co-Authored-By: Subramanya Sastry <ssastry@wikimedia.org> Change-Id: I8329864535f0b1dd5f9163868a08d6cb1ffcb78f
* Fix whitespaces after commaUmherirrender2022-12-151-1/+1
| | | | Change-Id: Ide6de0a53661e6f650099d7b1f274a02699441df
* unit tests: Use MainConfigNames constant to refer configsUmherirrender2022-08-171-3/+4
| | | | | | | When creating ServiceOptions objects or fake HashConfigs use the constant to refer the config name Change-Id: I59a29f25b76e896c07e82156c6cc4494f98e64cc
* Remove poweredbyico SkinTemplate variable AND SkinGetPoweredBy hookMoh'd Khier Abualruz2022-06-281-84/+0
| | | | | | | | | | - poweredbyico removed - copyrightico removed - SkinGetPoweredBy, SkinGetPoweredByHook removed - Release Notes updated Bug: T306138 Change-Id: I6171b487e1ab0235b81a8a21a1decaf5cfdc4c1c
* Introduce SkinComponentSearchjdlrobson2022-03-311-0/+53
| | | | | | | | | | | | | | Changes: * Internal SkinTemplate::getSearchInputAttributes method is removed * Skin::makeSearchInput and Skin::makeSearchButton are hard deprecated. Methods moved to SkinTemplate to support skins using BaseTemplate (this avoids deprecation warnings in Timeless) * Correct the function signature for Skin::getRelevantTitle and the caller in Linker to take into account the use of getTitle and the possibility of a null return. Bug: T301723 Change-Id: I0906cd1582b93c741b93503562ec0fe37d80d948
* Use updated ObjectFactory namespaceAlexander Vorwerk2022-03-091-1/+1
| | | | | | | Depends-On: I99c5e5664d2401c36a9890f148eba7c25e6e8324 Depends-On: I48ab818b2965da14af15ef370aa83ad9455badd9 Depends-On: I018371e4b77911e56152ca7b2df734afc73f58a5 Change-Id: I04ebdb52102f6191d49a9cc70b1f98308299e72f
* skins: Fix non-replacing skippable state bug in SkinFactoryTimo Tijhof2022-03-011-3/+1
| | | | | | | As found via the test added with I3609cc71de48d3f5, which fails without this change, and is enabled now in this patch. Change-Id: Ie536644084b8a8b5386eb013cfd54621cfabc52d
* Merge "skins: Increase SkinFactory test coverage, improve various class docs"jenkins-bot2022-03-011-40/+33
|\
| * skins: Increase SkinFactory test coverage, improve various class docsTimo Tijhof2022-02-281-40/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Skin constructor docs were unreadable on doc.wm.o and in other places and IDEs that display docs due to lack of formatting (line are just whitespace in Markdown, same as HTML). * Make some of the method briefs (first line separated by new line) more useful, especially where this brief was missing and thus rendered unhelpful text like "Returns array of:" with no more. * Misc grammar and typo fixes, consistent phrasing, and other minor points from code conventions. Changed a few "fetch" to "get" in trivial methods. * Found a bug in SkinFactory::register() regarding skipskin handling, will fix in follow-up. * Found a bug in Skin::buildSidebar() regarding insufficient cache fragmentation. Will fix in a follow-up. Change-Id: I3609cc71de48d3f5c8404ea834d42c0cec5cba59
* | Remove unnecessary TestingAccessWrapper from SkinComponentTableOfContentsTestNicholas Ray2022-02-221-2/+1
| | | | | | | | | | | | | | This was an artifact left over from when we were testing private methods. Since we only test the public method now it can be removed. Change-Id: I1666c5a041e11c9ecc59a8a9cc3688e010dfae6b
* | Add `number-section-count` to data returned by SkinComponentTableOfContentsNicholas Ray2022-02-211-84/+80
|/ | | | | | | | | | | | | | | | | | The data returned by SkinComponentTableOfContents::getTemplateData is a nested array which makes it somewhat arduous for the client to know how many sections are in the array. Add `number-section-count` to make it easier on the client. Additionally: * Add validation in SkinMustacheTest for keys that contain numbers. * Revise unit tests to only test public method (`getTemplateData`) and not private methods. * Remove `testGetTOCData` test as these test cases will now be covered by the `testGetTemplateData` unit test. Bug: T300973 Change-Id: Ifaee451e1903f2accd0ada2f2ed6dfa3f83037b6
* Add template data to support TOC collapsible section arrows in Vectorbwang2022-02-181-4/+26
| | | | | Bug: T299361 Change-Id: I8ab5c0543b898d1df9399a1cb39672c45daf2acd
* Introduce SkinComponentTableOfContentsClare Ming2022-02-171-0/+166
| | | | | | | | | - Moves Skin::getSectionsData and related methods into new TOC component. - Update SkinMustacheTest for toc getTemplateData method. - Add test for new TOC component. Bug: T301523 Change-Id: I29dda96f1e91da6892840d38a80c6102d425d0f7
* Replace `new stdClass` with more compact array syntaxThiemo Kreuz2021-11-021-1/+1
| | | | | | | It does the exact same. The resulting object is still an stdClass instance. Change-Id: Ief68609943ee30aa95732d24021c921dfbad166c
* SkinFactory: Allow skins to be registered as "skippable"jdlrobson2021-10-041-6/+6
| | | | | | | | | | | | | The existing method of hardcoding ApiOutput and Fallback is not great, and there is a use case inside Vector as we split Vector skin into two as well as inside ContentTranslation. This adds to the existing wgSkipSkins configuration by allowing skins to register themselves as skippable without a LocalSettings change. Bug: T291193 Change-Id: I9caa8deb5b58fa1ef1eb548db497ef095cbbd154
* skins: Correctly index the copyright icon, caused failure in MFDerick Alangi2021-09-201-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On mobile and possibly desktop via (`$wgFooterIcons`), trying to acccess the copyright icon returns an array instead of a string. An exception is thrown since the indexing is done on a string. Throwing an error: TypeError: Return value of BaseTemplate::getCopyrightIconHTML() must be of the type string, array returned. The returned array looks like this (when I test): ["copyright"]=> array(1) { ["copyright"]=> array(3) { ["url"]=> string(47) "https://creativecommons.org/licenses/by-sa/4.0/" ["src"]=> string(44) "/core/resources/assets/licenses/cc-by-sa.png" ["alt"]=> string(39) "Creative Commons Attribution-ShareAlike" } } So getting the icon, we need to index src, hence the patch. Let me know if I'm wrong here. Also, have a look [[Manual:$wgFooterIcons]], you'll see that default value is an empty array instead of a string: $wgFooterIcons = [ "copyright" => [ "copyright" => [], ], ] This made MF to not be able to load locally and the patch fixes it. In addition, we can just pass `$config` as we have above rather than request the for it again and again. Bug: T291325 Change-Id: Icb42342e83f2bc61922ab991bcec66aa5e7b5646
* Deprecate Skin::getCopyrightIcon. Skin::getPoweredBy, SkinGetPoweredBy hookjdlrobson2021-09-141-0/+65
| | | | | | | | The skin methods serve BaseTemplate so are moved there. The associated hook is seldom used so deprecated. Bug: T290583 Change-Id: I166241fc88b98603f8d5489643eda984f49bad66
* build: Updating dependencieslibraryupgrader2021-07-221-1/+1
| | | | | | | | | | | | | | 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
* Tests: Mark more more closures as staticUmherirrender2021-02-091-4/+4
| | | | | | | Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
* Replace tabs with spacesMatěj Suchánek2020-09-041-1/+1
| | | | Change-Id: Id034c34a294585f58dba58c26db466e0e39cb557
* Remove usages of Skin::getAllowedSkins.Ammar Abdulhamid2020-08-051-3/+35
| | | | | | | | * Move the method to SkinFactory and replaces usages. * Inject $wgSkipSkins into the SkinFactory Bug: T257993 Change-Id: I9869cf34c5e87cbad963f48db0649b3b7a252a4a
* skins: Port SkinFallback and SkinApiOutput to a generic SkinMustache classjdlrobson2020-06-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new SkinMustache class is based on the emerging class in Vector. Having this in core, will allow Vector to make use of this class immediately and provide a minimal generic mechanism going forward for rendering skins using Mustache. For now, I've fleshed out the minimum possible data in getTemplateData which are based on existing functions in Vector. The Skin class now takes a generic options parameter which allows registration of a skin using the SkinMustache class with a templateDirectory option pointing to the associated template. A `styles` option can be passed to define stylesheets that should be associated with the skin. The SkinApi and SkinFallback classes are reduced significantly. There are no known uses of SkinApiTemplate and it is thus removed. SkinFallbackTemplate is removed and its functions copied across to SkinFallback End user changes: * The fallback skin no longer prints the confusing warning message if the default skin is setup incorrectly. Previously viewing the fallback skin with useskin indicated that wgDefaultSkin was not set correctly which was misleading and confusing. * Factory functions now receive skin options as a second parameter and the service as a first - this is due to how ObjectFactory handles the extraArgs key for 'factory' key - placing it at the beginning. Bug: T254048 Change-Id: Ibbabd1d0f26efebf8f8ff068966685dc2191c527
* Support the creation of Skins with services injectedmainframe982020-03-161-20/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | The old way of providing a callable to SkinFactory::register is still supported. Those callables expected the skin name as their first argument. Coincidentally, so does the constructor of Skin. Some skins might not define any constructor parameters at all, which is acceptable to PHP, as it will just discard the argument. The registration using $wgValidSkinNames has not been changed, and skins that want to define services to be injected will still need to manually register their skin to the skin factory. CodeSearch did not indicate any extensions or skins manually constructing a SkinFactory in tests, but for posterity, the old way of creating a SkinFactory for testing can be replaced with new SkinFactory( new ObjectFactory( $this->createMock( ContainerInterface::class ) ) ); Note that the constructor for SkinFactory for internal use only, in accordance with the Stable interface policy. You should use MediaWikiServices::getInstance()->getSkinFactory instead. Bug: T244466 Change-Id: I8ba9d869bddd9b6124e47697b789d752c0620b02
* Cleanup of old PHPUnit usage, part 3Max Semenik2019-10-051-3/+3
| | | | | | Bug: T192167 Bug: T234597 Change-Id: I88a1ced51d7b57bc683de4a58bbeaa1537762113
* Move trivially compatible tests to the unit tests suiteMáté Szabó2019-06-301-0/+82
| | | | | | | | | | | | | | | | | | | | | This changeset resumes work on T89432 and related tickets by porting an initial set of tests to the new unit test suite separated out in I69b92db3e70093570e05cc0a64c7780a278b321a. The tests were only ported if they worked immediately without requiring any changes other than changing the test case class to MediaWikiUnitTestCase and moving the test to the new suite. If a test failed for any reason (even trivial misconfiguration), it was NOT ported. With this change, the unit tests suite now consits of a total of 455 tests. As before, you can run these tests via the following command: $ composer phpunit:unit Bug: T84948 Bug: T89432 Bug: T87781 Change-Id: Ibb8175981092d7f41864e641cc3c118af70a5c76
* Revert "Separate MediaWiki unit and integration tests"Legoktm2019-06-133-207/+0
| | | | | | | | This reverts commit 0a2b996278e57a8b8c5377cd3a3eaa54f993d4a9. Reason for revert: Broke postgres tests. Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
* Separate MediaWiki unit and integration testsMáté Szabó2019-06-133-0/+207
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