Exemplo n.º 1
0
 /**
  * Returns the width in pixels if the rendition is an image.
  *
  * @return integer the width in pixels or -1 if the width is not available or the rendition is not an image
  */
 public function getWidth()
 {
     return parent::getWidth() ?: -1;
 }
 /**
  * @depends testSetRenditionDocumentIdSetsPropertyAsString
  */
 public function testGetRenditionDocumentIdReturnsPropertyValue()
 {
     $this->renditionData->setRenditionDocumentId('foo');
     $this->assertSame('foo', $this->renditionData->getRenditionDocumentId());
 }
 public function testConvertRenditionsConvertsArrayToRenditionObjects()
 {
     $expectedRendition1 = new RenditionData();
     $expectedRendition1->setStreamId('workspace://SpacesStore/8b49dd01-56bb-4980-b161-1249ac93eb72');
     $expectedRendition1->setHeight(100);
     $expectedRendition1->setWidth(100);
     $expectedRendition1->setLength(539);
     $expectedRendition1->setKind('doclib');
     $expectedRendition1->setMimeType('image/png');
     $expectedRendition1->setRenditionDocumentId('workspace://SpacesStore/8b49dd01-56bb-4980-b161-1249ac93eb73');
     $expectedRendition1->setTitle('title');
     $expectedRendition1->setExtensions($this->cmisExtensionsDummy);
     $expectedRendition2 = new RenditionData();
     $expectedRendition2->setStreamId('workspace://SpacesStore/8b49dd01-56bb-4980-b161-1249ac93eb74');
     $expectedRendition2->setHeight(100);
     $expectedRendition2->setWidth(100);
     $expectedRendition2->setLength(539);
     $expectedRendition2->setKind('doclib');
     $expectedRendition2->setMimeType('image/png');
     $expectedRendition2->setRenditionDocumentId('workspace://SpacesStore/8b49dd01-56bb-4980-b161-1249ac93eb75');
     $expectedRendition2->setTitle('title2');
     $expectedRendition2->setExtensions($this->cmisExtensionsDummy);
     $getObjectResponse = $this->getResponseFixtureContentAsArray('Cmis/v1.1/BrowserBinding/getObject-response.log');
     $result = $this->jsonConverter->convertRenditions($getObjectResponse[JSONConstants::JSON_OBJECT_RENDITIONS]);
     $this->assertEquals(array($expectedRendition1, $expectedRendition2), $result);
     return $result;
 }
Exemplo n.º 4
0
 /**
  * Convert given input data to a RenditionData object
  *
  * @param array|null $data
  * @return null|RenditionData
  */
 public function convertRendition(array $data = null)
 {
     if (empty($data)) {
         return null;
     }
     $rendition = new RenditionData();
     if (isset($data[JSONConstants::JSON_RENDITION_HEIGHT])) {
         $rendition->setHeight((int) $data[JSONConstants::JSON_RENDITION_HEIGHT]);
     }
     if (isset($data[JSONConstants::JSON_RENDITION_KIND])) {
         $rendition->setKind((string) $data[JSONConstants::JSON_RENDITION_KIND]);
     }
     if (isset($data[JSONConstants::JSON_RENDITION_LENGTH])) {
         $rendition->setLength((int) $data[JSONConstants::JSON_RENDITION_LENGTH]);
     }
     if (isset($data[JSONConstants::JSON_RENDITION_MIMETYPE])) {
         $rendition->setMimeType((string) $data[JSONConstants::JSON_RENDITION_MIMETYPE]);
     }
     if (isset($data[JSONConstants::JSON_RENDITION_DOCUMENT_ID])) {
         $rendition->setRenditionDocumentId((string) $data[JSONConstants::JSON_RENDITION_DOCUMENT_ID]);
     }
     if (isset($data[JSONConstants::JSON_RENDITION_STREAM_ID])) {
         $rendition->setStreamId((string) $data[JSONConstants::JSON_RENDITION_STREAM_ID]);
     }
     if (isset($data[JSONConstants::JSON_RENDITION_TITLE])) {
         $rendition->setTitle((string) $data[JSONConstants::JSON_RENDITION_TITLE]);
     }
     if (isset($data[JSONConstants::JSON_RENDITION_WIDTH])) {
         $rendition->setWidth((int) $data[JSONConstants::JSON_RENDITION_WIDTH]);
     }
     $rendition->setExtensions($this->convertExtension($data, JSONConstants::getRenditionKeys()));
     return $rendition;
 }