aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-03-06 12:54:52 +0100
committerAndy Scherzinger <info@andy-scherzinger.de>2024-06-13 18:34:51 +0200
commit0ab1cc5f17b2941364572007f7cf120342495d87 (patch)
tree2a6032349daa0a17aaa819f89045184c0b0ad823 /tests
parente1af6af627bf18620bcf49e599b12ade02103d25 (diff)
downloadnextcloud-server-0ab1cc5f17b2941364572007f7cf120342495d87.tar.gz
nextcloud-server-0ab1cc5f17b2941364572007f7cf120342495d87.zip
refactor: make share manager buildable
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Share20/ManagerTest.php195
1 files changed, 19 insertions, 176 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index aeea1b5b863..e352c088d51 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -151,19 +151,27 @@ class ManagerTest extends \Test\TestCase {
->willReturnCallback(function ($singular, $plural, $count, $parameters = []) {
return vsprintf(str_replace('%n', $count, ($count === 1) ? $singular : $plural), $parameters);
});
+ $this->l10nFactory->method('get')->willReturn($this->l);
$this->factory = new DummyFactory(\OC::$server);
- $this->manager = new Manager(
+ $this->manager = $this->createManager($this->factory);
+
+ $this->defaultProvider = $this->createMock(DefaultShareProvider::class);
+ $this->defaultProvider->method('identifier')->willReturn('default');
+ $this->factory->setProvider($this->defaultProvider);
+ }
+
+ private function createManager(IProviderFactory $factory): Manager {
+ return new Manager(
$this->logger,
$this->config,
$this->secureRandom,
$this->hasher,
$this->mountManager,
$this->groupManager,
- $this->l,
$this->l10nFactory,
- $this->factory,
+ $factory,
$this->userManager,
$this->rootFolder,
$this->mailer,
@@ -175,10 +183,6 @@ class ManagerTest extends \Test\TestCase {
$this->shareDisabledChecker,
$this->dateTimeZone,
);
-
- $this->defaultProvider = $this->createMock(DefaultShareProvider::class);
- $this->defaultProvider->method('identifier')->willReturn('default');
- $this->factory->setProvider($this->defaultProvider);
}
/**
@@ -193,7 +197,6 @@ class ManagerTest extends \Test\TestCase {
$this->hasher,
$this->mountManager,
$this->groupManager,
- $this->l,
$this->l10nFactory,
$this->factory,
$this->userManager,
@@ -2802,27 +2805,7 @@ class ManagerTest extends \Test\TestCase {
$factory = $this->createMock(IProviderFactory::class);
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService,
- $this->shareDisabledChecker,
- $this->dateTimeZone,
- );
+ $manager = $this->createManager($factory);
$share = $this->createMock(IShare::class);
@@ -2851,27 +2834,7 @@ class ManagerTest extends \Test\TestCase {
$factory = $this->createMock(IProviderFactory::class);
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService,
- $this->shareDisabledChecker,
- $this->dateTimeZone,
- );
+ $manager = $this->createManager($factory);
$share = $this->createMock(IShare::class);
@@ -2907,27 +2870,7 @@ class ManagerTest extends \Test\TestCase {
$factory = $this->createMock(IProviderFactory::class);
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService,
- $this->shareDisabledChecker,
- $this->dateTimeZone,
- );
+ $manager = $this->createManager($factory);
$share = $this->createMock(IShare::class);
@@ -4308,27 +4251,7 @@ class ManagerTest extends \Test\TestCase {
throw new Exception\ProviderException();
});
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService,
- $this->shareDisabledChecker,
- $this->dateTimeZone,
- );
+ $manager = $this->createManager($factory);
$this->assertSame($expected,
$manager->shareProviderExists($shareType)
);
@@ -4344,27 +4267,7 @@ class ManagerTest extends \Test\TestCase {
public function testGetSharesInFolder() {
$factory = new DummyFactory2($this->createMock(IServerContainer::class));
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService,
- $this->shareDisabledChecker,
- $this->dateTimeZone,
- );
+ $manager = $this->createManager($factory);
$factory->setProvider($this->defaultProvider);
$extraProvider = $this->createMock(IShareProvider::class);
@@ -4411,27 +4314,7 @@ class ManagerTest extends \Test\TestCase {
public function testGetAccessList() {
$factory = new DummyFactory2($this->createMock(IServerContainer::class));
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService,
- $this->shareDisabledChecker,
- $this->dateTimeZone,
- );
+ $manager = $this->createManager($factory);
$factory->setProvider($this->defaultProvider);
$extraProvider = $this->createMock(IShareProvider::class);
@@ -4530,27 +4413,7 @@ class ManagerTest extends \Test\TestCase {
public function testGetAccessListWithCurrentAccess() {
$factory = new DummyFactory2($this->createMock(IServerContainer::class));
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService,
- $this->shareDisabledChecker,
- $this->dateTimeZone,
- );
+ $manager = $this->createManager($factory);
$factory->setProvider($this->defaultProvider);
$extraProvider = $this->createMock(IShareProvider::class);
@@ -4658,27 +4521,7 @@ class ManagerTest extends \Test\TestCase {
public function testGetAllShares() {
$factory = new DummyFactory2($this->createMock(IServerContainer::class));
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService,
- $this->shareDisabledChecker,
- $this->dateTimeZone,
- );
+ $manager = $this->createManager($factory);
$factory->setProvider($this->defaultProvider);
$extraProvider = $this->createMock(IShareProvider::class);