Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Aug 12, 2021
1 parent 172dd33 commit 373b0ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
18 changes: 1 addition & 17 deletions apps/files_sharing/lib/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,10 @@
namespace OCA\Files_Sharing;

use OC\Files\Filesystem;
use OCP\EventDispatcher\IEventDispatcher;
use Psr\Log\LoggerInterface;

class Hooks {
public static function deleteUser($params) {
$manager = new External\Manager(
\OC::$server->getDatabaseConnection(),
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
\OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
\OC::$server->getCloudFederationProviderManager(),
\OC::$server->getCloudFederationFactory(),
\OC::$server->getGroupManager(),
\OC::$server->getUserManager(),
$params['uid'],
\OC::$server->query(IEventDispatcher::class),
\OC::$server->get(LoggerInterface::class)
);
$manager = \OC::$server->get(External\Manager::class);

$manager->removeUserShares($params['uid']);
}
Expand Down
11 changes: 10 additions & 1 deletion apps/files_sharing/tests/External/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
use Test\Traits\UserTrait;
Expand Down Expand Up @@ -153,6 +155,13 @@ protected function tearDown(): void {
}

private function createManagerForUser($userId) {
$user = $this->createMock(IUser::class);
$user->method('getUID')
->willReturn($userId);
$userSession = $this->createMock(IUserSession::class);
$userSession->method('getUser')
->willReturn($user);

return $this->getMockBuilder(Manager::class)
->setConstructorArgs(
[
Expand All @@ -166,7 +175,7 @@ private function createManagerForUser($userId) {
$this->cloudFederationFactory,
$this->groupManager,
$this->userManager,
$userId,
$userSession,
$this->eventDispatcher,
$this->logger,
]
Expand Down
10 changes: 9 additions & 1 deletion apps/files_sharing/tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

use OC\Files\Filesystem;
use OCA\Files_Sharing\AppInfo\Application;
use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider;
use OCA\Files_Sharing\MountProvider;
use OCP\Files\Config\IMountProviderCollection;
use OCP\Share\IShare;
use Test\Traits\MountProviderTrait;

Expand Down Expand Up @@ -71,7 +74,12 @@ abstract class TestCase extends \Test\TestCase {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();

new Application();
$app = new Application();
$app->registerMountProviders(
\OC::$server->get(IMountProviderCollection::class),
\OC::$server->get(MountProvider::class),
\OC::$server->get(ExternalMountProvider::class),
);

// reset backend
\OC_User::clearBackends();
Expand Down

0 comments on commit 373b0ef

Please sign in to comment.