Esempio n. 1
0
 public function testContentIsConvertedToBestMatch()
 {
     $supportedMediaTypes = array('application/json' => 'BedRest\\TestFixtures\\Mocks\\Content\\Converter\\Dummy');
     $this->negotiator->setSupportedMediaTypes($supportedMediaTypes);
     // mock media type list
     $mediaTypeList = $this->getMock('BedRest\\Content\\Negotiation\\MediaTypeList', array(), array(), '', false);
     $mediaTypeList->expects($this->any())->method('getBestMatch')->with(array_keys($supportedMediaTypes))->will($this->returnValue('application/json'));
     $content = 'raw_data';
     $result = $this->negotiator->negotiate($content, $mediaTypeList);
     $this->assertInstanceOf('BedRest\\Content\\Negotiation\\NegotiatedResult', $result);
     $this->assertEquals('application/json', $result->contentType);
     $this->assertEquals('encoded_data', $result->content);
 }
 /**
  * @param  string|ModelInterface   $nameOrModel The script/resource process, or a view model
  * @param  null|array|\ArrayAccess $values      Values to use during rendering
  * @return string                  The script output.
  */
 public function render($nameOrModel, $values = null)
 {
     $result = $this->negotiator->negotiate($nameOrModel->getVariables(), $nameOrModel->getAccept());
     return $result;
 }