Commit graph

6 commits

Author SHA1 Message Date
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
Lucas Werkmeister
766120ce92 Call TestCase::fail() more carefully in MockHttpTrait
If we directly pass [ TestCase::class, 'fail' ] as the callback for a
mock method, then the method will be called with whatever arguments the
caller tried to pass to the original method. Those arguments may not be
compatible with TestCase::fail()’s signature, which requires the first
argument to be a string (or absent). Use a custom callback first which
throws away any arguments before calling TestCase::fail().

Bug: T272998
Change-Id: I3514d3d29355a55a5ca10ccc22981e3972347f35
2021-01-27 15:58:52 +01:00
Lucas Werkmeister
f406c5872e Allow more calls in MockHttpTrait
Don’t fail the test immediately when createMultiClient() or
createGuzzleClient() is called – instead, return service instances that
will fail the test as soon as any method is called on them. This is a
bit friendlier for dependency injection.

Bug: T272998
Change-Id: I79f90ef028867920f6a228991eda59ed4aeadb62
2021-01-27 11:51:28 +01:00
Umherirrender
86ea6965d3 Add missing @param/@return to MockHttpTrait
Change-Id: I38cb2e0e7f7a0f6a0199670f7aa56a1522d6628c
2020-12-19 07:21:51 +00:00
daniel
78e2089140 PHPUnit tests: prevent real Guzzle requests from tests.
Per I1702c11928f8760, tests should fail when trying to make a
HTTP request, unless they have explicitely defined the desired
response.

This patch implements the same behavior for the newly introduced
createGuzzleClient() method.

Bug: T263816
Bug: T262443
Change-Id: Ie3c2efb1387ecc5bc29ff1749cae4bb33e636e9f
2020-10-26 23:03:36 +01:00
daniel
383a6e2a42 Introduce MockHttpTrait
MockHttpTrait can be used by tests that need to simulate HTTP requests.

Bug: T262443
Needed-By: I1832cb1858ef4cf42ec34cb7fda509ce5b951c27
Needed-By: I390856b4609635cee22253071f21ce63ff716791
Needed-By: Iff24b55dfaf7a4e02a4c80aaeaf0366de5660ef1
Needed-By: Ia8213725839e4b697c4985060bc35593fea622bc
Change-Id: I8ce17da7315b87b8dd0e502e601b9ac488089456
2020-09-28 20:28:43 +00:00