public function testGetRepositoryInfosReturnsArrayWithRepositoryInternals()
 {
     /** @var RepositoryService|PHPUnit_Framework_MockObject_MockObject $repositoryService */
     $repositoryService = $this->getMockBuilder('\\Dkd\\PhpCmis\\Bindings\\Browser\\RepositoryService')->setMethods(array('getRepositoriesInternal'))->setConstructorArgs(array($this->getSessionMock()))->getMock();
     $repositoryInfo1 = new RepositoryInfoBrowserBinding();
     $repositoryInfo1->setId('repository-id-1');
     $repositoryInfo2 = new RepositoryInfoBrowserBinding();
     $repositoryInfo2->setId('repository-id-2');
     $repositoryService->expects($this->any())->method('getRepositoriesInternal')->willReturn(array($repositoryInfo1, $repositoryInfo2));
     $this->assertSame(array($repositoryInfo1, $repositoryInfo2), $repositoryService->getRepositoryInfos());
 }
 /**
  * @dataProvider getRepositoriesInternalDataProvider
  * @param $repositoryId
  * @param $repositoryUrlCacheMock
  */
 public function testGetRepositoriesInternalReturnsArrayOfRepositoryInfos($repositoryId, $repositoryUrlCacheMock)
 {
     $jsonConverterMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Converter\\JsonConverter')->setMethods(array('convertRepositoryInfo'))->getMock();
     $repositoryInfoBrowserBinding = new RepositoryInfoBrowserBinding();
     $repositoryInfoBrowserBinding->setId('id');
     $repositoryInfoBrowserBinding->setRepositoryUrl(self::BROWSER_URL_TEST);
     $repositoryInfoBrowserBinding->setRootUrl(self::BROWSER_URL_TEST);
     $jsonConverterMock->expects($this->once())->method('convertRepositoryInfo')->willReturn($repositoryInfoBrowserBinding);
     $cmisBindingsHelperMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\Bindings\\CmisBindingsHelper')->setMethods(array('getJsonConverter'))->getMock();
     $cmisBindingsHelperMock->expects($this->any())->method('getJsonConverter')->willReturn($jsonConverterMock);
     $responseMock = $this->getMockBuilder('\\GuzzleHttp\\Message\\Response')->disableOriginalConstructor()->setMethods(array('json'))->getMock();
     $responseMock->expects($this->any())->method('json')->willReturn(array(array('valid repository info stuff')));
     /** @var PHPUnit_Framework_MockObject_MockObject|AbstractBrowserBindingService $binding */
     $binding = $this->getMockBuilder(self::CLASS_TO_TEST)->setConstructorArgs(array($this->getSessionMock(), $cmisBindingsHelperMock))->setMethods(array('getRepositoryUrlCache', 'getServiceUrl', 'read'))->getMockForAbstractClass();
     $binding->expects($this->any())->method('getRepositoryUrlCache')->willReturn($repositoryUrlCacheMock);
     $binding->expects($this->any())->method('getServiceUrl')->willReturn(self::BROWSER_URL_TEST);
     $binding->expects($this->any())->method('read')->willReturn($responseMock);
     $this->assertEquals(array($repositoryInfoBrowserBinding), $this->getMethod(self::CLASS_TO_TEST, 'getRepositoriesInternal')->invokeArgs($binding, array($repositoryId)));
 }
 /**
  * @param RepositoryCapabilities $repositoryCapabilities
  * @param AclCapabilities $aclCapabilities
  * @return RepositoryInfoBrowserBinding
  */
 protected function getExpectedRepositoryInfoObjectForFullRequest($repositoryCapabilities, $aclCapabilities)
 {
     $repositoryInfo = new RepositoryInfoBrowserBinding();
     $repositoryInfo->setId('A1');
     $repositoryInfo->setName('Apache Chemistry OpenCMIS InMemory Repository');
     $repositoryInfo->setCmisVersion(CmisVersion::cast(CmisVersion::CMIS_1_1));
     $repositoryInfo->setDescription('Apache Chemistry OpenCMIS InMemory Repository (Version: ?)');
     $repositoryInfo->setVendorName('Apache Chemistry');
     $repositoryInfo->setProductName('OpenCMIS InMemory-Server');
     $repositoryInfo->setProductVersion('?');
     $repositoryInfo->setRootFolderId('100');
     $repositoryInfo->setRepositoryUrl('http://www.example.com:8080/inmemory/browser/A1');
     $repositoryInfo->setCapabilities($repositoryCapabilities);
     $repositoryInfo->setRootUrl('http://www.example.com:8080/inmemory/browser/A1/root');
     $repositoryInfo->setAclCapabilities($aclCapabilities);
     $repositoryInfo->setLatestChangeLogToken('0');
     $repositoryInfo->setCmisVersion(CmisVersion::cast('1.1'));
     $repositoryInfo->setChangesIncomplete(true);
     $repositoryInfo->setChangesOnType(array(BaseTypeId::cast(BaseTypeId::CMIS_DOCUMENT)));
     $repositoryInfo->setPrincipalIdAnonymous('anonymous');
     $repositoryInfo->setPrincipalIdAnyone('anyone');
     $repositoryInfo->setExtensions($this->cmisExtensionsDummy);
     $extensionFeature = new ExtensionFeature();
     $extensionFeature->setId('E1');
     $extensionFeature->setUrl('http://foo.bar.baz');
     $extensionFeature->setCommonName('commonName');
     $extensionFeature->setVersionLabel('versionLabel');
     $extensionFeature->setDescription('Description');
     $extensionFeature->setFeatureData(array('foo' => 'bar'));
     $extensionFeature->setExtensions($this->cmisExtensionsDummy);
     $repositoryInfo->setExtensionFeatures(array($extensionFeature));
     return $repositoryInfo;
 }
 /**
  * @param RepositoryInfoBrowserBinding $object
  * @param array $data
  * @return RepositoryInfoBrowserBinding
  */
 protected function setRepositoryInfoValues(RepositoryInfoBrowserBinding $object, $data)
 {
     if (isset($data[JSONConstants::JSON_REPINFO_CAPABILITIES]) && is_array($data[JSONConstants::JSON_REPINFO_CAPABILITIES])) {
         $repositoryCapabilities = $this->convertRepositoryCapabilities($data[JSONConstants::JSON_REPINFO_CAPABILITIES]);
         if ($repositoryCapabilities !== null) {
             $data[JSONConstants::JSON_REPINFO_CAPABILITIES] = $repositoryCapabilities;
         } else {
             unset($data[JSONConstants::JSON_REPINFO_CAPABILITIES]);
         }
     }
     if (isset($data[JSONConstants::JSON_REPINFO_ACL_CAPABILITIES]) && is_array($data[JSONConstants::JSON_REPINFO_ACL_CAPABILITIES])) {
         $aclCapabilities = $this->convertAclCapabilities($data[JSONConstants::JSON_REPINFO_ACL_CAPABILITIES]);
         if ($aclCapabilities !== null) {
             $data[JSONConstants::JSON_REPINFO_ACL_CAPABILITIES] = $aclCapabilities;
         } else {
             unset($data[JSONConstants::JSON_REPINFO_ACL_CAPABILITIES]);
         }
     }
     if (isset($data[JSONConstants::JSON_REPINFO_CHANGES_ON_TYPE]) && is_array($data[JSONConstants::JSON_REPINFO_CHANGES_ON_TYPE])) {
         $types = array();
         foreach ($data[JSONConstants::JSON_REPINFO_CHANGES_ON_TYPE] as $type) {
             if (!empty($type)) {
                 $types[] = BaseTypeId::cast($type);
             }
         }
         $data[JSONConstants::JSON_REPINFO_CHANGES_ON_TYPE] = $types;
     }
     if (isset($data[JSONConstants::JSON_REPINFO_EXTENDED_FEATURES]) && is_array($data[JSONConstants::JSON_REPINFO_EXTENDED_FEATURES])) {
         $data[JSONConstants::JSON_REPINFO_EXTENDED_FEATURES] = $this->convertExtensionFeatures($data[JSONConstants::JSON_REPINFO_EXTENDED_FEATURES]);
     }
     if (isset($data[JSONConstants::JSON_REPINFO_CMIS_VERSION_SUPPORTED])) {
         $data[JSONConstants::JSON_REPINFO_CMIS_VERSION_SUPPORTED] = CmisVersion::cast($data[JSONConstants::JSON_REPINFO_CMIS_VERSION_SUPPORTED]);
     }
     $object->setExtensions($this->convertExtension($data, JSONConstants::getRepositoryInfoKeys()));
     $object->populate($data, array_merge(array_combine(JSONConstants::getRepositoryInfoKeys(), JSONConstants::getRepositoryInfoKeys()), array(JSONConstants::JSON_REPINFO_DESCRIPTION => 'description', JSONConstants::JSON_REPINFO_CMIS_VERSION_SUPPORTED => 'cmisVersion', JSONConstants::JSON_REPINFO_ID => 'id', JSONConstants::JSON_REPINFO_ROOT_FOLDER_URL => 'rootUrl', JSONConstants::JSON_REPINFO_NAME => 'name', JSONConstants::JSON_REPINFO_EXTENDED_FEATURES => 'extensionFeatures')), true);
     return $object;
 }