/** * @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; }