Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
Add in fix for Content-Type detection
Browse files Browse the repository at this point in the history
It wasn't factoring in things like:

`application/json; charset=UTF-8`
Now it does :)
  • Loading branch information
Brunty committed Feb 18, 2017
1 parent 8b5e17d commit aeb653b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ public function getContentType(): string

public function contentTypeIsXml(): bool
{
return $this->getContentType() === self::XML_CONTENT_TYPE;
return strpos($this->getContentType(), self::XML_CONTENT_TYPE) !== false;
}

public function contentTypeIsJson(): bool
{
return $this->getContentType() === self::JSON_CONTENT_TYPE;
return strpos($this->getContentType(), self::JSON_CONTENT_TYPE) !== false;
}

private function request(string $type, string $path, array $options = [])
Expand Down
6 changes: 6 additions & 0 deletions tests/ApiTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ public function it_asserts_the_response_is_json()
{
$this->get('/get');
$this->assertResponseWasJson();

$this->get('/response-headers?Content-Type=application/json; charset=UTF-8');
$this->assertResponseWasJson();
}

/**
Expand All @@ -216,6 +219,9 @@ public function it_asserts_the_response_is_xml()
{
$this->get('/xml');
$this->assertResponseWasXml();

$this->get('/response-headers?Content-Type=application/xml; charset=UTF-8');
$this->assertResponseWasXml();
}

/**
Expand Down

0 comments on commit aeb653b

Please sign in to comment.