Commit graph

22 commits

Author SHA1 Message Date
DannyS712
b876af50cc Fix order of parameters in assertions
Should be expected, and then actual

Switched some assertEquals to assertSame to fix failing
phpcs sniffs

Change-Id: I7257c5afacd22fed78a58f3cc918b721ac11a46d
2021-05-03 15:50:53 +00:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
DannyS712
6a93b0ca93 More misc test cleanup
* parent::setUp() should be first, and ::tearDown()
  should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
  to /unit

Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
2020-12-24 00:52:06 +00:00
Thiemo Kreuz
5f3a92385b Fix visibility of setUp/tearDown
Change-Id: I636be48eb9f713680abac35d46091f7b49374696
2020-06-16 21:02:05 +02:00
Reedy
3b94e2af1c Narrow MediaWiki.Commenting.FunctionComment.WrongStyle
Change-Id: I95d1195f09a806910559a0c5106d472addd3dec4
2020-05-20 03:33:39 +01:00
Daimona Eaytoy
6365eaab8d Autofix 94 PHPUnit 8 compat issues
Done automatically using the master version of MW codesniffer and
running composer fix.

Bug: T192167
Change-Id: If6b40f515fde32ab5eff074a90e821c30c791827
2019-12-13 15:29:10 +01:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
Max Semenik
49a28be979 Remove CurlHttpRequestTest::testCurlConstants()
Introduced in T72570, this test doesn't make much sense wthout HHVM,
however due to it inheriting from MediaWikiTestCase it has a lot of
overhead per constant.

Change-Id: I5243c1e8272f6423682d4d560e1f453d6fbb7c4d
2019-10-12 13:50:33 -07:00
Thiemo Kreuz
bcf3e1fdd2 tests: Fix MWHttpRequestTest covering the wrong class
Change-Id: I38d138fa3cf85cb0af305633a15a615069bf02c0
2019-10-09 09:56:14 +02:00
daniel
49d20b5095 Add tests for HttpRequestFactoryTest.
This also moves several tests out of HttpTest, so they are not lost when
the deprecated Http class is removed.

Bug: T222935
Change-Id: Ib4aac96ba1a978e8b6738ed446663afc3cc8c792
2019-05-13 14:32:23 +02:00
Aryeh Gregor
9018579681 Deprecate the Http class
All methods got moved to HttpRequestFactory or MWHttpRequest or dropped.

I made the return value of the new HttpRequestFactory::request/get/post
methods null on error instead of false, so that when we drop PHP 7
support, we can use a "?string" return value. This could theoretically
change behavior of code that was switched from the old Http methods, but
probably won't. I kept the old behavior for the deprecated methods.

I changed the default value of $wgHTTPProxy from false to ''. This way
it should be usable directly without a trivial wrapper method. For the
benefit of anyone who might have set it to false in LocalSettings.php, I
also recommend casting to string just in case.

Http::$httpEngine is deprecated. Eventually it will be removed along
with the curl and PHP engines, leaving only the Guzlle engine.

I also added deprecation of MWHttpRequest::factory, which occurred in
1.31, to the release notes for 1.34. Now hopefully we can hard-deprecate
it in another couple of versions.

Bug: T214390
Change-Id: I2a316a758d793857f248bd251b90f5e9a6440e3a
2019-05-06 12:07:26 +03:00
Umherirrender
a4caa4d0c6 build: Updating mediawiki/mediawiki-codesniffer to 22.0.0
Added spaces around .
Removed empty return statement which are not required
Removed return after phpunit markTestIncomplete,
which is throwing to exit the test, no need for a return

Change-Id: I2c80b965ee52ba09949e70ea9e7adfc58a1d89ce
2018-09-16 15:51:11 +00:00
Umherirrender
69dbaf3f88 build: Updating mediawiki/mediawiki-codesniffer to 17.0.0
Change-Id: Ib494b47c54fe6354d166055b1e1b31d3583bb992
2018-03-29 21:53:10 +02:00
Timo Tijhof
14644a2fb0 phpunit: Add some @covers and @large/@medium to integration tests
- @small: single class, no I/O (unit test).
- @medium: multi-class (partial or no mocks), no I/O (unit/integration test).
- @large: multi-class, I/O allowed (integration test).

Change-Id: I09317e6dd9b0ee34b7467fbffdd07957ef55dc04
2018-03-20 09:14:34 -07:00
Umherirrender
63d96c15fd build: Updating mediawiki/mediawiki-codesniffer to 16.0.0
Change-Id: I59b59f79bbf3ce4feff3b3a20c1c31bc16370531
2018-02-17 13:29:13 +01:00
Stanislav Malyshev
3de744597e Fix invocation of MWHttpRequest::factory with one argument.
Change-Id: Ib96c2888a6fd91ca80c162a80d283f650d6fa4b9
2018-01-31 23:08:22 -08:00
Stanislav Malyshev
ebbfe592fe Create factory for MWHttpRequest
This will allow classes that need MWHttpRequest to inject HttpRequestFactory
and thus make it overridable and testable.

Also made MWHttpRequest abstract class since it doesn't implement
execute anyway. Maybe a good idea to move execute to an abstract
method?

Change-Id: I5c0e035542ff5f791a21a95ed13bed4cea6906d0
2018-01-23 11:39:02 -08:00
Umherirrender
f739a8f368 Improve some parameter docs
Add missing @return and @param to function docs and fixed some @param

Change-Id: I810727961057cfdcc274428b239af5975c57468d
2017-09-10 20:32:31 +02:00
Gergő Tisza
525bfbc8df Switch to librarized version of TestingAccessWrapper
Replaces \TestingAccessWrapper (defined in core) with
\Wikimedia\TestingAccessWrapper (defined in the composer package
wikimedia/testing-access-wrapper).

See https://gerrit.wikimedia.org/r/#/q/topic:librarize-testing-access-wrapper
for downstream patches.

The core version of the class is kept around for a while to avoid
circular dependency problems.

Bug: T163434
Change-Id: I52cc257e593da3d6c3b01a909e554a950225aec8
2017-04-20 14:15:57 +00:00
Fomafix
ce6f7faadd Remove trailing empty lines in PHP
Performed using
find . -name \*.php -exec sed -i -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' {} \;

Change-Id: I5d0627f94c73690cf3a8a453539c22c760c2aa60
2017-01-16 22:06:43 +01:00
Gergő Tisza
caf78241e1 Add integration test for MWHttpRequest user/pass options
Change-Id: I5bcb263a725e8042ee51109080d2075744fe7001
2016-12-03 23:36:09 +00:00
Gergő Tisza
1531659d25 Clean up http classes a bit
* added integration tests. We probably don't want automated tests
  to make external requests but these make manual testing more
  convenient. Documented some oddities discovered by testing.
* made ::$status, ::proxySetup() and ::getHeaderList()
  protected; they were not referenced in any gerrit-hosted extension
  and they provide no useful functionality to external callers.
  Similarly, marked ::read() and ::errorHandler() as internal
  (these are used as callbacks so can't be protected)
* removed inheritance abuse in ::execute()
* documented ::execute() as returning a StatusValue (but
  keep returning a Status for now)
* changed setCookie argument defaults to ones that make sense
* replaced MWException
* moved unit tests to the correct location
* fixed some code style issues

Change-Id: I5852fc75badc5d475ae30ec2c9376bde7024bd95
2016-11-30 19:00:44 -08:00