aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/XmlTest.php
Commit message (Collapse)AuthorAgeFilesLines
* tests: Move test cases from /includes/ into sub folderUmherirrender2023-09-131-469/+0
| | | | | | | Follow move of the tested class Most moves are part of T321882 Change-Id: I74ab45d6a5331dcb2ff0b65dc2cc7c6315146646
* [tests] Add a regression test for Xml::inputMartin Urbanec2023-07-111-0/+15
| | | | | | | | | | | `Xml::input` threw an exception with `wgUseMediaWikiUIEverywhere` true, when classes don't contain `cdx-text-input__input`. To avoid this regression from happening again, add a test for it. Bug: T341566 Change-Id: I862b36efd10e34a2538d3afa9d67b822f2383c58
* OutputPage,Html,Xml: Widen `@covers` annotations in unit testsTimo Tijhof2023-06-021-52/+2
| | | | | | | | | | | | | | | | | | | | | | Follows-up I6d845bdfbb80, I69b5385868, I4c7d826c7e, I1287f3979ab, which widened the `@covers` annotations of other test 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 tagging missing 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" mechanism, nor am I claiming coverage in > in classes outside the subject under test. > > Tracking this narrow detail wastes time to keep methods in sync during > refactors, time to realize (and fix) when other people inevitably > dodn't keep them in sync, time lost in finding uncovered code to > write tests for only to realize it is already covered but not tagged. Change-Id: I9d63105fd64b0a863d5bfaa67ae069c14531a4cf
* HTML: Remove self-closing XHTML syntax from coreVolker E2023-05-031-3/+3
| | | | | | | | | | Syntactical leftover with no significance in modern web. Bug: T309150 Depends-On: I3a029ca950db42b938962b2452ad136ae8ddea6f Depends-On: Id0557ac19583de36d7226b14a4c06933da47fe97 Depends-On: I17580a72e4a9384d7d774866e610197e950900cb Change-Id: I4bbfa47fbf6e30fb90d920d6d02cdf6e0b1cdb46
* tests: Make some PHPUnit data providers staticTim Starling2023-03-241-3/+3
| | | | | | | | | | | | | 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
* tests: don't assume wgLanguageCode is 'en'C. Scott Ananian2022-07-211-3/+17
| | | | Change-Id: Ic748489309a1c8ff0f916b3f55aacc93ca128ea3
* tests: Set wgLang with MediaWikiIntegrationTestCase::setUserLangUmherirrender2022-07-131-1/+1
| | | | Change-Id: Ic1247a6719032b3a0ea1f76514edc5ffd5a7854a
* tests: Use `overrideConfig(Value|Values)` where neededDerick Alangi2022-07-121-4/+4
| | | | | | | This patch covers: tests/phpunit/includes/actions/ and tests/phpunit/includes/api/. Change-Id: I60d8fb7b8a63b423606db935fa0d24cf859b2512
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-3/+1
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* 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
* Move Xml::expandAttributes tests to unit testsDannyS7122021-03-071-20/+0
| | | | | | No integration logic needed Change-Id: If903ea138dba3703f06c4f4dc27cac1b192b9bbe
* Don't accept empty option group names for dropdown elementsThiemo Kreuz2021-02-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | When this code parses a string that looks like this: * ** A ** B It creates an option group with 2 options, but the name of the group is an empty string. This makes the OOUI DropdownInputWidget fail later. Since the empty group name is useless anyway, drop it. This makes the code behave as if the parsed string looked like this: * A * B Live example for the issue: https://el.wikipedia.org/wiki/MediaWiki:Protect-dropdown Bug: T275125 Change-Id: I780c1be27740b0ed3b35aa569b5a528112d7238f
* Convert or split some tests to MediaWikiUnitTestCaseDannyS7122021-01-071-52/+2
| | | | | | Don't require any integration Change-Id: I293a84ce8fe87fc6932f8a6400d6ca443ccc6235
* Cleanup some tests to reduce code duplicationsDannyS7122020-12-211-172/+69
| | | | | | Also fix incorrect order of some other assertions Change-Id: Idf50f98de7a17311ea8db6f2cae3b101f4c1da89
* Drop down lists: Do not use the value for 'other' as option groupUmherirrender2020-09-161-0/+21
| | | | | | | Instead use them as groupless reason list Bug: T251351 Change-Id: Id691d97e3e6f205615f639e051619f3d0f67c7ba
* MediaWikiTestCase to MediaWikiIntegrationTestCaseaddshore2020-06-301-1/+1
| | | | | | | | | | | | | The name change happened some time ago, and I think its about time to start using the name name! (Done with a find and replace) My personal motivation for doing this is that I have started trying out vscode as an IDE for mediawiki development, and right now it doesn't appear to handle php aliases very well or at all. Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
* Coding style: Auto-fix MediaWiki.Usage.PHPUnit*James D. Forrester2020-01-101-2/+2
| | | | Change-Id: I86fc55a4fc8ceafe368692173211bbcd6d8581d7
* More backwards compatible changes for PHPUnitMax Semenik2019-11-121-2/+3
| | | | | | | | The change in XmlTest is because PHPUnit 8 messes with serialization settings. Bug: T192167 Change-Id: I5c9358d7cfc451845e01fca67c8d15add4039dae
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-301-1/+1
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* Remove Language::factory and getParentLanguage useAryeh Gregor2019-10-271-6/+3
| | | | Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
* Replace setExpectedException with single argDaimona Eaytoy2019-10-051-1/+1
| | | | | | | | Find: (\$this->)setExpected(Exception\( \\?[a-z\\]+::class \);) Replace: $1expect$2 Bug: T192167 Change-Id: I33a24d42b6dc1e126f32d5dbf41daa0bccb1414f
* 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
* ResourceLoader: Add support for packageFilesRoan Kattouw2019-02-051-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Package files are files that are part of a module, but are not immediately executed when the module executes. Instead, they are lazy-excecuted when require() is called on them. Package files can be scripts (JS) or data (JSON), and can be real files on the file system, or virtual files generated by a callback. Using virtual data files, server-side data and config variables can be bundled with a module. Support for file-based require() allows us to import npm modules into ResourceLoader more easily. The require function passed to each script execution context, which was previously a reference to the global mw.loader.require() function, is changed to one that is scoped to the module and the file being executed. This is needed to support relative paths: require( '../foo.js' ) can mean a different file depending on the path of the calling file. The results of require()ing each file (i.e. the value of module.exports after executing it) are stored, and calling require() on the same file a second time won't execute it again, but will return the stored value. Miscellaneous changes: - Add XmlJsCode::encodeObject(), which combines an associative array of XmlJsCode objects into one larger XmlJsCode object. This is needed for encoding the packageFiles parameter in mw.loader.implement() calls. Bug: T133462 Change-Id: I78cc86e626de0720397718cd2bed8ed279579112
* Xml.php: Do not escape double quotes in $contents of Xml::element()Fomafix2018-05-231-2/+2
| | | | | | | | | | There is no need to escape double quotes in content of XML. Html::element() also does not escape double quotes in content. ENT_NOQUOTES escapes '<', '>' and '&' but not "'" and '"'. https://secure.php.net/manual/en/function.htmlspecialchars.php Change-Id: I3b585c43e532cca1a8951d6c9e8b4825fc3b012d
* 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
* Fix @covers in XmlTestKunal Mehta2017-12-241-2/+2
| | | | | | Follows up 389fa13ff875. Change-Id: I32ddf37b24a6b5162b383260233d616cb49f7ddb
* Add tests for several methods of XmlAmir Sarabadani2017-12-251-0/+81
| | | | | | Added tests for methods: monthSelector, span, buildTable, buildTableRow Change-Id: I5ca6bb231b5ed95f57f649a92d659245a4852c85
* Merge "Improve namespace handling in tests"jenkins-bot2017-09-291-0/+5
|\
| * Improve namespace handling in testsBrad Jorsch2017-09-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | MWNamespace has three internal caches, only one of which can be cleared (and that somewhat oddly by passing a boolean to MWNamespace::getCanonicalNamespaces()). This change introduces a MWNamespace::clearCaches() method to clear all three caches. It also adds some resetting in tests that seemed to be missing it. Change-Id: I1dcfcd8713888b3ff8fc75e95329ba72bd95d0c9
* | Revert "Xml: Fix Xml::fieldset() when $content is not given"Bartosz Dziewoński2017-09-171-0/+51
| | | | | | | | | | | | | | | | | | | | Apparently that is intentional and documented. Huh. Whoops. This reverts commit 0f1cc3bb6e7c3be9b86d2c8736f7458cd40588f2. Also add test cases for this bizarre function. Change-Id: I0311f7c85cd575f2a66d50589ec364072be486fb
* | Reduce code duplication for parsing messages into dropdown menusBartosz Dziewoński2017-09-121-6/+57
|/ | | | | | | | | | | | | | | | | | | | The same behavior was implemented by Xml::listDropDown(), Article::confirmDelete() and HTMLFormField::getOptions(). A new function Xml::listDropDownOptions() is added and all three are changed to use it. Additionally: * Xml::listDropDown() now uses XmlSelect internally to generate the dropdown HTML. * Xml::listDropDownOptionsOoui() is introduced to handle converting the existing format to the OOUI format, which was previously duplicated in Article::confirmDelete() and HTMLFormField::getOptionsOOUI(). * This change allows HTMLForm 'select' fields (HTMLSelectField) to support nested options (optgroups) in OOUI mode. This is a prerequisite for T117781. Bug: T117781 Change-Id: I0a088f61eb32ec59677113583c7ecdcbc3fd2af0
* Xml: Add test for listDropDown and remove unused getArrayFromWikiTextListTimo Tijhof2017-03-201-0/+29
| | | | | | Follows-up 4b49705613 and 8c7095be85 (T34950). Change-Id: I95b7f7ce03b2cbe68215a7ff17afc1997a54f9b1
* tests: Replace implicit Bugzilla bug numbers with Phab onesJames D. Forrester2017-02-211-1/+1
| | | | | | | It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345" except where it doesn't, so let's just standardise on the real numbers. Change-Id: I46261416f7603558dceb76ebe695a5cac274e417
* Removed Xml::escapeJsString()Reedy2016-12-021-11/+0
| | | | Change-Id: Iead8385a72a79632a90594a8828080a6d572e039
* Remove support for $wgWellFormedXml=falseBrian Wolff2016-05-121-1/+0
| | | | | | | | | | | | | | | | | | | tl;dr: Having unnessary complexity in security critical code is bad. * Extra options add extra complexity and maintenance burden ** Thus we should only have one html output mode. well formed = false was already vetoed in T52040, so lets go with WellFormed=true. * Options which are used by very few people tend to get tested less * Escaping is an area of code where we should be very conservative * Having escaping rules depend on making assumptions about which characters various browsers consider "whitespace" is scary * $wgWellFormedXml=false has had a negative security impact in the past (Usually not directly its fault, but has made other bugs more exploitable) * Saving a couple bytes (even less bytes after gzip taken into account) is really not worth it in this context (imho). Change-Id: I5c922e0980d3f9eb39adb5bb5833e158afda42ed
* wgUseMediaWikiUIEverywhere false in Html/XmlTestaddshore2016-03-241-0/+1
| | | | | | | | | | | It seems both of these tests assertions all expect this to be false. Ic675e92d8dd8f11fa67914d2ce1dc00a379106ca ended up discovering these issues somehow with these tests suddenly starting to fail. Change-Id: I9d2d3c18d1c9640e2ff04d6fd4296abb86e26877
* OutputPage: Minor clean up of <head> and HTMLTimo Tijhof2016-03-241-3/+3
| | | | | | | | | | | | | | * Remove trailing space in self-closing tag. Brings parserTest output of Parser and Parsoid closer together. * Remove various line breaks at begin and end of script contents. * Remove FILTER_NOMIN from makeConfigSetScript() output. This isn't part of any user- or page-dependent module and not minified. And Xml::encodeJsCall already ensures compact output for prod mode. Bug: T127328 Change-Id: I85a5a59fd0955c1a112e8b24b933f0d9e983a156
* Convert all array() syntax to []Kunal Mehta2016-02-171-16/+16
| | | | | | | | | | 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
* Use XmlSelect to simplify Xml::monthSelectorGeoffrey Mon2015-06-061-3/+3
| | | | | | | | | * Modify Xml::monthSelector * Tweak XmlTest.php to swap the order of some props (XmlSelect output swaps the position of id and name props of <select>s) Bug: T93234 Change-Id: If7e41251a6b2314e36dac8b7522c8e7b765f1814
* Html: Make addition of 'mw-ui-input' conditional on $wgUseMediaWikiUIEverywhereBartosz Dziewoński2015-03-131-6/+6
| | | | | | | | | | | | | We were always adding it previously, which seemed harmless since 'mediawiki.ui.input' RL module, providing the styling, was only loaded if $wgUseMediaWikiUIEverywhere was true… unless someone loaded it manually to have specific input fields styled. Whoops. There are a lot more unconditional additions like this in tons of places in the code, and someone should check whether each one is intentional or not, but probably no one will. Oh well. Bug: T92496 Change-Id: I5e91a3852a76ebbbfe64485bccb4c30ddee28b66
* Add blanket support for mediawiki ui via globalsjdlrobson2014-08-151-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This provides better mobile experiences on various pages and a more consistent UI across both mobile and desktop. It does this in two ways. 1) Forces HTMLForms to not use table based layouts so as not to interfere with responsive nature of mediawiki ui elements 2) Applies MediaWiki.UI classes to most pages If a page is created via Xml or Html classes it will use mediawiki ui Where possible I've added classes unconditionally, but for cases of buttons this is behind the $wgUseMediaWikiUIEverywhere global since button styling is enabled on pages by default and for checkboxes since it is changes HTML markup. 3) Adds all MediaWiki.UI styles to pages which can use it When enabled: * Apply these styles to all pages which use HTMLForms * Apply to EditPage * Apply to anything that uses certain elements outputted by the Xml or HTML helper classes * Apply to History page * Apply to protection page * Apply to move page * Apply to deletion page Currently kept behind a global to allow us time to finetune existing elements. After further testing we will look to kill the globals and make mediawiki.ui the default See: I430c0fbb79d2a33bb828b2427bda0ee01115d73f Change-Id: I47db5eab4569514d039261d11b6dedb0eeae17b5
* Pass phpcs-strict on some test files (8/11)Siebrand Mazeland2014-04-241-1/+2
| | | | Change-Id: I138c1f9bf2c3c7e9218d5fa29365e78b309fb459
* Pass phpcs-strict on some test files (5/x)Siebrand Mazeland2014-04-241-3/+14
| | | | Change-Id: I690645cd8a9b1165dcc8271b201c695ea9391226
* Remove unused stuff from testsaddshore2014-03-071-4/+1
| | | | Change-Id: Iddabfbc80378b02fa4a2c58f80d50241be8105d3
* Fix scope on all /phpunit test methodsaddshore2013-10-241-21/+21
| | | | Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
* Add more @covers tags and test cleanupaddshore2013-10-221-0/+3
| | | | | | | | | Other cleanup includes - Adding method scopes - Fixing php comments - Adding todos Change-Id: I0a231008e6a59110ffcab6af1bd8c4d3ee13f21d
* Add @covers tags for more testsaddshore2013-10-211-11/+75
| | | | Change-Id: Iff3af78e9b41c445b7f066b6c0d0f4a87d2d6c4e
* Drop support for XHTML 1.0Daniel Friesen2013-05-151-1/+0
| | | | | | | | | | | * $wgHtml5 = false; is now ignored completely. * $wgDocType and $wgDTD have been removed. * $wgXhtmlDefaultNamespace is now ignored. * XHTML5 will be output if $wgMimeType is set to an XML mime type (according to HTML5's rules). * For backwards compatibility with extensions $wgHtml5 and $wgXhtmlDefaultNamespace are set in Setup.php but depending on them is deprecated. Change-Id: Iad9634e2ee420b5a3bbffe550421fde4fa1819b0
* Update formattingSiebrand Mazeland2013-02-141-65/+71
| | | | | | 3 of n. Change-Id: I62ad009018c54da6cf081c334e44eb98a3c72695
* Set wgHtml5/wgWellFormedXml for XmlTestsumherirrender2012-12-091-0/+2
| | | | Change-Id: I3cab843bad9461098cf3c6b574fb767c3267ab14