diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2023-04-28 12:32:18 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2023-05-12 14:15:02 +0200 |
commit | 2cc672d26b33939a44d71a346c9f3726f4b951db (patch) | |
tree | a74f76d3898152bcd51bc1c94e18ad212bab5317 /apps/dav/tests | |
parent | 5993a4b3e3f70e8d768c36c8e16402c67e124eb4 (diff) | |
download | nextcloud-server-2cc672d26b33939a44d71a346c9f3726f4b951db.tar.gz nextcloud-server-2cc672d26b33939a44d71a346c9f3726f4b951db.zip |
fix(dav): Run system address book create-if-not-exists in transaction
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/CardDAV/SyncServiceTest.php | 12 |
1 files changed, 8 insertions, 4 deletions
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]); |