Exemplo n.º 1
0
 public function testMetadataConversion()
 {
     $tabOpenable = $this->doublesManager->createTabOpenable('/url/des/tabs', 'label des Tabs');
     $request = $this->doublesManager->createHTTPRequest('POST', '/entities/persons');
     $response = new ServiceResponse(Service::OK, (object) array('ok' => 'true'), 'json');
     $response->setMetadata(MetadataGenerator::create()->openTab($tabOpenable));
     $httpResponse = $this->converter->fromService($response, $request);
     $this->assertInstanceof('Psc\\Net\\HTTP\\Response', $httpResponse);
     $this->assertTrue($httpResponse->hasHeaderField('X-Psc-Cms-Meta'));
 }
Exemplo n.º 2
0
 public function testCreateMethod()
 {
     $response = $this->createServiceResponse(Service::OK);
     $this->assertEquals($response, ServiceResponse::create());
 }
Exemplo n.º 3
0
 /**
  * @return list($format, $mimeContentType)
  */
 public function decideFormat(ServiceResponse $response, Request $request)
 {
     if ($response->getFormat() !== NULL) {
         $format = $response->getFormat();
     } elseif ($request->accepts('application/json')) {
         $format = ServiceResponse::JSON;
     } else {
         $format = ServiceResponse::HTML;
     }
     return array($format, $this->getContentType($format));
 }