/**
  * @depends testSetNumItemsSetsNumItems
  */
 public function testNumItemsReturnsNumItems()
 {
     $this->objectList->setNumItems(2);
     $this->assertEquals(2, $this->objectList->getNumItems());
     $this->objectList->setNumItems(3);
     $this->assertEquals(3, $this->objectList->getNumItems());
 }
 /**
  * @dataProvider getContentChangesDataProvider
  * @param string $expectedUrl
  * @param string $repositoryId
  * @param string|null $changeLogToken
  * @param boolean $includeProperties
  * @param boolean $includePolicyIds
  * @param boolean $includeAcl
  * @param integer|null $maxItems
  */
 public function testGetContentChangesReturnObjectList($expectedUrl, $repositoryId, $changeLogToken = null, $includeProperties = false, $includePolicyIds = false, $includeAcl = false, $maxItems = null)
 {
     $responseData = $this->getResponseFixtureContentAsArray('Cmis/v1.1/BrowserBinding/getContentChanges-response.log');
     $responseMock = $this->getMockBuilder('\\GuzzleHttp\\Message\\Response')->disableOriginalConstructor()->setMethods(array('json'))->getMock();
     $responseMock->expects($this->once())->method('json')->willReturn($responseData);
     $dummyObjectData = new ObjectData();
     $jsonConverterMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Converter\\JsonConverter')->setMethods(array('convertObject'))->getMock();
     $expectedNumberOfItems = 39;
     $jsonConverterMock->expects($this->exactly($expectedNumberOfItems))->method('convertObject')->willReturn($dummyObjectData);
     $cmisBindingsHelperMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Bindings\\CmisBindingsHelper')->setMethods(array('getJsonConverter'))->getMock();
     $cmisBindingsHelperMock->expects($this->once())->method('getJsonConverter')->willReturn($jsonConverterMock);
     /** @var DiscoveryService|PHPUnit_Framework_MockObject_MockObject $discoveryService */
     $discoveryService = $this->getMockBuilder(self::CLASS_TO_TEST)->setConstructorArgs(array($this->getSessionMock(), $cmisBindingsHelperMock))->setMethods(array('getRepositoryUrl', 'read'))->getMock();
     $discoveryService->expects($this->once())->method('getRepositoryUrl')->with($repositoryId)->willReturn(Url::createFromUrl(self::BROWSER_URL_TEST));
     $discoveryService->expects($this->once())->method('read')->with($expectedUrl)->willReturn($responseMock);
     $expectedObjectList = new ObjectList();
     $expectedObjectList->setObjects(array_fill(0, $expectedNumberOfItems, new ObjectData()));
     $expectedObjectList->setNumItems($expectedNumberOfItems);
     $expectedObjectList->hasMoreItems(false);
     $this->assertEquals($expectedObjectList, $discoveryService->getContentChanges($repositoryId, $changeLogToken, $includeProperties, $includePolicyIds, $includeAcl, $maxItems));
 }
 public function testConvertQueryResultListConvertsArrayToObjectList()
 {
     /** @var  PHPUnit_Framework_MockObject_MockObject|JsonConverter $jsonConverterMock */
     $jsonConverterMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Converter\\JsonConverter')->setMethods(array('convertObject'))->getMock();
     $response = $this->getResponseFixtureContentAsArray('Cmis/v1.1/BrowserBinding/doQuery-response.log');
     $dummyObjectData = new ObjectData();
     $expectedNumberOfItems = 4;
     $jsonConverterMock->expects($this->exactly($expectedNumberOfItems))->method('convertObject')->willReturn($dummyObjectData);
     $expectedObjectList = new ObjectList();
     $expectedObjectList->setObjects(array_fill(0, $expectedNumberOfItems, new ObjectData()));
     $expectedObjectList->setNumItems($expectedNumberOfItems);
     $expectedObjectList->hasMoreItems(false);
     $this->assertEquals($expectedObjectList, $jsonConverterMock->convertQueryResultList($response));
 }
 /**
  * Convert given input data array from query result to a ObjectList object
  *
  * @param array|null $data
  * @return null|ObjectList
  */
 public function convertQueryResultList(array $data = null)
 {
     if (empty($data)) {
         return null;
     }
     $objectList = new ObjectList();
     $objects = array();
     if (isset($data[JSONConstants::JSON_QUERYRESULTLIST_RESULTS])) {
         foreach ((array) $data[JSONConstants::JSON_QUERYRESULTLIST_RESULTS] as $objectData) {
             $object = $this->convertObject($objectData);
             if ($object !== null) {
                 $objects[] = $object;
             }
         }
     }
     $objectList->setObjects($objects);
     if (isset($data[JSONConstants::JSON_QUERYRESULTLIST_HAS_MORE_ITEMS])) {
         $objectList->setHasMoreItems((bool) $data[JSONConstants::JSON_QUERYRESULTLIST_HAS_MORE_ITEMS]);
     }
     if (isset($data[JSONConstants::JSON_QUERYRESULTLIST_NUM_ITEMS])) {
         $objectList->setNumItems((int) $data[JSONConstants::JSON_QUERYRESULTLIST_NUM_ITEMS]);
     }
     $objectList->setExtensions($this->convertExtension($data, JSONConstants::getQueryResultListKeys()));
     return $objectList;
 }