Skip to content

Commit

Permalink
Added failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
robvanaarle committed Jul 12, 2023
1 parent 32ce665 commit c38d6de
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/BaseClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,35 @@ public function testRequestAddsProducesAsAcceptHeader()
$this->assertEquals('application/vnd.retailer.v10+pdf', $actualOptions['headers']['Accept']);
}

public function testRequestAddsConsumesAsContentTypeHeader()
{
$this->authenticateByClientCredentials();

$model = new $this->modelClass();
$model->foo = 'bar';

$actualOptions = null;
$response = Message::parseResponse(file_get_contents(__DIR__ . '/Fixtures/http/200-string'));
$this->httpClientMock
->expects($this->once())
->method('request')
->willReturnCallback(function ($method, $uri, $options) use ($response, &$actualOptions) {
$actualOptions = $options;
return $response;
});

$this->client->request('POST', 'foobar', [
'body' => $model,
'consumes' => 'application/vnd.retailer.vxx+json'
], [
'200' => 'string'
]);

$this->assertArrayHasKey('headers', $actualOptions);
$this->assertArrayHasKey('Accept', $actualOptions['headers']);
$this->assertEquals('application/vnd.retailer.vxx+json', $actualOptions['headers']['Content-Type']);
}

public function testRequestJsonEncodesBodyModelIntoBody()
{
$this->authenticateByClientCredentials();
Expand Down

0 comments on commit c38d6de

Please sign in to comment.