public function setUp()
 {
     $this->sessionMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\SessionInterface')->setMethods(array('getTypeDefinition'))->getMockForAbstractClass();
     $this->objectTypeDefinitionMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Data\\ObjectTypeInterface')->getMockForAbstractClass();
     $this->sessionMock->expects($this->any())->method('getTypeDefinition')->willReturn($this->objectTypeDefinitionMock);
     $this->objectTypeHelperTrait = $this->getMockBuilder('\\Dkd\\PhpCmis\\DataObjects\\ObjectTypeHelperTrait')->getMockForTrait();
     $this->setProtectedProperty($this->objectTypeHelperTrait, 'session', $this->sessionMock);
 }
 /**
  * @covers \Dkd\PhpCmis\DataObjects\RelationshipType::__construct
  */
 public function setUp()
 {
     $this->sessionMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\SessionInterface')->setMethods(array('getTypeDefinition'))->getMockForAbstractClass();
     $this->objectTypeDefinitionMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Data\\ObjectTypeInterface')->getMockForAbstractClass();
     $this->sessionMock->expects($this->any())->method('getTypeDefinition')->willReturn($this->objectTypeDefinitionMock);
     $errorReportingLevel = error_reporting(E_ALL & ~E_USER_NOTICE);
     $this->relationshipType = new RelationshipType($this->sessionMock, new RelationshipTypeDefinition('typeId'));
     error_reporting($errorReportingLevel);
 }
 /**
  * Returns the content URL of the rendition if the binding supports content
  * URLs.
  *
  * Depending on the repository and the binding, the server might not return
  * the content but an error message. Authentication data is not attached.
  * That is, a user may have to re-authenticate to get the content.
  *
  * @return string|null the content URL of the rendition or <code>null</code> if the binding
  *         does not support content URLs
  */
 public function getContentUrl()
 {
     $objectService = $this->session->getBinding()->getObjectService();
     if ($objectService instanceof LinkAccessInterface) {
         return $objectService->loadRenditionContentLink($this->session->getRepositoryInfo()->getId(), $this->objectId, $this->getStreamId());
     }
     return null;
 }
 /**
  * @param SessionInterface $session
  * @param ObjectDataInterface $objectData
  */
 public function __construct(SessionInterface $session, ObjectDataInterface $objectData)
 {
     $objectFactory = $session->getObjectFactory();
     $properties = $objectData->getProperties();
     // handle properties
     if (!empty($properties)) {
         $queryProperties = $objectFactory->convertQueryProperties($properties);
         foreach ($queryProperties as $queryProperty) {
             if ($queryProperty->getId() !== null) {
                 $this->propertiesById[$queryProperty->getId()] = $queryProperty;
             }
             if ($queryProperty->getQueryName() !== null) {
                 $this->propertiesByQueryName[$queryProperty->getQueryName()] = $queryProperty;
             }
         }
     }
     // handle allowable actions
     $allowableActions = $objectData->getAllowableActions();
     if ($allowableActions !== null) {
         $this->allowableActions = $allowableActions;
     }
     // handle relationships
     $relationshipsObjectData = $objectData->getRelationships();
     foreach ($relationshipsObjectData as $relationshipObjectData) {
         $relationship = $objectFactory->convertObject($relationshipObjectData, $session->getDefaultContext());
         if ($relationship instanceof RelationshipInterface) {
             $this->relationships[] = $relationship;
         }
     }
     // handle renditions
     $renditionsData = $objectData->getRenditions();
     foreach ($renditionsData as $renditionData) {
         $rendition = $objectFactory->convertRendition($objectData->getId(), $renditionData);
         if ($rendition instanceof RenditionInterface) {
             $this->renditions[] = $rendition;
         }
     }
 }
 public function testGetContentStreamReturnsStream()
 {
     $streamId = 'bar';
     $objectId = 'foo';
     /** @var  RepositoryInfoInterface|PHPUnit_Framework_MockObject_MockObject $repositoryInfoMock */
     $repositoryInfoMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Data\\RepositoryInfoInterface')->setMethods(array('getId'))->getMockForAbstractClass();
     $repositoryInfoMock->expects($this->any())->method('getId')->willReturn('repositoryId');
     $streamMock = $this->getMockBuilder('\\GuzzleHttp\\Stream\\StreamInterface')->getMockForAbstractClass();
     $objectServiceMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Bindings\\Browser\\ObjectService')->setMethods(array('getContentStream'))->disableOriginalConstructor()->getMockForAbstractClass();
     $objectServiceMock->expects($this->once())->method('getContentStream')->with($repositoryInfoMock->getId(), $objectId, $streamId)->willReturn($streamMock);
     $bindingMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Bindings\\CmisBindingInterface')->setMethods(array('getObjectService'))->disableOriginalConstructor()->getMockForAbstractClass();
     $bindingMock->expects($this->once())->method('getObjectService')->willReturn($objectServiceMock);
     $this->sessionMock->expects($this->once())->method('getBinding')->willReturn($bindingMock);
     $this->sessionMock->expects($this->once())->method('getRepositoryInfo')->willReturn($repositoryInfoMock);
     $rendition = new Rendition($this->sessionMock, $objectId);
     $rendition->setStreamId($streamId);
     $this->assertSame($streamMock, $rendition->getContentStream());
 }
 /**
  * Executes the query.
  *
  * @param boolean $searchAllVersions <code>true</code> if all document versions should be included in the search
  *      results, <code>false</code> if only the latest document versions should be included in the search results
  * @param OperationContextInterface|null $context the operation context to use
  * @return QueryResultInterface[]
  */
 public function query($searchAllVersions, OperationContextInterface $context = null)
 {
     return $this->session->query($this->toQueryString(), $searchAllVersions, $context);
 }
 /**
  * Get the bindings object factory for the current session binding
  *
  * @return BindingsObjectFactoryInterface
  */
 protected function getBindingsObjectFactory()
 {
     return $this->session->getBinding()->getObjectFactory();
 }