adjusts tests for CloudIdManager

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2022-08-30 18:15:02 +02:00
parent d3743392e0
commit 1626a56dda
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
9 changed files with 79 additions and 12 deletions

View File

@ -30,9 +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 OCP\EventDispatcher\IEventDispatcher;
class AddressHandlerTest extends \Test\TestCase {
/** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
@ -60,7 +62,13 @@ class AddressHandlerTest extends \Test\TestCase {
$this->contactsManager = $this->createMock(IManager::class);
$this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->urlGenerator, $this->createMock(IUserManager::class));
$this->cloudIdManager = new CloudIdManager(
$this->contactsManager,
$this->urlGenerator,
$this->createMock(IUserManager::class),
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
);
$this->addressHandler = new AddressHandler($this->urlGenerator, $this->il10n, $this->cloudIdManager);
}

View File

@ -34,10 +34,12 @@ use OCA\FederatedFileSharing\Controller\MountPublicLinkController;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\AppFramework\Http;
use OCP\Contacts\IManager as IContactsManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
use OCP\Files\IRootFolder;
use OCP\HintException;
use OCP\Http\Client\IClientService;
use OCP\ICacheFactory;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
@ -107,7 +109,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->createMock(IURLGenerator::class), $this->userManager);
$this->cloudIdManager = new CloudIdManager(
$this->contactsManager,
$this->createMock(IURLGenerator::class),
$this->userManager,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
);
$this->controller = new MountPublicLinkController(
'federatedfilesharing', $this->request,

View File

@ -38,10 +38,12 @@ use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\FederatedFileSharing\Notifications;
use OCA\FederatedFileSharing\TokenHandler;
use OCP\Contacts\IManager as IContactsManager;
use OCP\EventDispatcher\IEventDispatcher;
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;
@ -116,7 +118,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->createMock(IURLGenerator::class), $this->userManager);
$this->cloudIdManager = new CloudIdManager(
$this->contactsManager,
$this->createMock(IURLGenerator::class),
$this->userManager,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
);
$this->gsConfig = $this->createMock(\OCP\GlobalScale\IConfig::class);
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);

View File

@ -30,7 +30,9 @@ namespace OCA\Files_Sharing\Tests\External;
use OC\Federation\CloudIdManager;
use OCA\Files_Sharing\Tests\TestCase;
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
use OCP\ICacheFactory;
use OCP\IURLGenerator;
use OCP\IUserManager;
@ -68,7 +70,13 @@ class CacheTest extends TestCase {
$this->contactsManager = $this->createMock(IManager::class);
$this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class));
$this->cloudIdManager = new CloudIdManager(
$this->contactsManager,
$this->createMock(IURLGenerator::class),
$this->createMock(IUserManager::class),
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
);
$this->remoteUser = $this->getUniqueID('remoteuser');
$this->storage = $this->getMockBuilder('\OCA\Files_Sharing\External\Storage')

View File

@ -31,21 +31,19 @@
namespace OCA\Files_Sharing\Tests\External;
use OC\Federation\CloudIdManager;
use OC\Files\SetupManager;
use OC\Files\SetupManagerFactory;
use OC\Files\Storage\StorageFactory;
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\External\MountProvider;
use OCA\Files_Sharing\Tests\TestCase;
use OCP\Contacts\IManager;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Files\Config\IMountProviderCollection;
use OCP\Files\NotFoundException;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\ICacheFactory;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IURLGenerator;
@ -130,7 +128,13 @@ class ManagerTest extends TestCase {
$this->testMountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function () {
return $this->manager;
}, new CloudIdManager($this->contactsManager, $this->createMock(IURLGenerator::class), $this->userManager));
}, new CloudIdManager(
$this->contactsManager,
$this->createMock(IURLGenerator::class),
$this->userManager,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
));
$group1 = $this->createMock(IGroup::class);
$group1->expects($this->any())->method('getGID')->willReturn('group1');

View File

@ -1366,7 +1366,7 @@ class Server extends ServerContainer implements IServerContainer {
$c->get(IURLGenerator::class),
$c->get(IUserManager::class),
$c->get(ICacheFactory::class),
$c->get(EventDispatcherInterface::class),
$c->get(IEventDispatcher::class),
);
});

View File

@ -29,7 +29,9 @@ use OC\Federation\CloudIdManager;
use OC\KnownUser\KnownUserService;
use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IURLGenerator;
@ -77,7 +79,13 @@ class MailPluginTest extends TestCase {
$this->knownUserService = $this->createMock(KnownUserService::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->mailer = $this->createMock(IMailer::class);
$this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class));
$this->cloudIdManager = new CloudIdManager(
$this->contactsManager,
$this->createMock(IURLGenerator::class),
$this->createMock(IUserManager::class),
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
);
$this->searchResult = new SearchResult();
}

View File

@ -28,7 +28,9 @@ use OC\Collaboration\Collaborators\SearchResult;
use OC\Federation\CloudIdManager;
use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IURLGenerator;
use OCP\IUser;
@ -63,7 +65,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->createMock(IURLGenerator::class), $this->createMock(IUserManager::class));
$this->cloudIdManager = new CloudIdManager(
$this->contactsManager,
$this->createMock(IURLGenerator::class),
$this->createMock(IUserManager::class),
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
);
$this->searchResult = new SearchResult();
}

View File

@ -22,7 +22,10 @@
namespace Test\Federation;
use OC\Federation\CloudIdManager;
use OC\Memcache\ArrayCache;
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ICacheFactory;
use OCP\IURLGenerator;
use OCP\IUserManager;
use Test\TestCase;
@ -36,6 +39,8 @@ class CloudIdManagerTest extends TestCase {
private $userManager;
/** @var CloudIdManager */
private $cloudIdManager;
/** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
private $cacheFactory;
protected function setUp(): void {
@ -45,7 +50,17 @@ class CloudIdManagerTest extends TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->urlGenerator, $this->userManager);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->cacheFactory->method('createLocal')
->willReturn(new ArrayCache(''));
$this->cloudIdManager = new CloudIdManager(
$this->contactsManager,
$this->urlGenerator,
$this->userManager,
$this->cacheFactory,
$this->createMock(IEventDispatcher::class)
);
}
public function cloudIdProvider() {