|
2 | 2 |
|
3 | 3 | namespace TraderInteractive\Api; |
4 | 4 |
|
5 | | -use ArrayObject; |
| 5 | +use Fig\Http\Message\StatusCodeInterface as StatusCodes; |
6 | 6 | use SubjectivePHP\Psr\SimpleCache\InMemoryCache; |
7 | 7 | use DominionEnterprises\Util\Arrays; |
8 | 8 | use DominionEnterprises\Util\Http; |
@@ -585,7 +585,6 @@ function (RequestInterface $request) { |
585 | 585 | if ($request->getMethod() === 'DELETE' |
586 | 586 | && (string)$request->getUri() === 'baseUrl/v1/resource+name/the+id' |
587 | 587 | && $request->getHeaders() === [ |
588 | | - 'Content-Type' => ['application/json'], |
589 | 588 | 'Accept-Encoding' => ['gzip'], |
590 | 589 | 'Authorization' => ['Bearer a token'], |
591 | 590 | ] |
@@ -967,6 +966,37 @@ function (RequestInterface $request) { |
967 | 966 | $this->assertSame(['a body'], $client->index('foos')->getResponse()); |
968 | 967 | } |
969 | 968 |
|
| 969 | + /** |
| 970 | + * @test |
| 971 | + * @covers ::send |
| 972 | + * @covers ::startSend |
| 973 | + */ |
| 974 | + public function startSendDoesNotAddContentTypeHeaderIfNoJsonIsGiven() |
| 975 | + { |
| 976 | + $adapter = new FakeAdapter( |
| 977 | + function (RequestInterface $request) { |
| 978 | + if (substr($request->getUri(), -5) === 'token') { |
| 979 | + return new Psr7Response( |
| 980 | + StatusCodes::STATUS_OK, |
| 981 | + ['Content-Type' => ['application/json']], |
| 982 | + json_encode(['access_token' => 'a token', 'expires_in' => 1]) |
| 983 | + ); |
| 984 | + } |
| 985 | + |
| 986 | + $this->assertSame('GET', $request->getMethod()); |
| 987 | + $this->assertSame('baseUrl/v1/feeds/123/transport', (string)$request->getUri()); |
| 988 | + $this->assertSame('', (string)$request->getBody()); |
| 989 | + $this->assertSame([], $request->getHeader('Content-Type')); |
| 990 | + return new Psr7Response(StatusCodes::STATUS_OK); |
| 991 | + } |
| 992 | + ); |
| 993 | + |
| 994 | + $client = new Client($adapter, $this->getAuthentication(), 'baseUrl/v1'); |
| 995 | + |
| 996 | + $response = $client->send('GET', 'feeds/123/transport'); |
| 997 | + $this->assertSame(StatusCodes::STATUS_OK, $response->getHttpCode()); |
| 998 | + } |
| 999 | + |
970 | 1000 | private function getAuthentication() : Authentication |
971 | 1001 | { |
972 | 1002 | return Authentication::createClientCredentials('not under test', 'not under test'); |
|
0 commit comments