From 89029aecac53ef12a96536411d04ac3178d509d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justinas=20Raka=C5=A1is?= Date: Mon, 16 May 2016 21:44:26 +0300 Subject: [PATCH] Mock available contentTypes to make test run as it should --- tests/Handlers/AbstractHandlerTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/Handlers/AbstractHandlerTest.php b/tests/Handlers/AbstractHandlerTest.php index c38792d29..e68728f52 100644 --- a/tests/Handlers/AbstractHandlerTest.php +++ b/tests/Handlers/AbstractHandlerTest.php @@ -15,11 +15,23 @@ class AbstractHandlerTest extends \PHPUnit_Framework_TestCase public function testHalfValidContentType() { $req = $this->getMockBuilder('Slim\Http\Request')->disableOriginalConstructor()->getMock(); - $req->expects($this->any())->method('getHeaderLine')->will($this->returnValue('unknown/json')); + + $req->expects($this->any())->method('getHeaderLine')->will($this->returnValue('unknown/+json')); $abstractHandler = $this->getMockForAbstractClass(AbstractHandler::class); + $newTypes = [ + 'application/xml', + 'text/xml', + 'text/html', + ]; + $class = new \ReflectionClass(AbstractHandler::class); + + $reflectionProperty = $class->getProperty('knownContentTypes'); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($abstractHandler, $newTypes); + $method = $class->getMethod('determineContentType'); $method->setAccessible(true);