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