aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/content/TextContentTest.php
Commit message (Collapse)AuthorAgeFilesLines
* tests: Use namespaced classesUmherirrender2024-10-211-0/+1
| | | | | | | | 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
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-1/+1
| | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* tests: Add missing documentation to class propertiesUmherirrender2024-09-181-0/+1
| | | | | | | | | | 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: Ifc27750207edc09e94af030d882b6f1a5369cf98
* Add namespace to WikitextContentEbrahim Byagowi2024-08-061-0/+1
| | | | | | | It adds MediaWiki\Content namespace to WikitextContent and two classes related. Change-Id: Ib74e4c5b3edac6aa0e35d3b2093ce1d0b794cb6d
* content: Widen `@covers` tags in phpunit testsTimo Tijhof2024-07-211-27/+6
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* content: Restore broken test coverage for TextContent::getNativeDatathiemowmde2024-07-211-34/+6
| | | | | | | | | | | The getNativeData() method got deprecated and wasn't tested any more. The test case was made identical to the existing test for getText(). This mistake happened in 2018, see Id2c61dc. I suggest to re-arrange the existing test cases to make it much more obvious what's happening here. Change-Id: I022a7183b87402290898bee3458ef700009e1401
* Add namespace and deprecation alias to TextContentHandlerEbrahim Byagowi2024-05-201-1/+1
| | | | | | | | | This patch introduces a namespace declaration for the MediaWiki\Content to TextContentHandler and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I2c72dacf28ee72fb70b15acdd81d0eb717ea949a
* Add namespace and deprecation alias to TextContentEbrahim Byagowi2024-05-191-17/+18
| | | | | | | | | 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 JavaScriptContentEbrahim Byagowi2024-05-171-0/+1
| | | | | | | | | This patch introduces a namespace declaration for the MediaWiki\Content to JavaScriptContent and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I87c17327911e28a461feaf2ff46242454cff257a
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-161-18/+18
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Namespace includes/contextJames D. Forrester2024-02-081-0/+1
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessaryJames D. Forrester2023-11-211-4/+0
| | | | | Bug: T342301 Change-Id: I5ea01f7ee103570165261bde0965c5b65e04c369
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-191-0/+1
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* 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-5/+7
| | | | | | | | | | | | | | 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 Content::getParserOutput call to ContentRenderer::getParserOutputRoman Stolar2021-10-201-47/+0
| | | | | Bug: T287158 Change-Id: I8a13f45027e08e2d8ddefa140dd47a0c55094934
* Hard-deprecate Content::preSaveTransform.Roman Stolar2021-08-251-40/+0
| | | | | | | | Use ContentTransformer::preSaveTransform instead. Extensions defining a content model should override ContentHandler::preSaveTransform. Bug: T287156 Change-Id: I2a8c60470366fd95d056e0dfa8144f209bb7117e
* Hard-deprecate Content::preloadTransform.Roman Stolar2021-08-231-23/+0
| | | | | | | | Use ContentTransformer::preloadTransform instead. Extensions defining a content model should override ContentHandler::preloadTransform. Bug: T287157 Change-Id: I766d793881812524fb9762292b7abedeb3cd0769
* Remove Content::getDeletionUpdates() and all usage of it.Roman Stolar2021-07-221-48/+0
| | | | | | Bug: T285730 Depends-On: Iab6916134308c73f97c2c4fce2c11a08eab95442 Change-Id: If65db7bc768c6991935982d738f8a3a20d8b4c18
* 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
* Use WikiPage::doUserEditContent() instead of ::doEditContent()DannyS7122021-06-281-1/+1
| | | | | | | | Results in passing a user where previously the fallback to $wgUser was being used, mostly in tests. Bug: T255507 Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
* Make WikiPage a (non-proper) PageIdentityDaniel Kinzler2021-02-101-1/+1
| | | | | | | | | | | | This is a step towards introducing PageRecord. We allow WikiPage to be a "non-proper" PageIdentity for now, but this should be changed to a ProperPageIdentity as soon as possible. Bug: T272424 Change-Id: I194c55ec757e655117bccfeb7d6f5d8487b559e5 Signed-off-by: daniel <dkinzler@wikimedia.org>
* Convert RevisionRecord to Authority and PageIdentityPetr Pchelko2021-01-211-1/+1
| | | | | | | | | | | | | | | | | | | As we convert the RevisionRecord to using Authority, we no longer need Title instances, so we can convert that to PageIdentity. Ideally, we'd part away from using Title at all, but: 1. For foreign wikis PageIdentity has stronger validation, so calling PageIdentity getId() on Title will break things. There's still a lot of code depending on lax Title guarantees, so we keep it. 2. A lot of code still depends on Title, so we try to pass it through even if we don't nesessarily need to, to save cost on recreating it later on. Bug: T271458 Depends-On: I287400b967b467ea18bebbb579e881a785a19158 Change-Id: I63d9807264d7e2295afef51fc9d982447f92fcbd
* Make WikitextContentTest set the context title to avoid failuresAaron Schulz2020-10-201-0/+2
| | | | | | | | This avoids failures due to WikitextContent::isCountable() erroring out when no title is set for the main RequestContext. Bug: T257009 Change-Id: I70274e3876c5b7c273110f9afa713a85edcc6339
* Remove all methods of MWTidy except for MWTidy::tidy()C. Scott Ananian2020-08-171-8/+0
| | | | | | | These methods were either @internal or deprecated in 1.35 Bug: T198214 Change-Id: Ica1d1fdfd2a23a2040eac90c71f6211a4513c916
* Merge "Remove minor pieces of unused code from TextContentTest"jenkins-bot2020-06-081-3/+3
|\
| * Remove minor pieces of unused code from TextContentTestThiemo Kreuz2020-05-291-3/+3
| | | | | | | | | | | | | | * Some function parameters are not used (any more). * Prefer the much cheaper makeTitle(), if possible. Change-Id: If6fe444175db843c1839880212673d0b0edefb27
* | Replace all call_user_func(_array) in all testsThiemo Kreuz2020-06-061-2/+2
|/ | | | | | | | | | | | | There is native support for all of this now in PHP, thanks to changes and additions that have been made in later versions. There should be no need any more to ever use call_user_func() or call_user_func_array(). Reviewing this should be fairly easy: Because this patch touches exclusivly tests, but no production code, there is no such thing as "insufficent test coverage". As long as CI goes green, this should be fine. Change-Id: Ib9690103687734bb5a85d3dab0e5642a07087bbc
* Tests: Remove unneeded uses of global $wgUserDannyS7122020-03-121-1/+0
| | | | | | | Tests still pass -> wgUser isn't needed Bug: T243708 Change-Id: I931f01bc132a5777c27a4296a14fd734a23ca099
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-2/+2
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-301-2/+2
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* Add some missing @covers tagsKunal Mehta2019-02-021-0/+4
| | | | Change-Id: Idb9af9515702ee9748755d7799663713b2283647
* Deprecate Content::getNativeData, add TextContent::getTextdaniel2019-01-161-5/+25
| | | | | | | | | | | | | 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
* Use Remex for TextContentTest subclassesC. Scott Ananian2018-09-251-1/+1
| | | | | | | We are deprecating untidy configurations of the parser. Bug: T198214 Change-Id: I16529879a3b3aed960c5dc006e2af513d7e91fcd
* Hard-deprecate the $wgUseTidy optionC. Scott Ananian2018-09-201-1/+1
| | | | | | | | | This has been soft-deprecated since MW 1.26; this hard-deprecation sets the stage for future removal of this old cruft. Bug: T198214 Depends-On: Idf246d05d116f63a73105b50a1929a7721fbe7b9 Change-Id: I2e7d990da1da378eb6e828d4b3c0f5a41791dd92
* [MCR] Set MCR migration stage to write-both/read-new.daniel2018-09-111-13/+11
| | | | | | | | | | | | | | This patch exists to see if CI passes with $wgMultiContentRevisionSchemaMigrationStage set to SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW. NOTE: verify that $wgMultiContentRevisionSchemaMigrationStage is explicitly set toSCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD in production config (T197816) before merging this. Bug: T198561 Depends-On: Ib718868d2c768b6ea851355eef047bc0e6593495 Change-Id: I15989adae2b5916577d164c50d7da88774e49324
* Mass conversion of $wgContLang to serviceAryeh Gregor2018-08-111-5/+6
| | | | | | | Brought to you by vim macros. Bug: T200246 Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
* Drop 'comma' value for wgArticleCountMethodJames D. Forrester2018-03-011-10/+0
| | | | | | | | | | | | | | | | | We have three methods for page counting currently supported for wikitext non-redirect pages; 'any' counts any page that exists, 'link' counts any page that has any outbound links, and 'comma' which searches for any ',' in the text having loaded it. This last option is much slower than these other two, and is only used on a very small number of installations. Now by dropping support for this method we can simplify this code and so run it more often. Note that non-wikitext pages already did not support this count method. Installations with this setting set to 'comma', or any other string will now work as if it was configured with 'any'. Bug: T188472 Change-Id: I965927edcd2485ec4b49b2d80fdf216dbf19520b
* 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 method level @group Database tagsaddshore2017-11-231-1/+0
| | | | | | | MessageTest did not have the group at class level either so that is added in this patch. Change-Id: Idb6213282d6854044f374c9df51ea32d0a5523e1
* content: Refactor normalization of line endings codeKunal Mehta2016-08-231-0/+26
| | | | | | | | | | | | | | | | | The code that normalizes line endings ("\r\n" and "\r" to "\n") and trims trailing whitespace is buried in Parser::preSaveTransform(), and was duplicated to TextContent in 96b6afb31dfcff, as non-wikitext content models should still be normalizing line endings. This splits the duplicated code into TextContent::normalizeLineEndings(), and utilize it in the Parser. Additionally, expand the documentation of TextContent::preSaveTransform() to document that subclasses should make sure they normalize line endings during the PST stage. And remove a useless rtrim() call from WikitextContent that did nothing. Change-Id: I9094c671d4bbd23d75436f8f1d682d6dd6e6d2fc
* TextContent: Normalize newlines in preSaveTransform()Brad Jorsch2016-08-161-0/+5
| | | | | | | | | | | | | | This does the same normalization of newlines that Parser::preSaveTransform() does. This should be appropriate for any text content type, especially considering that EditPage uses WebRequest::getText() which does a less-strict version of this same transformation. This also cleans up the code for doing that newline replacement to be a bit less verbose. Bug: T142805 Change-Id: I462afcda502f031a8b0360d982ce2398a0383a96
* Remove Title::newFromRedirectRecurse()Florian2016-04-031-10/+0
| | | | | Bug: T122754 Change-Id: I8b957eff7f355493ef6850f7a83dcb619ab6be78
* Remove Title::newFromRedirectArrayFlorian2016-04-021-10/+0
| | | | | Bug: T122754 Change-Id: I2cdeb98c81d4b98ea986bd2f7b23cd93c62c5930
* Convert all array() syntax to []Kunal Mehta2016-02-171-76/+76
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Fix issues identified by SpaceBeforeSingleLineComment sniffVivek Ghaisas2015-09-261-3/+3
| | | | Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
* Abstract and refactor Tidy supportTim Starling2015-09-101-1/+7
| | | | | | | | | | | | | | * Split tidy implementations into a class hierarchy * Bring all tidy configuration into a single associative array and deprecate the old configuration. * Remove $wgAlwaysUseTidy This is preparatory to replacement of Tidy (T89331). I used the name "Raggett" for things relating to Dave Raggett's Tidy, since if we use "tidy" to mean the new abstract system as well as Raggett's tidy, it gets confusing. Change-Id: I77af1a16cbbb47fc226d05fb9aad56c58e8910b5
* Fix bypassing hooks in TextContentTestumherirrender2014-10-231-20/+1
| | | | | | | Save the whole global $wgHooks with the default way instead of just a hook in a own variable. Change-Id: Ie796f7a53ee38e0dc07f5b026134bbdcb8c9fd53
* Limit test leakage, $wgCapitalLinks expected to be trueChad Horohoe2014-07-071-0/+1
| | | | Change-Id: I0f837d29595abefaebeb67d6cc62ea48838d626a
* Introduce ContentGetParserOutput hookdaniel2014-05-101-3/+23
| | | | | | | | | | | | | This hooks allows extensions to override the normal model-specific rendering of page content. A typical use would be to provide syntax highlighting for pages that contain scripts. In that sense, ContentGetParserOutput is a generalization of the old ShowRawCssJs hook. This, together with I76412f9d, is a (hopefully) fixed version of the reverted Ibfb2cbefea44. Change-Id: I979e2438689648ba4c959d8083197ef14ce524e8