summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/CardDAV
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2018-08-06 12:34:56 +0200
committerThomas Citharel <tcit@tcit.fr>2018-08-06 12:34:56 +0200
commitc80049516992cdd06c5d6cf7265af1abe4156f98 (patch)
tree1136c137b3ecb5557c4605b42061fc74839c1ff3 /apps/dav/tests/unit/CardDAV
parent03f1fef1601c21a2c387a20db9e46b21273c15c9 (diff)
downloadnextcloud-server-c80049516992cdd06c5d6cf7265af1abe4156f98.tar.gz
nextcloud-server-c80049516992cdd06c5d6cf7265af1abe4156f98.zip
Test sync service when user is deactivated
I feel like this could probably be handled better :/ Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps/dav/tests/unit/CardDAV')
-rw-r--r--apps/dav/tests/unit/CardDAV/SyncServiceTest.php26
1 files changed, 21 insertions, 5 deletions
diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
index fb8c2775ed2..7d444571fac 100644
--- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
+++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
@@ -84,14 +84,30 @@ class SyncServiceTest extends TestCase {
$ss->ensureSystemAddressBookExists('principals/users/adam', 'contacts', []);
}
- public function testUpdateAndDeleteUser() {
+ public function dataActivatedUsers() {
+ return [
+ [true, 1, 1, 1],
+ [false, 0, 0, 3],
+ ];
+ }
+
+ /**
+ * @dataProvider dataActivatedUsers
+ *
+ * @param boolean $activated
+ * @param integer $createCalls
+ * @param integer $updateCalls
+ * @param integer $deleteCalls
+ * @return void
+ */
+ public function testUpdateAndDeleteUser($activated, $createCalls, $updateCalls, $deleteCalls) {
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backend */
$backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
$logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
- $backend->expects($this->once())->method('createCard');
- $backend->expects($this->once())->method('updateCard');
- $backend->expects($this->once())->method('deleteCard');
+ $backend->expects($this->exactly($createCalls))->method('createCard');
+ $backend->expects($this->exactly($updateCalls))->method('updateCard');
+ $backend->expects($this->exactly($deleteCalls))->method('deleteCard');
$backend->method('getCard')->willReturnOnConsecutiveCalls(false, [
'carddata' => "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.4.8//EN\r\nUID:test-user\r\nFN:test-user\r\nN:test-user;;;;\r\nEND:VCARD\r\n\r\n"
@@ -106,7 +122,7 @@ class SyncServiceTest extends TestCase {
$user->method('getUID')->willReturn('test-user');
$user->method('getCloudId')->willReturn('cloudId');
$user->method('getDisplayName')->willReturn('test-user');
- $user->method('isEnabled')->willReturn(true);
+ $user->method('isEnabled')->willReturn($activated);
$accountManager = $this->getMockBuilder(AccountManager::class)->disableOriginalConstructor()->getMock();
$accountManager->expects($this->any())->method('getUser')
->willReturn([