Skip to content
Permalink
Browse files

Add tests

  • Loading branch information...
dereuromark committed Sep 23, 2018
1 parent 5262d0d commit 78340f5fa64faae2a69f54dd061fbc43b73aa245
Showing with 28 additions and 4 deletions.
  1. +4 −4 src/Http/Response.php
  2. +24 −0 tests/TestCase/Http/ResponseTest.php
@@ -1111,7 +1111,7 @@ public function type($contentType = null)
{
deprecationWarning(
'Response::type() is deprecated. ' .
'Use getType(), setType() or withType() instead.'
'Use setTypeMap(), getType() or withType() instead.'
);
if ($contentType === null) {
@@ -1138,17 +1138,17 @@ public function type($contentType = null)
}
/**
* Sets a content type into the map.
* Sets a content type definition into the map.
*
* E.g.: setType('xhtml' => ['application/xhtml+xml', 'application/xhtml', 'text/xhtml'])
* E.g.: setType('xhtml' => ['application/xhtml+xml', 'application/xhtml'])
*
* This is needed for RequestHandlerComponent and recognition of types.
*
* @param string $type Content type.
* @param string|array $mimeType Definition of the mime type.
* @return void
*/
public function setType($type, $mimeType)
public function setTypeMap($type, $mimeType)
{
$this->_mimeTypes[$type] = $mimeType;
}
@@ -265,6 +265,30 @@ public function testGetType()
);
}
/**
* @return void
*/
public function testSetTypeMap()
{
$response = new Response();
$response->setTypeMap('ical', 'text/calendar');
$response = $response->withType('ical')->getType();
$this->assertEquals('text/calendar', $response);
}
/**
* @return void
*/
public function testSetTypeMapAsArray()
{
$response = new Response();
$response->setTypeMap('ical', ['text/calendar']);
$response = $response->withType('ical')->getType();
$this->assertEquals('text/calendar', $response);
}
/**
* Tests the withType method
*

0 comments on commit 78340f5

Please sign in to comment.
You can’t perform that action at this time.