aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/htmlform
Commit message (Collapse)AuthorAgeFilesLines
* tests: Namespace and consolidate existing HTMLForm testsJames D. Forrester2024-03-083-764/+0
| | | | | | | This doesn't alter code coverage, but it puts all the tests in one place so we can improve them consistently. Change-Id: I5e2124704aa8dc4b45be17d61fbc2fbd606661b9
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-163-10/+10
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Namespace HTMLForm and friendsJames D. Forrester2024-02-141-0/+3
| | | | | Bug: T353458 Change-Id: I09e66c3223018ec47e0549ee7f6a590b676f4eef
* Namespace includes/contextJames D. Forrester2024-02-082-0/+3
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* Refactor HTMLRestrictionsField to allow more restrictions to be addedSiddharth VP2023-11-231-76/+0
| | | | | | | | | | | Earlier, loadDataFromRequest() returned MWRestrictions object only in case of valid input, and the original string if invalid. Now, an MWRestrictions object is returned in all cases, on which we now have a validity field. This also de-duplicates the check to find the invalid IP address(es). Bug: T349957 Change-Id: Iadb762b572cf0e7d2b92dbc4912804a3ddb48e74
* Namespace Config-related classes under \MediaWiki\ConfigJames D. Forrester2023-09-211-0/+1
| | | | | Bug: T166010 Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-191-0/+1
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* 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
* Reorg: Move Status to MediaWiki\Status\Amir Sarabadani2023-08-252-0/+2
| | | | | | | | | | This class is used heavily basically everywhere, moving it to Utils wouldn't make much sense. Also with this change, we can move StatusValue to MediaWiki\Status as well. Bug: T321882 Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3 Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
* htmlform: Allow validation-callback to return Status instancesmainframe982023-07-091-1/+116
| | | | | | | | | Convert this in HTMLFormField::validate to prevent callers from receiving unexpected Status instances that will be identified as an error result, even if the Status is good. Bug: T338677 Change-Id: If2208cca92c5c496eef73f25363221bc490d9c88
* tests: Use MainConfigNames consts to refer config namesUmherirrender2023-06-191-1/+2
| | | | | | PasswordSalt was dropped in 2e909bcb Change-Id: I58d2b8d4e2a235afdc8054eafdea4e85b61f03c1
* Replace deprecated MWExceptionDaimona Eaytoy2023-06-092-6/+5
| | | | | Bug: T328220 Change-Id: I66be7a6dd752d6b9c254beb65f4eb5ace3c89776
* Allow setting "notices" for OOUI form fieldsMarius Hoch2023-05-301-0/+19
| | | | | | | | We need this in Wikibase to nicely indicate why a certain form field cannot be used. Bug: T330193 Change-Id: Ic0a6f9561db41d4da218122477ce9318665929d5
* tests: Make some PHPUnit data providers staticTim Starling2023-03-243-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
* Reorg: Namespace the Title classJames D. Forrester2023-03-023-0/+3
| | | | | | | | | | | | | | | | | | | 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
* Revert "htmlform: Improve validation of multiselect fields"Kosta Harlan2023-02-021-58/+0
| | | | | | | | | This reverts commit 782828c1062dfcbd1c8729b574526a4caa1ebf49. Reason for revert: T328676 Bug: T328676 Change-Id: I4d2a72c02fab8ef31eb165237349e298509a4f1a
* htmlform: Improve validation of multiselect fieldsUmherirrender2023-01-291-0/+58
| | | | | | | | | | | | | | | | | | - Run the 'max' check always, even 'exists' option is set to false, let the parent class decide if exists validation is needed (for namespace type this is just moved, parent does not support that setting) - Validate given namespace to be numeric and cast the value, on new php the meaning of the condition ´'text' < 0´ changed (https://wiki.php.net/rfc/string_to_number_comparison) - Pass the max value as formatted number to the message - Return message as object, allows the html builder to choose the correct format to display - Make 'required' to work on namespace type and title multiselect type - Combine multiple errors from each validation step and show as bullet point list, if multiple errors exists (not for namespace type, there are no nice messages to show) Change-Id: I1f6df50277e6911b2f0ac36fdbd071407437fc78
* Replace more usages of MWExceptionDaimona Eaytoy2023-01-261-1/+1
| | | | | Bug: T86704 Change-Id: I14abf71b7dcf432d0eb35f0b4ab2fa4fb797e2e8
* Simplify callback in HTMLForm testsBartosz Dziewoński2023-01-102-8/+2
| | | | | | | | The anonymous function was equivalent to just specifying 'wfMessage'. Same as in I355504984d343a2c7c469759f791612c5b6d6556 in Wikibase. Change-Id: Ib94b7cceabce25ca95374d944255c7197e6a476a Follows-Up: Ica0740049f0a3e8ec764903c5b71825e4d628a3f
* Deprecate creating HTMLFormFields without reference to parent formBrian Wolff2023-01-082-2/+18
| | | | | | | | | | | | | | | | Currently it is documented that mParent in HTMLFormField may be null. This can happen if the form element is constructed manually via new, instead of the normal way via HTMLForm methods. As it stands, much of the code assumes that mParent is always set despite the documentation. Lets mark creating form fields without parent set as deprecated. The current situation seems like a recipe for bugs, and after the deprecation period this would allow us to simplify some of the HTMLFormField code. Bug: T326456 Change-Id: Ica0740049f0a3e8ec764903c5b71825e4d628a3f Depends-On: I15a39605e3eec8a5c265c4a331039fa906eda036
* Reorg: Move RawMessage to under language/Amir Sarabadani2022-12-161-0/+1
| | | | | | | | | | To follow Message. This is approved as part of RFC T166010. Also namespace it but doing it properly with PSR-4 would require namespacing every class under language/ and that will take some time. Bug: T321882 Change-Id: I195cf4c67bd51410556c2dd1e33cc9c1033d5d18
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-283-0/+5
| | | | | | | | | | | | | | | Redoing I5ea70120d74 but without moving WebRequest that caused issues with phan-taint-plugin. Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequestUpload Bug: T321882 Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
* Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-273-5/+0
| | | | | | | | | This reverts commit 2bdc0b2b7209441a42a784157633a8a01b321922. Reason for revert: T166010#8349431 Bug: T166010 Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-263-0/+5
| | | | | | | | | | | | | Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequest - WebRequestUpload Bug: T166010 Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
* tests: Replace assertRegExp with assertMatchesRegularExpressionDaimona Eaytoy2022-10-071-2/+2
| | | | | | | | | | | | | | | | | | And also assertNotRegExp -> assertDoesNotMatchRegularExpression. The methods were renamed in PHPUnit 9. Done automatically with: grep -rl assertRegExp tests/ | xargs sed -r -i "s/>assertRegExp\(/>assertMatchesRegularExpression\(/" grep -rl assertNotRegExp tests/ | xargs sed -r -i "s/>assertNotRegExp\(/>assertDoesNotMatchRegularExpression\(/" Split out from Ifdba0f9e98eb6bce4590b7eb73170c51a697d7c6 so that it remains smaller and easier to review. Also make a test use MediaWikiUnitTestCase (it's already in the unit/ dir) so that it can access the forward-compat method. Bug: T243600 Change-Id: Ifa279d5f201d7abeebece292141ebface8278046
* tests: Use Title::makeTitle instead of Title::newFromTextUmherirrender2022-09-232-2/+2
| | | | | | Avoid parsing known titles in tests to improve performance Change-Id: Ie240eb42479d19714e64cc4606e26073fadc2e13
* tests: Use Title::makeTitle instead of Title::newFromTextUmherirrender2022-07-061-1/+1
| | | | | | Avoid parsing known titles in tests to improve performance Change-Id: Ibfccfe696f0b8bfda0b99abae324e60bbecef7d8
* htmlform: Remove mw1.30 B/C code for autocomplete attributeDerick Alangi2022-05-191-19/+0
| | | | Change-Id: I24afbacf21d24887508b8b4a0fa82f03ce4cc63d
* tests: Pass context to HTMLForm constructorBartosz Dziewoński2022-05-161-4/+3
| | | | Change-Id: If301d79b9e07485232082035e53d02f5f98e5031
* Merge "HTMLForm: Add test for CSRF token check"jenkins-bot2022-02-211-0/+51
|\
| * HTMLForm: Add test for CSRF token checkGergő Tisza2022-02-131-0/+51
| | | | | | | | | | Bug: T301467 Change-Id: I52edb26f53c79795e3d501f810974aa97665bb77
* | HTMLFormField: Adjust isSubmitAttempt and add more commentsFunc2022-02-111-0/+1
|/ | | | | | | | | | | | | | | This is a follow-up of change Ic414e7bb7933c8c5c58a277ac1c5c3aaf8c36119. I noticed that HTMLForm would add a hidden field of edit token for forms that require to be posted... And I also noticed that there is a crazy use case (https://gerrit.wikimedia.org/g/mediawiki/core/+/9ca83949432f312aff18e29534a3d1cd81dd55b7/includes/specials/SpecialTags.php#320) that would break with the loose check (I'm also going to fix it by I5050311c37030a64daaa25d05e2223485ed86108). So that change should be undone, but keep the POST check here to avoid arbitrary token in a GET form. Add more comments since there are some preconditions in another file and avoid future regression. (And I hope this is the last time I fix this test...) Change-Id: Ib02cd6b4a45e3820c4378fe5b0c7fc61fe1251e7
* HTMLFormFieldTest: Add more tests about field clonerFunc2022-02-081-1/+71
| | | | Change-Id: Ie8539ec2fdfc29b166737f9715ed05b7abf3316f
* HTMLFormField: Make the behavior of cond-state consistent between client and ↵Func2022-02-071-19/+115
| | | | | | | | | | | | | | server Old codes relied on some assumptions, so: * When a "key in form descriptor" is provided, the 'name' param can't be set otherwise the js wouldn't be able to find it. * When a "name for submission" (with 'wp' prefix or same as the 'name' param) is provided, it works on the client-side but something might be broken on the server-side. Since the documented usage is to use "key in form descriptor" and most use case is fine, the use of "name for submission" is explicitly disallowed here. Use cases simply with the 'wp' prefix would still keep working on both sides though. Depends-On: I27fd8fa9643d611b37e3f47e77b698245814d539 Change-Id: I9a42417a6161f42181badd8cdbec81ba85dc62f6
* HTMLFormField: Bypass the inverting logic of HTMLCheckField for disable-if ↵Func2022-02-011-1/+1
| | | | | | | | | | | and hide-if Values loaded from the default wouldn't be inverted, there is no need to copy the conditions to here, we can just simply bypass them. Fortunately, nothing can be affected in a normal use case, since all value of fields would be set to server. Thanks to the newly added tests, which helped me to realize this problem. Change-Id: I5589ba7383587afdd9307c79e88849dacee02706
* HTMLFormFieldTest: Use mFieldData for check of valuesFunc2022-02-011-43/+43
| | | | | | | | Fields can have some filter to process the data, for example, HTMLCheckField would return true rather than raw string '1', we should also test this. Note that the param indicating 'checked' state is matching the state on client-side, the value would be inverted by HTMLCheckField... Change-Id: Ia9a7a8c46b0a55ecf2d5378a0d0b6cc00cdb54eb
* HTMLFormField: Split out the validation of cond-state paramsFunc2022-01-281-1/+1
| | | | | | Follow-up changes will use cond-state params in other functions, split this out to make sure it's validated. Change-Id: Icf358794b11a8f986fbd02c8f1b15ea9d1ef4d15
* Add tests for HTMLFormField 'hide-if' / 'disable-if' functionalityBartosz Dziewoński2022-01-281-0/+260
| | | | | | (Test scaffolding code copied from HTMLRestrictionsFieldTest) Change-Id: I9d221059813a6ac362e3e070984abcaae57906dc
* Rename HTMLForm::[get|set|add]*Text() methodsGergő Tisza2022-01-021-0/+7
| | | | | | | | | | | | | | | | Rename HTMLForm::[get|set|add][Pre|Post|Header|Footer]Text() to HTMLForm::[get|set|add][Pre|Post|Header|Footer]Html() and deprecate the old methods. Their arguments are rendered as raw HTML so the old name was misleading. Some of these are marked as stable to override and theoretically the renaming could cause problems if callers are updated to the new name while the overriding class is still using the old name, but the only case known to codesearch is OOUIHTMLForm which is also updated here. Bug: T290771 Change-Id: I2c269eb6ab2b320fa2eef4ee8a226e96ad05fbe2
* Remove or replace usages of "sanity"Reedy2021-11-211-1/+0
| | | | | | | Still some more to go... Bug: T254646 Change-Id: Ia117f01e443c35b4765f3275cab4f2707e1be96f
* Tests: Mark more more closures as staticUmherirrender2021-02-091-1/+1
| | | | | | | Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
* Update wikimedia/ip-utils from 1.0.0 to 3.0.1Reedy2021-01-261-1/+1
| | | | | | | Bug: T247212 Bug: T248237 Depends-On: Iaa520a50498c4d1d4514874fbe6f72aa0f76ccb8 Change-Id: I155024341e8e6b13240e37b30c31b95dc83a47e0
* Make unit tests assertion about assertNotEquals more strictUmherirrender2020-11-011-2/+2
| | | | | | | Originally an autofix of PHPUnitAssertEquals sniff, but manually updated. Change-Id: I78efc6f7997f0b7227b40d7eab1495cc7a1d7da5
* MediaWikiTestCase to MediaWikiIntegrationTestCaseaddshore2020-06-302-2/+2
| | | | | | | | | | | | | 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
* HTMLForm: Allow status object to have raw parametersFlorian2020-02-091-1/+16
| | | | | | | | | | | | | | | | The status object, which can be returned after validating an HTMLForm, can contain message objects. These message objects can be constructed with the full feature set provided by Message, e.g. raw parameters. The handling of these status objects in HTMLForm basically prevented some features of the Message object in the status, as it parsed the messages through the Parser, which does not recognize these raw parameters as such and escapes them wrongly. This behaviour is fixed with this change. Bug: T240774 Change-Id: I152ec51f317799572bf6791e110cd72c42da82a0
* Stop using assertContains with string haystackDaimona Eaytoy2019-12-151-4/+4
| | | | | | | | This was done automatically by replacing every assertContains with string *needle*. Then verifying the results. Bug: T192167 Change-Id: Id8cbbf3b01e948f80046714183cc299f86be21fd
* phpcs: Enable ↵James D. Forrester2019-10-142-6/+3
| | | | | | MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedException* and make pass Change-Id: I63f97497714a32236268be6965c5e181dade6c58
* Add public as visibility in tests folderUmherirrender2019-10-101-3/+3
| | | | | | | Add public, protected or private to function missing a visibility Enable the tests folder for the phpcs sniff Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
* Load GlobalFunctions.php to tests/phpunit/bootstrap.phpAmir Sarabadani2019-07-141-104/+0
| | | | | | | That mostly enables testing global functions Bug: T87781 Change-Id: Ib42c56a67926ebcdba53f4c6c54a5bff98cb77a3
* Revert "Separate MediaWiki unit and integration tests"Legoktm2019-06-134-0/+304
| | | | | | | | This reverts commit 0a2b996278e57a8b8c5377cd3a3eaa54f993d4a9. Reason for revert: Broke postgres tests. Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1