From fc11eef4a128f1b857fc9fe75b806e32a619c4db Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 7 Apr 2026 17:59:52 +0200 Subject: [PATCH] test: update tests to new full sync Signed-off-by: Robin Appelman --- .../tests/unit/CardDAV/SyncServiceTest.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php index 9fe8a7cd66e..630d61672ee 100644 --- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php @@ -5,6 +5,7 @@ * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-only */ + namespace OCA\DAV\Tests\unit\CardDAV; use GuzzleHttp\Exception\ClientException; @@ -297,10 +298,26 @@ END:VCARD'; } public function testFullSyncWithOrphanElement(): void { + $pendingCards = []; $this->backend->expects($this->exactly(0)) ->method('createCard'); $this->backend->expects($this->exactly(1)) - ->method('updateCard'); + ->method('updateCard') + ->willReturnCallback(function ($id, $uri) use (&$pendingCards) { + unset($pendingCards[$uri]); + }); + $this->backend->expects($this->exactly(1)) + ->method('markCardsAsPending') + ->willReturnCallback(function ($id) use (&$pendingCards) { + $cards = array_values($this->backend->getCards($id)); + $uris = array_map(fn ($card) => $card['uri'], $cards); + $pendingCards = array_combine($uris, $cards); + }); + $this->backend->expects($this->exactly(1)) + ->method('getPendingCards') + ->willReturnCallback(function ($id) use (&$pendingCards) { + return array_values($pendingCards); + }); $this->backend->expects($this->exactly(1)) ->method('deleteCard'); @@ -355,6 +372,7 @@ END:VCARD'; ['uri' => 'Database:bob.vcf'], ]); + $this->service->markCardsAsPending(1); $token = $this->service->syncRemoteAddressBook( '', 'system', @@ -365,6 +383,7 @@ END:VCARD'; 'principals/system/system', [] )[0]; + $this->service->deletePendingCards(1); $this->assertEquals('http://sabre.io/ns/sync/3', $token); }