Example #1
0
    public function testGetSet()
    {
        $obj = new Payload('application/json');
        $obj = new Payload('application/json', '{"name":"aaron"}');
        $this->assertSame('application/json', $obj->getContentType());
        $this->assertSame('{"name":"aaron"}', $obj->getContent());
        $subject = <<<EOD
{ "collection" : 
  {
    "version" : "1.0",
    "href" : "http://example.org/friends/"
  } 
}    
EOD;
        $obj->setContentType('application/vnd.collection+json');
        $obj->setContent($subject);
        $this->assertSame('application/vnd.collection+json', $obj->getContentType());
        $this->assertSame($subject, $obj->getContent());
    }
 /**
  * Method to produce and return a consistent Payload object.
  *
  * Use this when a translation fails.
  *
  * @param  \AKlump\Http\Transfer\Payload $payload [description]
  *
  * @return \AKlump\Http\Transfer\Payload A new payload containing a failure message.
  */
 public static function failedTranslation($payload)
 {
     $obj = new Payload('text/error');
     $obj->setContent('Unable to recognize/translate mime type: ' . $payload->getContentType());
     return $obj;
 }