Commit graph

12 commits

Author SHA1 Message Date
thiemowmde
ab1e3a66e7 Make use of the [ ... ] operator instead of array_merge
The array spread operator is documented to behave identical to
array_merge. The syntax is just much shorter and easier to read in
situations like this, in my opinion.

Change-Id: I3b016e896e552af53d87d5e72436dc4e29070ce1
2024-01-31 15:47:44 +01:00
jenkins-bot
395d6211f0 Merge "api: include parameter name in error details for toomanyvalues error" 2023-06-03 17:26:20 +00:00
Siddharth VP
2133ec291b api: include parameter name in error details for toomanyvalues error
Bug: T258469
Change-Id: I95b9fb1e7ba8d4897f6bd83f1d64ffd72220b7e2
2023-06-03 17:39:08 +05:30
Derick Alangi
e687e353d1 ParamValidator: Throw exception if there is a type to value mismatch
When qery param type is defined as a string but given in URL as value in
the form of an array/list like: `q[0]=x` or `q[0]=x&q[1]=y`, clearly that
is a type to value mismatch and the framework should throw and let the client
know that this is a bad request.

Previously, the system will attempt a search using the array value which
will return incorrect result that match the search. Also, since there
are so many places where this is called, we needed to fix this in the
ParamValidator itself (as an edge case).

NOTE: If an array needs to be used as the value of the query parameter,
then ParamValidator::PARAM_ISMULTI should be set to true.

Bug: T326764
Change-Id: I507e5c4725b63d652771517ecd127da81082db31
2023-05-29 15:00:58 +03:00
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
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
2023-03-24 02:53:57 +00:00
Umherirrender
8170da2516 tests: Remove assertion of spec in ParamValidatorTest::testGetTypeDef
Creation of dynamic property Mock_TypeDef_90a9d0fe::$spec is deprecated
in php8.2

Bug: T314099
Change-Id: If7b8a99cf7e7b94d9d2ff857948f874ccf3f1d37
2023-01-06 04:01:09 +01:00
Alexander Vorwerk
9b09bf3112 Use updated ObjectFactory namespace
Depends-On: I99c5e5664d2401c36a9890f148eba7c25e6e8324
Depends-On: I48ab818b2965da14af15ef370aa83ad9455badd9
Depends-On: I018371e4b77911e56152ca7b2df734afc73f58a5
Change-Id: I04ebdb52102f6191d49a9cc70b1f98308299e72f
2022-03-09 23:04:51 +00:00
Timo Tijhof
8d406bbcd6 phpcs: Disable Generic.Files.LineLength for test files
There is a common and reasonable need for longer lines in tests.
The nudge for shorter lines doesn't seem valuable here. The natural
breaks will likely still fall in 80-100 given the enforced practice
for non-test code, e.g. whether through habit, or 80-100 column markers
in text editors, or the finite width of diff and code review
interfaces.

Change-Id: I879479e13551789a67624ce66f0946d2f185e6ee
2022-02-18 18:32:05 +00:00
Reedy
6e29611642 Remove or replace usages of "sanity"
Still some more to go...

Bug: T254646
Change-Id: Ia117f01e443c35b4765f3275cab4f2707e1be96f
2021-11-21 16:42:31 +00:00
libraryupgrader
5357695270 build: Updating dependencies
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
2021-07-22 03:36:05 +00:00
Daimona Eaytoy
535d7abf59 phpunit: Mass-replace setMethods with onlyMethods and adjust
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
2021-04-16 20:15:00 +02:00
DannyS712
ec3d351c62 Move most ParamValidator tests to unit tests
No integration needed, except for maybe in
the tests for the UploadedFile* classes, which
are left where they are for now - those tests
deal with the file system.

Change-Id: I4f38557d524b2d36dea36a926d0f31e1afed5c7a
2021-04-14 23:57:20 +00:00
Renamed from tests/phpunit/includes/libs/ParamValidator/ParamValidatorTest.php (Browse further)