diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-15 11:46:24 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-20 10:15:18 +0200 |
commit | 21e72da9ee34cec56b10c83ae0c75b4bf320dfcb (patch) | |
tree | b6c0b8208f004e1b2b37b1af54e8d4c40310d56e /tests/bookmark/BookmarkTest.php | |
parent | 9b3c1270bcbe4f8e30e0160da8badd43dd94871a (diff) | |
download | Shaarli-21e72da9ee34cec56b10c83ae0c75b4bf320dfcb.tar.gz Shaarli-21e72da9ee34cec56b10c83ae0c75b4bf320dfcb.tar.zst Shaarli-21e72da9ee34cec56b10c83ae0c75b4bf320dfcb.zip |
Asynchronous retrieval of bookmark's thumbnails
This feature is based general.enable_async_metadata setting and works with existing metadata.js file.
The script is compatible with any template:
- the thumbnail div bloc must have attribute
- the bookmark bloc must have attribute with the bookmark ID as value
Fixes #1564
Diffstat (limited to 'tests/bookmark/BookmarkTest.php')
-rw-r--r-- | tests/bookmark/BookmarkTest.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/bookmark/BookmarkTest.php b/tests/bookmark/BookmarkTest.php index 4c7ae4c0..4c1ae25d 100644 --- a/tests/bookmark/BookmarkTest.php +++ b/tests/bookmark/BookmarkTest.php | |||
@@ -347,4 +347,48 @@ class BookmarkTest extends TestCase | |||
347 | $bookmark->deleteTag('nope'); | 347 | $bookmark->deleteTag('nope'); |
348 | $this->assertEquals(['tag1', 'tag2', 'chair'], $bookmark->getTags()); | 348 | $this->assertEquals(['tag1', 'tag2', 'chair'], $bookmark->getTags()); |
349 | } | 349 | } |
350 | |||
351 | /** | ||
352 | * Test shouldUpdateThumbnail() with bookmarks needing an update. | ||
353 | */ | ||
354 | public function testShouldUpdateThumbnail(): void | ||
355 | { | ||
356 | $bookmark = (new Bookmark())->setUrl('http://domain.tld/with-image'); | ||
357 | |||
358 | static::assertTrue($bookmark->shouldUpdateThumbnail()); | ||
359 | |||
360 | $bookmark = (new Bookmark()) | ||
361 | ->setUrl('http://domain.tld/with-image') | ||
362 | ->setThumbnail('unknown file') | ||
363 | ; | ||
364 | |||
365 | static::assertTrue($bookmark->shouldUpdateThumbnail()); | ||
366 | } | ||
367 | |||
368 | /** | ||
369 | * Test shouldUpdateThumbnail() with bookmarks that should not update. | ||
370 | */ | ||
371 | public function testShouldNotUpdateThumbnail(): void | ||
372 | { | ||
373 | $bookmark = (new Bookmark()); | ||
374 | |||
375 | static::assertFalse($bookmark->shouldUpdateThumbnail()); | ||
376 | |||
377 | $bookmark = (new Bookmark()) | ||
378 | ->setUrl('ftp://domain.tld/other-protocol', ['ftp']) | ||
379 | ; | ||
380 | |||
381 | static::assertFalse($bookmark->shouldUpdateThumbnail()); | ||
382 | |||
383 | $bookmark = (new Bookmark()) | ||
384 | ->setUrl('http://domain.tld/with-image') | ||
385 | ->setThumbnail(__FILE__) | ||
386 | ; | ||
387 | |||
388 | static::assertFalse($bookmark->shouldUpdateThumbnail()); | ||
389 | |||
390 | $bookmark = (new Bookmark())->setUrl('/shaare/abcdef'); | ||
391 | |||
392 | static::assertFalse($bookmark->shouldUpdateThumbnail()); | ||
393 | } | ||
350 | } | 394 | } |