/**
* Test save a bookmark - try to retrieve the thumbnail
*/
- public function testSaveBookmarkWithThumbnail(): void
+ public function testSaveBookmarkWithThumbnailSync(): void
{
$parameters = ['lf_url' => 'http://url.tld/other?part=3#hash'];
$this->container->conf = $this->createMock(ConfigManager::class);
$this->container->conf->method('get')->willReturnCallback(function (string $key, $default) {
- return $key === 'thumbnails.mode' ? Thumbnailer::MODE_ALL : $default;
+ if ($key === 'thumbnails.mode') {
+ return Thumbnailer::MODE_ALL;
+ } elseif ($key === 'general.enable_async_metadata') {
+ return false;
+ }
+
+ return $default;
});
$this->container->thumbnailer = $this->createMock(Thumbnailer::class);
static::assertSame(302, $result->getStatusCode());
}
+ /**
+ * Test save a bookmark - do not attempt to retrieve thumbnails if async mode is enabled.
+ */
+ public function testSaveBookmarkWithThumbnailAsync(): void
+ {
+ $parameters = ['lf_url' => 'http://url.tld/other?part=3#hash'];
+
+ $request = $this->createMock(Request::class);
+ $request
+ ->method('getParam')
+ ->willReturnCallback(function (string $key) use ($parameters): ?string {
+ return $parameters[$key] ?? null;
+ })
+ ;
+ $response = new Response();
+
+ $this->container->conf = $this->createMock(ConfigManager::class);
+ $this->container->conf->method('get')->willReturnCallback(function (string $key, $default) {
+ if ($key === 'thumbnails.mode') {
+ return Thumbnailer::MODE_ALL;
+ } elseif ($key === 'general.enable_async_metadata') {
+ return true;
+ }
+
+ return $default;
+ });
+
+ $this->container->thumbnailer = $this->createMock(Thumbnailer::class);
+ $this->container->thumbnailer->expects(static::never())->method('get');
+
+ $this->container->bookmarkService
+ ->expects(static::once())
+ ->method('addOrSet')
+ ->willReturnCallback(function (Bookmark $bookmark): Bookmark {
+ static::assertNull($bookmark->getThumbnail());
+
+ return $bookmark;
+ })
+ ;
+
+ $result = $this->controller->save($request, $response);
+
+ static::assertSame(302, $result->getStatusCode());
+ }
+
/**
* Change the password with a wrong existing password
*/