|
10 | 10 |
|
11 | 11 | use OCA\DAV\CardDAV\AddressBook; |
12 | 12 | use OCA\DAV\CardDAV\ImageExportPlugin; |
| 13 | +use OCA\DAV\CardDAV\Integration\ExternalAddressBook; |
13 | 14 | use OCA\DAV\CardDAV\PhotoCache; |
14 | 15 | use OCP\AppFramework\Http; |
15 | 16 | use OCP\Files\NotFoundException; |
@@ -172,6 +173,39 @@ public function testCard(?int $size, bool $photo): void { |
172 | 173 | $this->assertFalse($result); |
173 | 174 | } |
174 | 175 |
|
| 176 | + public function testAppGeneratedAddressBook(): void { |
| 177 | + $this->request->method('getQueryParameters') |
| 178 | + ->willReturn(['photo' => null]); |
| 179 | + $this->request->method('getPath') |
| 180 | + ->willReturn('user/book/card'); |
| 181 | + |
| 182 | + $card = $this->createMock(Card::class); |
| 183 | + $card->method('getETag') |
| 184 | + ->willReturn('"myEtag"'); |
| 185 | + $book = $this->createMock(ExternalAddressBook::class); |
| 186 | + |
| 187 | + $this->tree->method('getNodeForPath') |
| 188 | + ->willReturnCallback(function ($path) use ($card, $book) { |
| 189 | + if ($path === 'user/book/card') { |
| 190 | + return $card; |
| 191 | + } elseif ($path === 'user/book') { |
| 192 | + return $book; |
| 193 | + } |
| 194 | + $this->fail(); |
| 195 | + }); |
| 196 | + |
| 197 | + $this->cache->expects($this->never()) |
| 198 | + ->method('get'); |
| 199 | + $this->response->expects($this->once()) |
| 200 | + ->method('setStatus') |
| 201 | + ->with(Http::STATUS_NO_CONTENT); |
| 202 | + $this->response->expects($this->never()) |
| 203 | + ->method('setBody'); |
| 204 | + |
| 205 | + $result = $this->plugin->httpGet($this->request, $this->response); |
| 206 | + $this->assertFalse($result); |
| 207 | + } |
| 208 | + |
175 | 209 | public function testCardWithSpecialCharactersInName(): void { |
176 | 210 | $this->request->method('getQueryParameters') |
177 | 211 | ->willReturn(['photo' => null]); |
|
0 commit comments