aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/content/WikitextContentHandlerTest.php
Commit message (Collapse)AuthorAgeFilesLines
* tests: Use namespaced classesUmherirrender2024-10-211-2/+3
| | | | | | | | 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 namespace to IDBAccessObject and DBAccessObjectUtilsJames D. Forrester2024-09-271-0/+1
| | | | | Bug: T353458 Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
* Move remaining four classes in includes/content into Content namespaceJames D. Forrester2024-08-101-1/+1
| | | | | Bug: T353458 Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
* Add namespace to FileContentHandlerEbrahim Byagowi2024-08-071-0/+1
| | | | | | It adds MediaWiki\Content namespace to FileContentHandler Change-Id: I2db36de12a60c78524ea6ee2d8866ff901a48cac
* Add namespace to WikitextContentEbrahim Byagowi2024-08-061-1/+3
| | | | | | | It adds MediaWiki\Content namespace to WikitextContent and two classes related. Change-Id: Ib74e4c5b3edac6aa0e35d3b2093ce1d0b794cb6d
* content: Widen `@covers` tags in phpunit testsTimo Tijhof2024-07-211-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:Widen > Given all called methods are de-facto and liberally claimed, and > that we keep the coverage limited to the subject class, it maintains > the spirit and intent by listing the class explicitly instead. > > PHPUnit offers a more precise tool when you need it (i.e. when testing > legacy monster/god classes), but for well-written code, the > class-wide tag is exactly what you want. > > We lose useful coverage and waste valuable time on keeping tags > accurate through refactors (or worse, forget to do so). > Tracking tiny per-method details wastes time in realizing (and > fixing) when people inevitably don't keep them in sync, and time > lost in finding uncovered code to write tests to realize it was > already covered but "not yet claimed". While at it, also fix PHPUnit warnings in CssContentHandlerIntegrationTest and JavaScriptContentHandlerIntegrationTest about not having any `@covers` annotations. Change-Id: I5afd9fe0bca0fa86cc096f6e5e79f2ba1cfbfa77
* tests: Use namespaced classes (1)Umherirrender2024-06-141-0/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: Iae45fa269363be8ee05c598ea6926514ce817762
* tests: Remove usage of deprecated methods on ContentHandlerdaniel2024-04-301-0/+23
| | | | | | Prepare for hard deprecation of static ContentHandler methods. Change-Id: Ie37937da26630d4c9782f2ac4aa413e9c18ea535
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-161-5/+5
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Remove indirect calls to IDBAccessObject::READ_* constantsAtieno2024-01-291-1/+1
| | | | | | | | | We are getting rid of the schema of implementing this interface and calling self::READ_* constants, it's confusing, inconsistent, prone to clashes and isn't really useful for non-ORM systems (which we are not) Bug: T354194 Change-Id: I4c722807b27db4e59f5ba3acc3ddb57fca9140b1
* 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
* WikitextContentHandler/ParserOutput: move redirect header to post processingC. Scott Ananian2023-09-151-32/+0
| | | | | | | | | Insert the redirect handler as part of the post-processing done in ParserOutput::getText(). This ensures that it does not corrupt edit-mode Parsoid output. Depends-On: Ia6e390d849830993a6b97004f099773cfd4fa54b Change-Id: I20db09619999919bfeda997d79561d21e3bf8718
* Avoid DB access in non-database testsDaimona Eaytoy2023-08-061-2/+17
| | | | | | | | Mock the needed dependencies to avoid database access when possible, and add the test to the Database group otherwise. Bug: T155147 Change-Id: Ic5c39ab35ab4d993721713285180f072497a5a40
* Merge "Hard-deprecate ParserOutput::{get,set}Flag()"jenkins-bot2023-08-021-1/+4
|\
| * Hard-deprecate ParserOutput::{get,set}Flag()C. Scott Ananian2023-07-281-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These were deprecated in 1.38; users are expected to use ParserOutput::{get,set}OutputFlag() instead, which helps eliminate a confusing aliasing of many MW methods named "flag". Original deprecation: 06ab90f163fd63f0cda8952ecf4d6e15a6e16260 Code search: https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos= Patches for non-production extensions: PageProperties: I592d43e2c912df635cd9162180ed20a6136535f1 CIForms: I238a6c557891bb6d271d2641261ef69542b7957e Bug: T292868 Bug: T305161 Change-Id: I4525443ab0932241b0cf64ab606f7ab7d6d70b6e
* | tests: Avoid database usage when possibleDaimona Eaytoy2023-07-311-16/+15
|/ | | | | | | | | | | | | | | | | | | | | | | | We would like to remove DB access in non-database PHPUnit tests. As a first step, avoid database usage in tested code when possible. In particular: - In NameTableStoreFactory, avoid domain ID normalization if the provided ID is already false. - In SpecialDoubleRedirects, do not acquire a DB connection until it's needed (which is just one place). - Use editPage() in TitleDefTest instead of a DIY implementation, and add `@group Database` accordingly. - Avoid parsing titles in ContentHandler tests that don't need to parse titles. Among the many dependencies of parsing titles is the interwiki lookup, which requires DB access. - Also remove test cases that used the "Gadget" namespace; it doesn't exist in core, so these pages were actually in the mainspace. - Mock the database in CategoriesRdfTest. The only two methods that use the database were already being mocked. - Add `@group Database` to test classes that are intentionally using the Database, mainly via getTestUser(). Bug: T155147 Change-Id: I9385fe14cfeb6b7b7378cc322d510034c4ee0711
* tests: Use Title::makeTitle instead of Title::newFromTextUmherirrender2023-06-191-1/+1
| | | | | | Avoid parsing known titles in tests to improve performance Change-Id: Iddefe62c3d85281642f17e60cbc27aff47b85a67
* 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
* 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
* tests: Use WikiPageFactory to create WikiPage objectUmherirrender2022-06-261-1/+1
| | | | | Bug: T259948 Change-Id: I9afcf3b845306f81ee5ca156553256e6c38df3a0
* Language: Inject NamespaceInfoBartosz Dziewoński2022-05-111-2/+1
| | | | Change-Id: I90eee60467698bbefb619bfa69abfaa10c759fea
* Clarify generate-html and make ParserOutput behave as expectedBrian Wolff2022-05-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously: * It was unclear that generate-html is an optional optimization * Most of MediaWiki core was doing $parserOutput->setText('') if html wasn't generated. However this is wrong and will cause $parserOutput->hasText() to return true and also potentially cause cache pollution if a content handler both does that and supports parser cache (Like MassMessage; see T299896) * The default value of mText in the constructor was '', and most of the time MW used that default. This doesn't seem right. If setText() is never called, the ParserOutput should not be considered to have text * It was impossible to set mText to null, as $parserOutput->setText(null) was a no-op. Docs implied you were supposed to do this, so it was very confusing. This patch clarifies docs, changes the default value for ParserOutput::$mText from '' to null, and makes $parserOutput->setText(null) do what you expect it to. The last two are arguably breaking changes, although the previous behaviours were unexpected, mostly undocumented and based on a code search do not appear to be relied on. It seems like the main reason this only broke MassMessage is most content handlers either don't support generateHtml, or they don't support parser cache. Bug: T306591 Change-Id: I49cdf21411c6b02ac9a221a13393bebe17c7871e Depends-On: I68ad491735b2df13951399312a4f9c37b63a08fa
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-4/+3
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* Replace Content::getParserOutput call to ContentRenderer::getParserOutputRoman Stolar2021-10-201-0/+22
| | | | | Bug: T287158 Change-Id: I8a13f45027e08e2d8ddefa140dd47a0c55094934
* 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
* Replace PHPUnit ->returnValue() with ->willReturn() shortcutThiemo Kreuz2021-04-221-2/+2
| | | | | | | | | | | | It's the same and makes the test code much more readable, I would like to argue. Because of the was I split all the changes I made into smaller patches this patch contains some other changes in the same lines where I could not split them off. E.g. removal of ->any(), which is the default anyway and doesn't do anything. Change-Id: Ib297b989d4aec33b31a4e33fe9d5032865b39be0
* phpunit: Mass-replace setMethods with onlyMethods and adjustDaimona Eaytoy2021-04-161-2/+2
| | | | | | | | | | | | Ended up using grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g' special-casing setMethods( null ) -> onlyMethods( [] ) and then manual fix of failing test (from PS2 onwards). Bug: T278010 Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
* Merge "Revert "Add change tags for media additions/removals""jenkins-bot2021-03-261-32/+0
|\
| * Revert "Add change tags for media additions/removals"Urbanecm2021-03-261-32/+0
| | | | | | | | | | | | | | | | | | | | This reverts commit 5a0bfa9d9816b01a73d0d2f4b75249ade588777b. Reason for revert: caused a train blocker (T278429) plus Daniel says it's "super expensive" Bug: T278429 Bug: T266067 Change-Id: I6724b4bc02d29c12c3fe18cc1e8fa17a443257d5
* | Merge "Add change tags for media additions/removals"jenkins-bot2021-03-221-0/+32
|\|
| * Add change tags for media additions/removalsMatthias Mullie2021-03-101-0/+32
| | | | | | | | | | | | | | | | | | This introduces 3 new tags to track changes in media usage across articles. These tags are both hidden & disabled by default. Bug: T266067 Change-Id: I3e7acafe0b2266cf6e253dfef42fa6c666424469
* | Split WikitextContentHandlerTest into separate unit testsDannyS7122021-03-151-108/+3
|/ | | | | | | Not everything requires integration Clean up the code that is being moved Change-Id: I045641a8b72fa07f21f3a41d84bb24aca55374a0
* Introduce ContentHandlerFactoryArtBaltai2020-02-071-1/+2
| | | | | | | | | | | | | | | | | Added: - ContentHandlerFactory Tests: - PHPUnit Changed - Calls of changed and deprecated - DI for some service/api Deprecated: - ContentHandler::* then similar to ContentHandlerFactory - ContentHandler::getForTitle - ContentHandler::$handlers Bug: T235165 Change-Id: I59246938c7ad7b3e70e46c9e698708ef9bc672c6
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-4/+4
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-301-1/+1
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* Clean up most of b/c for phpunit4Amir Sarabadani2019-10-061-2/+2
| | | | | | | We don't support phpunit4 anymore: https://w.wiki/9UT Change-Id: Ia7c932998f1a49af1e322ab9e1dc249b7bd2e8b2
* tests: Prefer PHPUnit's assertSame() when comparing empty stringsThiemo Kreuz2019-09-201-1/+1
| | | | | | | | assertSame() is guaranteed to never do any magic type conversion. This can be critical when accidentially comparing empty strings (a value PHP considers to be "falsy") to false, 0, 0.0, null, and such. Change-Id: I2e2685c5992cae252f629a68ffe1a049f2e5ed1b
* Add some missing @covers tagsKunal Mehta2019-02-021-0/+6
| | | | Change-Id: Idb9af9515702ee9748755d7799663713b2283647
* Deprecate Content::getNativeData, add TextContent::getTextdaniel2019-01-161-4/+4
| | | | | | | | | | | | | getNativeData() is under-specified - callers can do nothing with the value returned by getNativeData without knowing the concrete Content class. And if they know the concrete class, they can and should use a specialized getter instead, anyway. Basically, getNativeData is overly generic, an example of polymorphism done poorly. Let's fix it now. Bug: T155582 Change-Id: Id2c61dcd38ab30416a25746e3680edb8791ae8e8
* Re-namespace RevisionStore and RevisionRecord classesBrad Jorsch2018-10-091-1/+1
| | | | | | | | | | | | | | | | | | | During development a lot of classes were placed in MediaWiki\Storage\. The precedent set would mean that every class relating to something stored in a database table, plus all related value classes and such, would go into that namespace. Let's put them into MediaWiki\Revision\ instead. Then future classes related to the 'page' table can go into MediaWiki\Page\, future classes related to the 'user' table can go into MediaWiki\User\, and so on. Note I didn't move DerivedPageDataUpdater, PageUpdateException, PageUpdater, or RevisionSlotsUpdate in this patch. If these are kept long-term, they probably belong in MediaWiki\Page\ or MediaWiki\Edit\ instead. Bug: T204158 Change-Id: I16bea8927566a3c73c07e4f4afb3537e05aa04a5
* Add constant for the name of the 'main' slot for MCRGergő Tisza2018-09-241-2/+3
| | | | | Bug: T202142 Change-Id: I97a74e5a029b014f3c2195188936d5c8233c1b7f
* Introduce ContentHandler::getSecondaryDataUpdates.daniel2018-09-141-0/+27
| | | | | | | | | | This adds getSecondaryDataUpdates and getDeletionUpdates to ContentHandler, and updates WikiPage and DerivedPageDataUpdates to handle DataUpdates from all slots. Bug: T194038 Bug: T194037 Change-Id: I75c96318f58a5cdda48484f7040ae41e6f42392a
* Mass conversion of $wgContLang to serviceAryeh Gregor2018-08-111-2/+1
| | | | | | | Brought to you by vim macros. Bug: T200246 Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
* MagicWordFactory to replace MagicWord static members/methodsAryeh Gregor2018-07-301-1/+3
| | | | | | | | | | | | | | Static members of MagicWord have been removed. Static methods are soft-deprecated and forward to the factory. They will be hard-deprecated when all callers are removed from core. MagicWord::clearCache() has been removed. Instead, call resetServiceForTesting( 'MagicWordFactory' ) on your MediaWikiServices object. Change-Id: Ie061fe90f9b9eca0cbf7e8199d9ca325c464867a Bug: T200247
* Use ::class to resolve class names in testsUmherirrender2018-01-261-1/+1
| | | | | | | This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
* Remove very, very old disabled test cases and todosThiemo Mättig2017-12-281-17/+0
| | | | | | Some of this is from 2011. Change-Id: I3cf78e6b451af92063746af87c25c1d352ce94da
* Add @covers tags to ContentHandler testsKunal Mehta2017-12-271-0/+6
| | | | Change-Id: I4d0994e91f63a0921343f34ef81a82463b4ab969
* Add new core tagspetarpetkovic2017-11-301-0/+105
| | | | | | | | | | | | | | Add tags to types of edits that get automatic edit summaries: - Making a page a redirect - Changing redirect target - Changing an existing redirect into a non-redirect - Blanking of the page - Removing nearly all (more than 90%) content - Rolling back an edit Bug: T167656 Bug: T73236 Change-Id: Ie7f637fcec5ee659c1086e28e8ba21f470c45160
* phpunit: Avoid use of deprecated getMock for PHPUnit 5 compatTimo Tijhof2017-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | The default will remain PHPUnit 4.x due to PHP 5.5 support. But, we should allow developers to run tests with newer PHPUnit versions which are noticably faster (especially for code coverage reports). * <https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0> PHPUnit 5 deprecates the getMock() shortcut for getMockBuilder()->getMock(). It instead introduces the shortcut createMock() which has better defaults than getMockBuilder(). For example, it sets 'disableArgumentCloning' and other things by default. Going forward, code should either use getMockBuilder directly and configure it using the setter methods (instead of the confusing variadic arguments of getMock) or simply use the new minimalistic createMock method. This patch backports the createMock method to MediaWikiTestCase so that we can start using it. Change-Id: I091c0289b21d2b1c876adba89529dc3e72b99af2
* Create fields & data for image/file data indexingStanislav Malyshev2016-09-261-2/+11
| | | | | Bug: T145558 Change-Id: I23d4c8235d0e4150eefec31cea4b2cfdd32bf32a