Skip to content

Commit db945d2

Browse files
[HttpClient] Add default base_uri to MockHttpClient
1 parent 731af83 commit db945d2

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

MockHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MockHttpClient implements HttpClientInterface
3434
/**
3535
* @param callable|callable[]|ResponseInterface|ResponseInterface[]|iterable|null $responseFactory
3636
*/
37-
public function __construct($responseFactory = null, string $baseUri = null)
37+
public function __construct($responseFactory = null, ?string $baseUri = 'https://example.com')
3838
{
3939
if ($responseFactory instanceof ResponseInterface) {
4040
$responseFactory = [$responseFactory];

Tests/MockHttpClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MockHttpClientTest extends HttpClientTestCase
2727
*/
2828
public function testMocking($factory, array $expectedResponses)
2929
{
30-
$client = new MockHttpClient($factory, 'https://example.com/');
30+
$client = new MockHttpClient($factory);
3131
$this->assertSame(0, $client->getRequestsCount());
3232

3333
$urls = ['/foo', '/bar'];
@@ -126,7 +126,7 @@ public function validResponseFactoryProvider()
126126
*/
127127
public function testTransportExceptionThrowsIfPerformedMoreRequestsThanConfigured($factory)
128128
{
129-
$client = new MockHttpClient($factory, 'https://example.com/');
129+
$client = new MockHttpClient($factory);
130130

131131
$client->request('POST', '/foo');
132132
$client->request('POST', '/foo');

Tests/ScopingHttpClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testMatchingUrlsAndOptions()
9191

9292
public function testForBaseUri()
9393
{
94-
$client = ScopingHttpClient::forBaseUri(new MockHttpClient(), 'http://example.com/foo');
94+
$client = ScopingHttpClient::forBaseUri(new MockHttpClient(null, null), 'http://example.com/foo');
9595

9696
$response = $client->request('GET', '/bar');
9797
$this->assertSame('http://example.com/foo', implode('', $response->getRequestOptions()['base_uri']));

0 commit comments

Comments
 (0)