diff options
author | Robin Appelman <robin@icewind.nl> | 2022-08-30 19:15:02 +0300 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2022-08-30 23:59:49 +0300 |
commit | 2094c63ccb7bb24fcfe53ac2a201d7ded4d92a0e (patch) | |
tree | b6cfa03e35d35a62d960260aa7c6ceab965524ab | |
parent | 2d681088b0bb85aa372a3cca3649335ab357fc57 (diff) |
adjusts tests for CloudIdManagercloudid-cache-20
Signed-off-by: Robin Appelman <robin@icewind.nl>
8 files changed, 86 insertions, 8 deletions
diff --git a/apps/federatedfilesharing/tests/AddressHandlerTest.php b/apps/federatedfilesharing/tests/AddressHandlerTest.php index fb78e83ea68..d95ca6fbbb3 100644 --- a/apps/federatedfilesharing/tests/AddressHandlerTest.php +++ b/apps/federatedfilesharing/tests/AddressHandlerTest.php @@ -30,8 +30,11 @@ namespace OCA\FederatedFileSharing\Tests; use OC\Federation\CloudIdManager; use OCA\FederatedFileSharing\AddressHandler; use OCP\Contacts\IManager; +use OCP\ICacheFactory; use OCP\IL10N; use OCP\IURLGenerator; +use OCP\IUserManager; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class AddressHandlerTest extends \Test\TestCase { /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */ @@ -59,7 +62,13 @@ class AddressHandlerTest extends \Test\TestCase { $this->contactsManager = $this->createMock(IManager::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->cloudIdManager = new CloudIdManager( + $this->contactsManager, + $this->urlGenerator, + $this->createMock(IUserManager::class), + $this->createMock(ICacheFactory::class), + $this->createMock(EventDispatcherInterface::class) + ); $this->addressHandler = new AddressHandler($this->urlGenerator, $this->il10n, $this->cloudIdManager); } diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php index b38fb17bf0c..0acd0d0601d 100644 --- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php @@ -38,6 +38,7 @@ use OCP\Contacts\IManager as IContactsManager; use OCP\Federation\ICloudIdManager; use OCP\Files\IRootFolder; use OCP\Http\Client\IClientService; +use OCP\ICacheFactory; use OCP\IL10N; use OCP\IRequest; use OCP\ISession; @@ -45,6 +46,7 @@ use OCP\IUserManager; use OCP\IUserSession; use OCP\Share\IManager; use OCP\Share\IShare; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class MountPublicLinkControllerTest extends \Test\TestCase { /** @var IContactsManager|\PHPUnit\Framework\MockObject\MockObject */ @@ -106,7 +108,13 @@ class MountPublicLinkControllerTest extends \Test\TestCase { $this->userSession = $this->getMockBuilder(IUserSession::class)->disableOriginalConstructor()->getMock(); $this->clientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->disableOriginalConstructor()->getMock(); $this->contactsManager = $this->createMock(IContactsManager::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->cloudIdManager = new CloudIdManager( + $this->contactsManager, + $this->createMock(IURLGenerator::class), + $this->userManager, + $this->createMock(ICacheFactory::class), + $this->createMock(EventDispatcherInterface::class) + ); $this->controller = new MountPublicLinkController( 'federatedfilesharing', $this->request, diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index e71e4215b93..6a9d724c0d5 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -40,6 +40,7 @@ use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudIdManager; use OCP\Files\File; use OCP\Files\IRootFolder; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IDBConnection; use OCP\IL10N; @@ -48,6 +49,7 @@ use OCP\IUserManager; use OCP\Share\IManager; use OCP\Share\IShare; use PHPUnit\Framework\MockObject\MockObject; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class FederatedShareProviderTest @@ -113,7 +115,13 @@ class FederatedShareProviderTest extends \Test\TestCase { //$this->addressHandler = new AddressHandler(\OC::$server->getURLGenerator(), $this->l); $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')->disableOriginalConstructor()->getMock(); $this->contactsManager = $this->createMock(IContactsManager::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->cloudIdManager = new CloudIdManager( + $this->contactsManager, + $this->createMock(IURLGenerator::class), + $this->userManager, + $this->createMock(ICacheFactory::class), + $this->createMock(EventDispatcherInterface::class) + ); $this->gsConfig = $this->createMock(\OCP\GlobalScale\IConfig::class); $this->userManager->expects($this->any())->method('userExists')->willReturn(true); diff --git a/apps/files_sharing/tests/External/CacheTest.php b/apps/files_sharing/tests/External/CacheTest.php index 0a5ea4ca231..9c718384a06 100644 --- a/apps/files_sharing/tests/External/CacheTest.php +++ b/apps/files_sharing/tests/External/CacheTest.php @@ -31,6 +31,10 @@ use OC\Federation\CloudIdManager; use OCA\Files_Sharing\Tests\TestCase; use OCP\Contacts\IManager; use OCP\Federation\ICloudIdManager; +use OCP\ICacheFactory; +use OCP\IURLGenerator; +use OCP\IUserManager; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class Cache @@ -66,7 +70,13 @@ class CacheTest extends TestCase { $this->contactsManager = $this->createMock(IManager::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->cloudIdManager = new CloudIdManager( + $this->contactsManager, + $this->createMock(IURLGenerator::class), + $this->createMock(IUserManager::class), + $this->createMock(ICacheFactory::class), + $this->createMock(EventDispatcherInterface::class) + ); $this->remoteUser = $this->getUniqueID('remoteuser'); $this->storage = $this->getMockBuilder('\OCA\Files_Sharing\External\Storage') diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 2734e3cce64..40f84d1c346 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -39,9 +39,11 @@ use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; +use OCP\ICacheFactory; use OCP\IGroupManager; use OCP\IUserManager; use OCP\Share\IShare; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\Traits\UserTrait; /** @@ -129,7 +131,13 @@ class ManagerTest extends TestCase { $this->testMountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function () { return $this->manager; - }, new CloudIdManager($this->contactsManager)); + }, new CloudIdManager( + $this->contactsManager, + $this->createMock(IURLGenerator::class), + $this->userManager, + $this->createMock(ICacheFactory::class), + $this->createMock(EventDispatcherInterface::class) + )); } private function setupMounts() { diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index ef1cd8ab959..a40876c6bfb 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -29,11 +29,14 @@ use OC\Federation\CloudIdManager; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\Contacts\IManager; use OCP\Federation\ICloudIdManager; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserSession; use OCP\Share\IShare; +use OCP\Mail\IMailer; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; class MailPluginTest extends TestCase { @@ -65,7 +68,14 @@ class MailPluginTest extends TestCase { $this->contactsManager = $this->createMock(IManager::class); $this->groupManager = $this->createMock(IGroupManager::class); $this->userSession = $this->createMock(IUserSession::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->mailer = $this->createMock(IMailer::class); + $this->cloudIdManager = new CloudIdManager( + $this->contactsManager, + $this->createMock(IURLGenerator::class), + $this->createMock(IUserManager::class), + $this->createMock(ICacheFactory::class), + $this->createMock(EventDispatcherInterface::class) + ); $this->searchResult = new SearchResult(); } diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php index 1345df13379..b9a603bc852 100644 --- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php +++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php @@ -29,11 +29,13 @@ use OC\Federation\CloudIdManager; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\Contacts\IManager; use OCP\Federation\ICloudIdManager; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; use OCP\Share\IShare; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; class RemotePluginTest extends TestCase { @@ -62,7 +64,13 @@ class RemotePluginTest extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->config = $this->createMock(IConfig::class); $this->contactsManager = $this->createMock(IManager::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->cloudIdManager = new CloudIdManager( + $this->contactsManager, + $this->createMock(IURLGenerator::class), + $this->createMock(IUserManager::class), + $this->createMock(ICacheFactory::class), + $this->createMock(EventDispatcherInterface::class) + ); $this->searchResult = new SearchResult(); } diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php index dd68abf0ecb..91c0fd81933 100644 --- a/tests/lib/Federation/CloudIdManagerTest.php +++ b/tests/lib/Federation/CloudIdManagerTest.php @@ -22,7 +22,12 @@ namespace Test\Federation; use OC\Federation\CloudIdManager; +use OC\Memcache\ArrayCache; use OCP\Contacts\IManager; +use OCP\ICacheFactory; +use OCP\IURLGenerator; +use OCP\IUserManager; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; class CloudIdManagerTest extends TestCase { @@ -30,13 +35,25 @@ class CloudIdManagerTest extends TestCase { protected $contactsManager; /** @var CloudIdManager */ private $cloudIdManager; + /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */ + private $cacheFactory; protected function setUp(): void { parent::setUp(); $this->contactsManager = $this->createMock(IManager::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->cacheFactory = $this->createMock(ICacheFactory::class); + $this->cacheFactory->method('createLocal') + ->willReturn(new ArrayCache('')); + + $this->cloudIdManager = new CloudIdManager( + $this->contactsManager, + $this->createMock(IURLGenerator::class), + $this->createMock(IUserManager::class), + $this->cacheFactory, + $this->createMock(EventDispatcherInterface::class) + ); } public function cloudIdProvider() { |