summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2016-06-21 15:25:44 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-06-21 15:25:44 +0200
commit1452b74de7f5a3b3afae546b757d2a3889857a61 (patch)
tree0eba5164f1af53876cdeac866e273ab7a40393a4 /apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
parentf2f1eab7f4ade9abb77f70c6a5c3244b5c6153f4 (diff)
downloadnextcloud-server-1452b74de7f5a3b3afae546b757d2a3889857a61.tar.gz
nextcloud-server-1452b74de7f5a3b3afae546b757d2a3889857a61.zip
Contacts API: replace raw image data with url (#25081)
* add uri to AddressBookImpl array * Introduce ImageExportPlugin for CardDav * add plugin to v1 routes * replace binary contact photo with link * update tests * Adding unit tests
Diffstat (limited to 'apps/dav/tests/unit/CardDAV/AddressBookImplTest.php')
-rw-r--r--apps/dav/tests/unit/CardDAV/AddressBookImplTest.php37
1 files changed, 25 insertions, 12 deletions
diff --git a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
index ddfec3dc3ac..4ccc841157f 100644
--- a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
+++ b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
@@ -43,6 +43,9 @@ class AddressBookImplTest extends TestCase {
/** @var AddressBook | \PHPUnit_Framework_MockObject_MockObject */
private $addressBook;
+ /** @var \OCP\IURLGenerator | \PHPUnit_Framework_MockObject_MockObject */
+ private $urlGenerator;
+
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject */
private $backend;
@@ -61,11 +64,13 @@ class AddressBookImplTest extends TestCase {
$this->backend = $this->getMockBuilder('\OCA\DAV\CardDAV\CardDavBackend')
->disableOriginalConstructor()->getMock();
$this->vCard = $this->getMock('Sabre\VObject\Component\VCard');
+ $this->urlGenerator = $this->getMock('OCP\IURLGenerator');
$this->addressBookImpl = new AddressBookImpl(
$this->addressBook,
$this->addressBookInfo,
- $this->backend
+ $this->backend,
+ $this->urlGenerator
);
}
@@ -87,7 +92,8 @@ class AddressBookImplTest extends TestCase {
[
$this->addressBook,
$this->addressBookInfo,
- $this->backend
+ $this->backend,
+ $this->urlGenerator,
]
)
->setMethods(['vCard2Array', 'readCard'])
@@ -100,15 +106,18 @@ class AddressBookImplTest extends TestCase {
->with($this->addressBookInfo['id'], $pattern, $searchProperties)
->willReturn(
[
- 'cardData1',
- 'cardData2'
+ ['uri' => 'foo.vcf', 'carddata' => 'cardData1'],
+ ['uri' => 'bar.vcf', 'carddata' => 'cardData2']
]
);
$addressBookImpl->expects($this->exactly(2))->method('readCard')
->willReturn($this->vCard);
$addressBookImpl->expects($this->exactly(2))->method('vCard2Array')
- ->with($this->vCard)->willReturn('vCard');
+ ->withConsecutive(
+ ['foo.vcf', $this->vCard],
+ ['bar.vcf', $this->vCard]
+ )->willReturn('vCard');
$result = $addressBookImpl->search($pattern, $searchProperties, []);
$this->assertTrue((is_array($result)));
@@ -130,7 +139,8 @@ class AddressBookImplTest extends TestCase {
[
$this->addressBook,
$this->addressBookInfo,
- $this->backend
+ $this->backend,
+ $this->urlGenerator,
]
)
->setMethods(['vCard2Array', 'createUid', 'createEmptyVCard'])
@@ -146,7 +156,7 @@ class AddressBookImplTest extends TestCase {
$this->backend->expects($this->never())->method('updateCard');
$this->backend->expects($this->never())->method('getCard');
$addressBookImpl->expects($this->once())->method('vCard2Array')
- ->with($this->vCard)->willReturn(true);
+ ->with('uid.vcf', $this->vCard)->willReturn(true);
$this->assertTrue($addressBookImpl->createOrUpdate($properties));
}
@@ -161,7 +171,8 @@ class AddressBookImplTest extends TestCase {
public function testUpdate() {
$uid = 'uid';
- $properties = ['UID' => $uid, 'FN' => 'John Doe'];
+ $uri = 'bla.vcf';
+ $properties = ['URI' => $uri, 'UID' => $uid, 'FN' => 'John Doe'];
/** @var \PHPUnit_Framework_MockObject_MockObject | AddressBookImpl $addressBookImpl */
$addressBookImpl = $this->getMockBuilder('OCA\DAV\CardDAV\AddressBookImpl')
@@ -169,7 +180,8 @@ class AddressBookImplTest extends TestCase {
[
$this->addressBook,
$this->addressBookInfo,
- $this->backend
+ $this->backend,
+ $this->urlGenerator,
]
)
->setMethods(['vCard2Array', 'createUid', 'createEmptyVCard', 'readCard'])
@@ -178,7 +190,7 @@ class AddressBookImplTest extends TestCase {
$addressBookImpl->expects($this->never())->method('createUid');
$addressBookImpl->expects($this->never())->method('createEmptyVCard');
$this->backend->expects($this->once())->method('getCard')
- ->with($this->addressBookInfo['id'], $uid . '.vcf')
+ ->with($this->addressBookInfo['id'], $uri)
->willReturn(['carddata' => 'data']);
$addressBookImpl->expects($this->once())->method('readCard')
->with('data')->willReturn($this->vCard);
@@ -187,7 +199,7 @@ class AddressBookImplTest extends TestCase {
$this->backend->expects($this->never())->method('createCard');
$this->backend->expects($this->once())->method('updateCard');
$addressBookImpl->expects($this->once())->method('vCard2Array')
- ->with($this->vCard)->willReturn(true);
+ ->with($uri, $this->vCard)->willReturn(true);
$this->assertTrue($addressBookImpl->createOrUpdate($properties));
}
@@ -251,7 +263,8 @@ class AddressBookImplTest extends TestCase {
[
$this->addressBook,
$this->addressBookInfo,
- $this->backend
+ $this->backend,
+ $this->urlGenerator,
]
)
->setMethods(['getUid'])