From 3a2b3c75f20d1bd2ac22d79a4372c6c5c0b5fa2f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 25 Nov 2024 17:30:32 +0100 Subject: perf: use more optimized way to get user storage info in ocs user info when possible Signed-off-by: Robin Appelman --- .../tests/Controller/GroupsControllerTest.php | 5 +++++ .../tests/Controller/UsersControllerTest.php | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'apps/provisioning_api/tests') diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index b1a708b9aa2..29b098429e8 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -12,6 +12,7 @@ use OC\User\NoUserException; use OCA\Provisioning_API\Controller\GroupsController; use OCP\Accounts\IAccountManager; use OCP\AppFramework\OCS\OCSException; +use OCP\Files\IRootFolder; use OCP\Group\ISubAdmin; use OCP\IConfig; use OCP\IGroup; @@ -46,6 +47,8 @@ class GroupsControllerTest extends \Test\TestCase { /** @var GroupsController|\PHPUnit\Framework\MockObject\MockObject */ protected $api; + private IRootFolder $rootFolder; + protected function setUp(): void { parent::setUp(); @@ -59,6 +62,7 @@ class GroupsControllerTest extends \Test\TestCase { $this->subAdminManager = $this->createMock(ISubAdmin::class); $this->l10nFactory = $this->createMock(IFactory::class); $this->logger = $this->createMock(LoggerInterface::class); + $this->rootFolder = $this->createMock(IRootFolder::class); $this->groupManager ->method('getSubAdmin') @@ -75,6 +79,7 @@ class GroupsControllerTest extends \Test\TestCase { $this->accountManager, $this->subAdminManager, $this->l10nFactory, + $this->rootFolder, $this->logger ]) ->setMethods(['fillStorageInfo']) diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 52dd82069f9..439ee0be250 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -23,6 +23,7 @@ use OCP\Accounts\IAccountPropertyCollection; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSException; use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\IRootFolder; use OCP\Group\ISubAdmin; use OCP\IConfig; use OCP\IGroup; @@ -76,6 +77,7 @@ class UsersControllerTest extends TestCase { private $knownUserService; /** @var IEventDispatcher|MockObject */ private $eventDispatcher; + private IRootFolder $rootFolder; /** @var IPhoneNumberUtil */ private $phoneNumberUtil; @@ -98,6 +100,7 @@ class UsersControllerTest extends TestCase { $this->knownUserService = $this->createMock(KnownUserService::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->phoneNumberUtil = new PhoneNumberUtil(); + $this->rootFolder = $this->createMock(IRootFolder::class); $l10n = $this->createMock(IL10N::class); $l10n->method('t')->willReturnCallback(fn (string $txt, array $replacement = []) => sprintf($txt, ...$replacement)); @@ -114,6 +117,7 @@ class UsersControllerTest extends TestCase { $this->accountManager, $this->subAdminManager, $this->l10nFactory, + $this->rootFolder, $this->urlGenerator, $this->logger, $this->newUserMailHelper, @@ -508,6 +512,7 @@ class UsersControllerTest extends TestCase { $this->accountManager, $this->subAdminManager, $this->l10nFactory, + $this->rootFolder, $this->urlGenerator, $this->logger, $this->newUserMailHelper, @@ -1127,7 +1132,7 @@ class UsersControllerTest extends TestCase { $this->api ->expects($this->once()) ->method('fillStorageInfo') - ->with('UID') + ->with($targetUser) ->willReturn(['DummyValue']); $backend = $this->createMock(UserInterface::class); @@ -1260,7 +1265,7 @@ class UsersControllerTest extends TestCase { $this->api ->expects($this->once()) ->method('fillStorageInfo') - ->with('UID') + ->with($targetUser) ->willReturn(['DummyValue']); $backend = $this->createMock(UserInterface::class); @@ -1441,7 +1446,7 @@ class UsersControllerTest extends TestCase { $this->api ->expects($this->once()) ->method('fillStorageInfo') - ->with('UID') + ->with($targetUser) ->willReturn(['DummyValue']); $backend = $this->createMock(UserInterface::class); @@ -3806,6 +3811,7 @@ class UsersControllerTest extends TestCase { $this->accountManager, $this->subAdminManager, $this->l10nFactory, + $this->rootFolder, $this->urlGenerator, $this->logger, $this->newUserMailHelper, @@ -3896,6 +3902,7 @@ class UsersControllerTest extends TestCase { $this->accountManager, $this->subAdminManager, $this->l10nFactory, + $this->rootFolder, $this->urlGenerator, $this->logger, $this->newUserMailHelper, -- cgit v1.2.3