/** * Test sendResponse method with exception rendering. * * @dataProvider dataProviderForSendResponseWithExceptionInDeveloperMode */ public function testSendResponseWithExceptionInDeveloperMode($exception, $expectedResult, $assertMessage) { /** Mock all required objects. */ $this->_rendererMock->expects($this->any())->method('getMimeType')->will($this->returnValue('application/json')); $this->_rendererMock->expects($this->any())->method('render')->will($this->returnCallback(array($this, 'callbackForSendResponseTest'), $this->returnArgument(0))); $this->_appMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(true)); $this->_responseRest->setException($exception); /** Start output buffering. */ ob_start(); $this->_responseRest->sendResponse(); /** Clear output buffering. */ ob_end_clean(); $actualResponse = $this->_responseRest->getBody(); $this->assertStringStartsWith($expectedResult, $actualResponse, $assertMessage); }
/** * Test GetMimeType method. */ public function testGetMimeType() { $exceptedMimeType = 'application/xml'; $this->assertEquals($exceptedMimeType, $this->_restXmlRenderer->getMimeType(), 'Unexpected mime type.'); }