From 2cc672d26b33939a44d71a346c9f3726f4b951db Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 28 Apr 2023 12:32:18 +0200 Subject: fix(dav): Run system address book create-if-not-exists in transaction Signed-off-by: Christoph Wurst --- apps/dav/tests/unit/CardDAV/SyncServiceTest.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'apps/dav/tests') diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php index 789009057fd..c031f8cbb97 100644 --- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php @@ -30,6 +30,7 @@ namespace OCA\DAV\Tests\unit\CardDAV; use OCA\DAV\CardDAV\CardDavBackend; use OCA\DAV\CardDAV\Converter; use OCA\DAV\CardDAV\SyncService; +use OCP\IDBConnection; use OCP\IUser; use OCP\IUserManager; use Psr\Log\LoggerInterface; @@ -84,10 +85,11 @@ class SyncServiceTest extends TestCase { /** @var IUserManager $userManager */ $userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); + $dbConnection = $this->createMock(IDBConnection::class); $logger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock(); $converter = $this->createMock(Converter::class); - $ss = new SyncService($backend, $userManager, $logger, $converter); + $ss = new SyncService($backend, $userManager, $dbConnection, $logger, $converter); $ss->ensureSystemAddressBookExists('principals/users/adam', 'contacts', []); } @@ -126,6 +128,7 @@ class SyncServiceTest extends TestCase { /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject $userManager */ $userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); + $dbConnection = $this->createMock(IDBConnection::class); /** @var IUser | \PHPUnit\Framework\MockObject\MockObject $user */ $user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -139,7 +142,7 @@ class SyncServiceTest extends TestCase { ->method('createCardFromUser') ->willReturn($this->createMock(VCard::class)); - $ss = new SyncService($backend, $userManager, $logger, $converter); + $ss = new SyncService($backend, $userManager, $dbConnection, $logger, $converter); $ss->updateUser($user); $ss->updateUser($user); @@ -151,7 +154,7 @@ class SyncServiceTest extends TestCase { * @param int $createCount * @param int $updateCount * @param int $deleteCount - * @return \PHPUnit\Framework\MockObject\MockObject + * @return \PHPUnit\Framework\MockObject\MockObject|CardDavBackend */ private function getBackendMock($createCount, $updateCount, $deleteCount) { $backend = $this->getMockBuilder(CardDavBackend::class) @@ -170,12 +173,13 @@ class SyncServiceTest extends TestCase { */ private function getSyncServiceMock($backend, $response) { $userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); + $dbConnection = $this->createMock(IDBConnection::class); $logger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock(); $converter = $this->createMock(Converter::class); /** @var SyncService | \PHPUnit\Framework\MockObject\MockObject $ss */ $ss = $this->getMockBuilder(SyncService::class) ->setMethods(['ensureSystemAddressBookExists', 'requestSyncReport', 'download', 'getCertPath']) - ->setConstructorArgs([$backend, $userManager, $logger, $converter]) + ->setConstructorArgs([$backend, $userManager, $dbConnection, $logger, $converter]) ->getMock(); $ss->method('requestSyncReport')->withAnyParameters()->willReturn(['response' => $response, 'token' => 'sync-token-1']); $ss->method('ensureSystemAddressBookExists')->willReturn(['id' => 1]); -- cgit v1.2.3