/** * @depends testSetNumItemsSetsNumItems */ public function testNumItemsReturnsNumItems() { $this->objectInFolderList->setNumItems(2); $this->assertEquals(2, $this->objectInFolderList->getNumItems()); $this->objectInFolderList->setNumItems(3); $this->assertEquals(3, $this->objectInFolderList->getNumItems()); }
public function testConvertObjectInFolderListConvertsArrayToObjectInFolderList() { /** @var PHPUnit_Framework_MockObject_MockObject|JsonConverter $jsonConverterMock */ $jsonConverterMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Converter\\JsonConverter')->setMethods(array('convertObjectInFolder'))->getMock(); $dummyObjectInFolderData = new ObjectInFolderData(); $expectedNumberOfItems = 5; $jsonConverterMock->expects($this->exactly($expectedNumberOfItems))->method('convertObjectInFolder')->willReturn($dummyObjectInFolderData); $expectedObjectInFolderList = new ObjectInFolderList(); $expectedObjectInFolderList->setNumItems($expectedNumberOfItems); $expectedObjectInFolderList->setHasMoreItems(false); $expectedObjectInFolderList->setObjects(array_fill(0, $expectedNumberOfItems, new ObjectInFolderData())); $response = $this->getResponseFixtureContentAsArray('Cmis/v1.1/BrowserBinding/getChildren-response.log'); $this->assertEquals($expectedObjectInFolderList, $jsonConverterMock->convertObjectInFolderList($response)); }
/** * Convert given input data to a ObjectInFolderList object * * @param array|null $data * @return null|ObjectInFolderList */ public function convertObjectInFolderList(array $data = null) { if (empty($data)) { return null; } $objectInFolderList = new ObjectInFolderList(); $objects = array(); if (isset($data[JSONConstants::JSON_OBJECTINFOLDERLIST_OBJECTS])) { foreach ((array) $data[JSONConstants::JSON_OBJECTINFOLDERLIST_OBJECTS] as $objectInFolderData) { if (!empty($objectInFolderData)) { $object = $this->convertObjectInFolder($objectInFolderData); if ($object !== null) { $objects[] = $object; } } } } $objectInFolderList->setObjects($objects); if (isset($data[JSONConstants::JSON_OBJECTINFOLDERLIST_HAS_MORE_ITEMS])) { $objectInFolderList->setHasMoreItems((bool) $data[JSONConstants::JSON_OBJECTINFOLDERLIST_HAS_MORE_ITEMS]); } if (isset($data[JSONConstants::JSON_OBJECTINFOLDERLIST_NUM_ITEMS])) { $objectInFolderList->setNumItems((int) $data[JSONConstants::JSON_OBJECTINFOLDERLIST_NUM_ITEMS]); } $objectInFolderList->setExtensions($this->convertExtension($data, JSONConstants::getObjectInFolderListKeys())); return $objectInFolderList; }