aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/controller/visitor
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-20 10:30:02 +0200
committerGitHub <noreply@github.com>2020-10-20 10:30:02 +0200
commitd8030c8155ee4c20573848b2444f6df0b65d1662 (patch)
treeb6c0b8208f004e1b2b37b1af54e8d4c40310d56e /tests/front/controller/visitor
parent9b3c1270bcbe4f8e30e0160da8badd43dd94871a (diff)
parent21e72da9ee34cec56b10c83ae0c75b4bf320dfcb (diff)
downloadShaarli-d8030c8155ee4c20573848b2444f6df0b65d1662.tar.gz
Shaarli-d8030c8155ee4c20573848b2444f6df0b65d1662.tar.zst
Shaarli-d8030c8155ee4c20573848b2444f6df0b65d1662.zip
Merge pull request #1584 from ArthurHoaro/feature/async-thumbnail-retrieval
Asynchronous retrieval of bookmark's thumbnails
Diffstat (limited to 'tests/front/controller/visitor')
-rw-r--r--tests/front/controller/visitor/BookmarkListControllerTest.php57
1 files changed, 55 insertions, 2 deletions
diff --git a/tests/front/controller/visitor/BookmarkListControllerTest.php b/tests/front/controller/visitor/BookmarkListControllerTest.php
index 0c95df97..5ca92507 100644
--- a/tests/front/controller/visitor/BookmarkListControllerTest.php
+++ b/tests/front/controller/visitor/BookmarkListControllerTest.php
@@ -307,7 +307,13 @@ class BookmarkListControllerTest extends TestCase
307 $this->container->conf 307 $this->container->conf
308 ->method('get') 308 ->method('get')
309 ->willReturnCallback(function (string $key, $default) { 309 ->willReturnCallback(function (string $key, $default) {
310 return $key === 'thumbnails.mode' ? Thumbnailer::MODE_ALL : $default; 310 if ($key === 'thumbnails.mode') {
311 return Thumbnailer::MODE_ALL;
312 } elseif ($key === 'general.enable_async_metadata') {
313 return false;
314 }
315
316 return $default;
311 }) 317 })
312 ; 318 ;
313 319
@@ -357,7 +363,13 @@ class BookmarkListControllerTest extends TestCase
357 $this->container->conf 363 $this->container->conf
358 ->method('get') 364 ->method('get')
359 ->willReturnCallback(function (string $key, $default) { 365 ->willReturnCallback(function (string $key, $default) {
360 return $key === 'thumbnails.mode' ? Thumbnailer::MODE_ALL : $default; 366 if ($key === 'thumbnails.mode') {
367 return Thumbnailer::MODE_ALL;
368 } elseif ($key === 'general.enable_async_metadata') {
369 return false;
370 }
371
372 return $default;
361 }) 373 })
362 ; 374 ;
363 375
@@ -379,6 +391,47 @@ class BookmarkListControllerTest extends TestCase
379 } 391 }
380 392
381 /** 393 /**
394 * Test getting a permalink with thumbnail update with async setting: no update should run.
395 */
396 public function testThumbnailUpdateFromPermalinkAsync(): void
397 {
398 $request = $this->createMock(Request::class);
399 $response = new Response();
400
401 $this->container->loginManager = $this->createMock(LoginManager::class);
402 $this->container->loginManager->method('isLoggedIn')->willReturn(true);
403
404 $this->container->conf = $this->createMock(ConfigManager::class);
405 $this->container->conf
406 ->method('get')
407 ->willReturnCallback(function (string $key, $default) {
408 if ($key === 'thumbnails.mode') {
409 return Thumbnailer::MODE_ALL;
410 } elseif ($key === 'general.enable_async_metadata') {
411 return true;
412 }
413
414 return $default;
415 })
416 ;
417
418 $this->container->thumbnailer = $this->createMock(Thumbnailer::class);
419 $this->container->thumbnailer->expects(static::never())->method('get');
420
421 $this->container->bookmarkService
422 ->expects(static::once())
423 ->method('findByHash')
424 ->willReturn((new Bookmark())->setId(2)->setUrl('https://url.tld')->setTitle('Title 1'))
425 ;
426 $this->container->bookmarkService->expects(static::never())->method('set');
427 $this->container->bookmarkService->expects(static::never())->method('save');
428
429 $result = $this->controller->permalink($request, $response, ['hash' => 'abc']);
430
431 static::assertSame(200, $result->getStatusCode());
432 }
433
434 /**
382 * Trigger legacy controller in link list controller: permalink 435 * Trigger legacy controller in link list controller: permalink
383 */ 436 */
384 public function testLegacyControllerPermalink(): void 437 public function testLegacyControllerPermalink(): void