aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/diff
Commit message (Collapse)AuthorAgeFilesLines
* tests: Use namespaced classesUmherirrender2024-10-214-0/+6
| | | | | | | | 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
* Add missing documentation to class properties (frontend-related)Umherirrender2024-09-051-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: Id75cb2e5fbee0fe7600f92473d876f23730d46b7
* Add namespace to WikitextContentEbrahim Byagowi2024-08-061-0/+1
| | | | | | | It adds MediaWiki\Content namespace to WikitextContent and two classes related. Change-Id: Ib74e4c5b3edac6aa0e35d3b2093ce1d0b794cb6d
* diff: migrate TextSlotDiffRenderer to use StatsFactoryCole White2024-06-281-1/+2
| | | | | Bug: T359241 Change-Id: I4f443b004b9ed77b9e6b8b1144d0cc2847a55d16
* Add namespace and deprecation alias to JsonContentEbrahim Byagowi2024-05-201-0/+1
| | | | | | | | | This patch introduces a namespace declaration for the MediaWiki\Content to JsonContent and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I44abb1ab5bd1fabf9886dc1457e241d7cae068bc
* Add namespace and deprecation alias to TextContentEbrahim Byagowi2024-05-192-1/+3
| | | | | | | | | This patch introduces a namespace declaration for the MediaWiki\Content to TextContent and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: Ic251b1ddfcf6db9c85cb54cddf912aa827d2bc3a
* Add namespace and deprecation alias to CssContentEbrahim Byagowi2024-05-181-0/+1
| | | | | | | | | This patch introduces a namespace declaration for the MediaWiki\Content to CssContent and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I6ab25787893cb2195f8cd2ba125ed8dd5a60de43
* Fix ExternalTextDifferTest on macOSMáté Szabó2024-05-041-2/+2
| | | | | | | | | | | In POSIX sh, `echo` flags are undefined. On macOS, this causes the expected output to include literal `-n`s instead of the expected behavior of not printing trailing newlines. So, use `printf` instead, which should work consistently on both macOS and Linux. Follows-up I5c506e3916285. Change-Id: I54fc42d8fb8156fcf1d623ef4a7515092e634f09
* Make DifferenceEngineTest run standaloneArthur Taylor2024-04-301-0/+1
| | | | | | | | | | | When running in a CI / Quibble context, this test class was failing - it relies on other classes in the suite already having initialised OOUI. Explicitly enable OOUI in this test to avoid the failure mode. Bug: T363797 Change-Id: I63c65d32b32f6e47b2b1900e819b58b9bbfe30c3
* Fix some spelling errorsTim Starling2024-03-181-2/+2
| | | | Change-Id: I3632ce1ae00527f806652deb96cafb473aed3dcf
* Fix weird (auto-generated?) namespaces in PHPUnit teststhiemowmde2024-02-201-1/+1
| | | | | | Same as I710a077. Change-Id: I2b8eaf060229da3e0b5035fc43e38d610d554535
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-164-4/+4
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Namespace includes/contextJames D. Forrester2024-02-085-0/+6
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* tests: Use namespaced classesUmherirrender2023-12-111-0/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statements and changes to docs done manually Change-Id: Ib326ae1e5c8409a98398c721e8b8ce42c73bd012
* parser: Move lang/dir and mw-content-ltr to ParserOutput::getTextTimo Tijhof2023-11-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | == Skin::wrapHTML == Skin::wrapHTML no longer has to perform any guessing of the ParserOutput language. Nor does it have to special wiki pages vs special pages in this regard. Yay, code removal. == ImagePage == On URLs like /wiki/File:Example.jpg, the main output handler is ImagePage::view. This calls the parent Article::view to handle most of its output. Article::view obtains the ParserOptions, and then fetches ParserOutput, and then adds `<div class=mw-parser-output>` and its metadata to OutputPage. Before this change, ImagePage::view was creating a wrapper based on "predicting" what language the ParserOutput will contain. It couldn't call the new OutputPage::getContentLanguage or some equivalent as Article::view wouldn't have populated that yet. This leaky abstraction is fixed by this change as now the `<div>` from ParserOutput no longer comes with a "please wrap it properly" contract that Article subclasses couldn't possibly implement correctly (it coudln't wrap it after the fact because Article::view writes to OutputPage directly). RECENT (T310445): A special case was recently added for file pages about translated SVGs. For those, we decide which language to use for the "fullMedia" thumb atop the page. This was recently changed as part of T310445 from a hardcoded $wgLanguageCode (site content lang) to new problematic Title::getPageViewLanguage, which tries to guestimate the page language of the rendered ParserOutput and then gets the preferred variant for the current user. The motivation for this was to support language variants but used Title::getPageViewLanguage as a kitchen sink to achieve that minor side-effect. The only part of this now-deprecated method that we actually need is LanguageConverter::getPreferredVariant(). Test plan: Covered by ImagePageTest. == Skin mainpage-title == RECENT (T331095, T298715): A special case was added to Skin::getTemplateData that powers the mainpage-title interface message feature. This is empty by default, but when created via MediaWiki:mainpage-title allows interface admins to replace the H1 with a custom and localised page heading. A few months ago, in Ifc9f0a7174, Title::getPageViewLanguage was applied here to support language variants. Replace with the same fix as for ImagePage. Revert back to Message::inContentLanguage() but refactor to inLanguage() via MediaWikiServices::getContentLanguage so that LanguageConverter::getPreferredVariant can be applied. == EditPage == This was doing similar "predicting" of the ParserOutput language to create an empty preview placeholder for use by preview.js. Now that ApiParse (via ParserOutput::getText) returns a usable element without any secret "you magically know the right class, lang, and dir" contract, this placeholder is no longer needed. Test Plan: * EditPage: Default preview 1. index.php?title=Main_Page&action=edit 2. Show preview 3. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr> * EditPage: JS preview 1. Preferences > Editing > Show preview without reload 2. index.php?title=Main_Page&action=edit 3. Show preview 4. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr> 5. Type something and 'Show preview' again 6. Assert old element gone, new text is shown, and new element attributes are the same as the above. == McrUndoAction == Same as EditPage basically, but without the JS preview use case. == DifferenceEngine == Test: 1. Open /w/index.php?title=Main_Page&diff=0 (this shows the latest diff, can do manually by viewing /wiki/Main_Page, click "View history", click "Compare selected revisions") 2. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr> 3. Open /w/index.php?title=Main_Page&diff=0&action=render 4. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr> == Special:ExpandTemplates == Test: 1. /wiki/Special:ExpandTemplates 2. Write "Hello". 3. "OK" 4. Assert <div class="mw-content-ltr mw-parser-output" lang=en dir=ltr> Bug: T341244 Depends-On: Icd9c079f5896ee83d86b9c2699636dc81d25a14c Depends-On: I4e7484b3b94f1cb6062e7cef9f20626b650bb4b1 Depends-On: I90b88f3b3a3bbeba4f48d118f92f54864997e105 Change-Id: Ib130a055e46764544af0f1a46d2bc2b3a7ee85b7
* diffs: add line number headings to inline diffsMusikAnimal2023-10-091-2/+8
| | | | | | | | | | | | | | Adds new regex in BaseTextDiffer::localizeLineNumbers() to work with wikidiff2 inline diffs as well as table diffs. Since there are no "columns" in inline mode, we have a new message to indicate how the line numbers changed from the old diff versus the new. Deprecate DifferenceEngine::localiseLineNumbers() as no longer used and redundant to BaseTextDiffer::localizeLineNumbers(). Bug: T346460 Change-Id: I7b195879b677e2242ad73070fe19ad82121576a8
* Make use of assertStatusGood/Error and such in teststhiemowmde2023-10-041-2/+2
| | | | Change-Id: I11eace3d9823ca28a1d9a64f959f5f8ca2945821
* Namespace Config-related classes under \MediaWiki\ConfigJames D. Forrester2023-09-211-0/+1
| | | | | Bug: T166010 Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
* DiffToggleSwitch: remove temporary inline switch flagTheresNoTime2023-09-061-2/+0
| | | | | | | | Remove `$wgShowDiffToggleSwitch`, ensure the inline switcher is always shown. Bug: T341630 Change-Id: I37d1abe0d9773654df24dd8316cd1b351e3b91a4
* Reorg: Move three output related classes to includes/Output/Amir Sarabadani2023-09-052-0/+3
| | | | | | | | | | And namesapce them: - StreamFile - OutputHandler - OutputPage Bug: T321882 Change-Id: Iedf8d88c595e580f2d8f0734c92aa5c45618ba33
* Include $wgWikidiff2Options in the diff cache keyTim Starling2023-08-231-1/+2
| | | | | Bug: T341754 Change-Id: I3b7d71f811d7ebd0cf83273164c479762e1a680b
* Merge "Add support for wikidiff2_multi_format_diff()"jenkins-bot2023-07-312-6/+19
|\
| * Add support for wikidiff2_multi_format_diff()Tim Starling2023-07-192-6/+19
| | | | | | | | | | Bug: T341754 Change-Id: I17396985d0b26516a06df17e9bd1343054521e01
* | Don't show the inline toggle selector on Special:MobileDiffTim Starling2023-07-261-0/+1
| | | | | | | | | | | | | | | | | | Have Article opt in to inline toggle switch display, so that random callers of DifferenceEngine::showDiffPage() do not receive a non-functional format selector. Bug: T342158 Change-Id: Id4e38c2a20b5381e5f70b1244304da2895eaf8e7
* | tests: Skip ManifoldTextDifferTest on windowsUmherirrender2023-07-221-0/+6
| | | | | | | | | | | | | | | | Fails with a 1) ManifoldTextDifferTest::testHasFormatExternal ExternalDiffEngine config points to a non-executable Change-Id: Ifb32694f2c1cef32a354e20636463a22b7ab5f6f
* | Add SlotDiffRenderer::localizeDiff()Tim Starling2023-07-201-0/+9
|/ | | | | | | | | | | | | | | | | It makes sense for SlotDiffRenderer to localize the diffs that it returns. DifferenceEngine can't conveniently use this right now since it stores all slot diffs concatenated together in a cache entry. It can't break the string apart again to call the right SlotDiffRenderer on each slot diff. So it assumes there must be a text diff in there somewhere and calls TextDiffer over the whole thing. EntitySchema does not have this problem and can benefit from this method. Bug: T342209 Change-Id: Ie06e100bb0e945de5dbe3dade14b2e6b706e078d
* Add unified formatTim Starling2023-07-193-5/+20
| | | | | | The code is there, so we may as well expose it. Change-Id: Ic4cf5c0d4a5b46f0f0f25454815dcea1f69970eb
* Factor out TextDiffer hierarchy from TextSlotDiffRendererTim Starling2023-07-198-36/+499
| | | | | | | | | | | | | | | | | | | | | | | | | * Follow the TODO comment in TextSlotDiffRenderer ::getTextDiffInternal() by moving the code out to three parallel implementations, namely ExternalTextDiffer, PhpTextDiffer and Wikidiff2TextDiffer. * Add a container/factory class ManifoldTextDiffer to glue them together and collate available formats. * Move the inline legend to Wikidiff2TextDiffer. Not the toggle since the ability to toggle depends on the available format, not the current format. * Update the diff cache keys so that ManifoldTextDiffer can store the engine=>format map it used to generate the diff. * Drop support for the second parameter to TextSlotDiffRenderer ::setEngine(), since nothing used it anymore. * Provide a format batch API, since some engines are able to efficiently generate multiple formats. This might be used by DifferenceEngine in future. Needs risky change notification for the cache key change. Bug: T339184 Depends-On: I8a35b9b8ec1622c9a36d2496bdd24f51bc52c85f Change-Id: I5c506e39162855aff53dd420dd8145156739059c
* Merge "Add a test for DifferenceEngine::showDiffPage"jenkins-bot2023-06-271-18/+245
|\
| * Add a test for DifferenceEngine::showDiffPageTim Starling2023-06-271-18/+245
| | | | | | | | | | | | | | An integration test that checks for a regex match on the HTML output. Achieves 92% coverage of showDiffPage. Change-Id: I3b2af33257f2326b67ff6f0734aeff0da3b69f43
* | Switch back to oo-ui-element-hidden from mw-diff-element-hiddenSam Wilson2023-06-261-1/+1
|/ | | | | | | | | Using the OOUI class name is an established pattern outside of OOUI widgets, so it's easier to stick with it for the diff page hiding and showing (switching to and from inline/table diffs, etc.). Bug: T324759 Change-Id: I805b6b71d8e137eaa3e000b15455557df42af838
* Merge "diff: Move SlotDiffRenderer::getTablePrefix() parts assembly up to ↵jenkins-bot2023-06-261-0/+57
|\ | | | | | | DifferenceEngine"
| * diff: Move SlotDiffRenderer::getTablePrefix() parts assembly up to ↵Tim Starling2023-06-261-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DifferenceEngine getTablePrefix() is used to show the inline legend and inline switcher. It is not yet part of a released stable interface. Theoretically there may be multiple text slots on a page, and we don't want multiple inline legends. There was already a fragment assembly system, for the benefit of hook handlers, so move that up to the page level, so that it can also deduplicate prefix fragments coming from each slot. Add tests. Bug: T324759 Change-Id: I9baa5c24128c63bc318ba13e83a024843f4ab15e
* | Improve handling of diffs between incompatible content modelsGergő Tisza2023-06-233-9/+42
|/ | | | | | | | | When the old and new content object for a slot cannot be compared, show an error message for that slot only, instead of throwing an exception. Bug: T214217 Change-Id: I6e982df358f85ca78f0448b3a93ded3f40676310
* DifferenceEngineTest: improve data providersTim Starling2023-06-221-76/+98
| | | | | | | | | | | | * Have data providers return plain data instead of objects. * Use addDBDataOnce() instead of a DIY equivalent. * Use a data provider instead of a loop in testMapDiffPrevNext and testLoadRevisionData. Resolve the problem of the provided data depending on auto-increment IDs from addDBDataOnce by using special strings that are replaced with IDs in the test case. Bug: T332865 Change-Id: Ie41f3222aa1b48c69dbfe4cd7f6ef84e394e31fa
* Merge "Move DiffEngine and helpers to includes/libs/Diff and put them in a ↵jenkins-bot2023-06-201-11/+0
|\ | | | | | | namespace"
| * Move DiffEngine and helpers to includes/libs/Diff and put them in a namespaceTim Starling2023-06-201-11/+0
| | | | | | | | | | | | | | I will address the dependencies on MW core in a followup. Bug: T339184 Change-Id: I892364b0c9f15c9de4cfc29c683670c172d71764
* | tests: Use MainConfigNames consts to refer config namesUmherirrender2023-06-191-2/+2
|/ | | | | | PasswordSalt was dropped in 2e909bcb Change-Id: I58d2b8d4e2a235afdc8054eafdea4e85b61f03c1
* tests: Make some PHPUnit data providers staticTim Starling2023-03-242-4/+4
| | | | | | | | | | | | | 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
* build: Updating mediawiki/mediawiki-codesniffer to 41.0.0libraryupgrader2023-03-111-1/+1
| | | | | | | The following sniffs are failing and were disabled: * MediaWiki.Usage.ForbiddenFunctions.eval Change-Id: I6fd0a9296c88a77c3abec6e5e8d568bb469c2d6e
* 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
* diff: Handle timestamp correct for suppressed revisionsUmherirrender2022-12-171-4/+6
| | | | | | | | - No linking when the user cannot see the suppressed revision - Double-strike the timestamp (b6f148b) Bug: T325450 Change-Id: If94e9655d72e59a2b9d5147c5c2338e98f0ad163
* tests: Add tests for DifferenceEngine::getRevisionHeaderUmherirrender2022-12-171-0/+80
| | | | | | Test all situation with or without revision deletion Change-Id: I9b490cb764853a85d4a0ab64b4c3118c34f71335
* Fix casing of class and function name usagesReedy2022-12-041-1/+1
| | | | | Bug: T253628 Change-Id: I5c64f436d3cf757390b751ce3e34bfc7872bc176
* Make use of the new PageUpdateStatusdaniel2022-11-301-1/+1
| | | | | | | | PageUpdateStatus provides clean access the the newly created RevisionRecord. Depends-On: Ia08c586198082ea47e8313d0d41835f9830fb29e Change-Id: Id6963842321c4eaa3d7d029ad0b769f73433c103
* tests: Use MediaWikiIntegrationTestCase::editPage for editsUmherirrender2022-09-231-5/+9
| | | | Change-Id: I1db7294635bb85e03841c4f7b100e2243ddf013b
* tests: Migrate `setMwGlobals()` to `overrideConfigValue(s)()`Derick Alangi2022-07-231-1/+2
| | | | | | | | | | | | | | Directories covered are: - tests/phpunit/includes/cache/ - tests/phpunit/includes/changes/ - tests/phpunit/includes/changetags/ - tests/phpunit/includes/config/ - tests/phpunit/includes/content/ - tests/phpunit/includes/debug/ - tests/phpunit/includes/deferred/ - tests/phpunit/includes/diff/ Change-Id: I3a1f586867db7d57b177e13a03a4593f7eed09f4
* Replace trivial usa of mock builder with createMock() shortcutThiemo Kreuz2022-07-151-2/+1
| | | | | | | | | | | createMock() does the same, but is much easier to read. A small difference is that some of the replacements made in this patch didn't use disableOriginalConstructor() before. In case this was relevant we should see the respective test fail. If not we can save some CPU cycles and skip these constructors. Change-Id: Ib98fb06e0fe753b7a53cb087a47e1159515a8ad5
* tests: Use Title::makeTitle instead of Title::newFromTextUmherirrender2022-07-061-1/+1
| | | | | | Avoid parsing known titles in tests to improve performance Change-Id: Ibfccfe696f0b8bfda0b99abae324e60bbecef7d8
* Merge "diff: Fix small issues and compact syntax in DifferenceEngine"jenkins-bot2022-02-041-0/+1
|\