aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/controller/admin/ManageShaareControllerTest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/front/controller/admin/ManageShaareControllerTest')
-rw-r--r--tests/front/controller/admin/ManageShaareControllerTest/DisplayCreateFormTest.php10
-rw-r--r--tests/front/controller/admin/ManageShaareControllerTest/SaveBookmarkTest.php55
2 files changed, 59 insertions, 6 deletions
diff --git a/tests/front/controller/admin/ManageShaareControllerTest/DisplayCreateFormTest.php b/tests/front/controller/admin/ManageShaareControllerTest/DisplayCreateFormTest.php
index 4fd88480..eafa54eb 100644
--- a/tests/front/controller/admin/ManageShaareControllerTest/DisplayCreateFormTest.php
+++ b/tests/front/controller/admin/ManageShaareControllerTest/DisplayCreateFormTest.php
@@ -144,12 +144,14 @@ class DisplayCreateFormTest extends TestCase
144 144
145 // Make sure that PluginManager hook is triggered 145 // Make sure that PluginManager hook is triggered
146 $this->container->pluginManager 146 $this->container->pluginManager
147 ->expects(static::at(0)) 147 ->expects(static::atLeastOnce())
148 ->method('executeHooks') 148 ->method('executeHooks')
149 ->withConsecutive(['render_editlink'], ['render_includes'])
149 ->willReturnCallback(function (string $hook, array $data): array { 150 ->willReturnCallback(function (string $hook, array $data): array {
150 static::assertSame('render_editlink', $hook); 151 if ('render_editlink' === $hook) {
151 static::assertSame('', $data['link']['title']); 152 static::assertSame('', $data['link']['title']);
152 static::assertSame('', $data['link']['description']); 153 static::assertSame('', $data['link']['description']);
154 }
153 155
154 return $data; 156 return $data;
155 }) 157 })
diff --git a/tests/front/controller/admin/ManageShaareControllerTest/SaveBookmarkTest.php b/tests/front/controller/admin/ManageShaareControllerTest/SaveBookmarkTest.php
index 37542c26..1adeef5a 100644
--- a/tests/front/controller/admin/ManageShaareControllerTest/SaveBookmarkTest.php
+++ b/tests/front/controller/admin/ManageShaareControllerTest/SaveBookmarkTest.php
@@ -209,7 +209,7 @@ class SaveBookmarkTest extends TestCase
209 /** 209 /**
210 * Test save a bookmark - try to retrieve the thumbnail 210 * Test save a bookmark - try to retrieve the thumbnail
211 */ 211 */
212 public function testSaveBookmarkWithThumbnail(): void 212 public function testSaveBookmarkWithThumbnailSync(): void
213 { 213 {
214 $parameters = ['lf_url' => 'http://url.tld/other?part=3#hash']; 214 $parameters = ['lf_url' => 'http://url.tld/other?part=3#hash'];
215 215
@@ -224,7 +224,13 @@ class SaveBookmarkTest extends TestCase
224 224
225 $this->container->conf = $this->createMock(ConfigManager::class); 225 $this->container->conf = $this->createMock(ConfigManager::class);
226 $this->container->conf->method('get')->willReturnCallback(function (string $key, $default) { 226 $this->container->conf->method('get')->willReturnCallback(function (string $key, $default) {
227 return $key === 'thumbnails.mode' ? Thumbnailer::MODE_ALL : $default; 227 if ($key === 'thumbnails.mode') {
228 return Thumbnailer::MODE_ALL;
229 } elseif ($key === 'general.enable_async_metadata') {
230 return false;
231 }
232
233 return $default;
228 }); 234 });
229 235
230 $this->container->thumbnailer = $this->createMock(Thumbnailer::class); 236 $this->container->thumbnailer = $this->createMock(Thumbnailer::class);
@@ -275,6 +281,51 @@ class SaveBookmarkTest extends TestCase
275 } 281 }
276 282
277 /** 283 /**
284 * Test save a bookmark - do not attempt to retrieve thumbnails if async mode is enabled.
285 */
286 public function testSaveBookmarkWithThumbnailAsync(): void
287 {
288 $parameters = ['lf_url' => 'http://url.tld/other?part=3#hash'];
289
290 $request = $this->createMock(Request::class);
291 $request
292 ->method('getParam')
293 ->willReturnCallback(function (string $key) use ($parameters): ?string {
294 return $parameters[$key] ?? null;
295 })
296 ;
297 $response = new Response();
298
299 $this->container->conf = $this->createMock(ConfigManager::class);
300 $this->container->conf->method('get')->willReturnCallback(function (string $key, $default) {
301 if ($key === 'thumbnails.mode') {
302 return Thumbnailer::MODE_ALL;
303 } elseif ($key === 'general.enable_async_metadata') {
304 return true;
305 }
306
307 return $default;
308 });
309
310 $this->container->thumbnailer = $this->createMock(Thumbnailer::class);
311 $this->container->thumbnailer->expects(static::never())->method('get');
312
313 $this->container->bookmarkService
314 ->expects(static::once())
315 ->method('addOrSet')
316 ->willReturnCallback(function (Bookmark $bookmark): Bookmark {
317 static::assertNull($bookmark->getThumbnail());
318
319 return $bookmark;
320 })
321 ;
322
323 $result = $this->controller->save($request, $response);
324
325 static::assertSame(302, $result->getStatusCode());
326 }
327
328 /**
278 * Change the password with a wrong existing password 329 * Change the password with a wrong existing password
279 */ 330 */
280 public function testSaveBookmarkFromBookmarklet(): void 331 public function testSaveBookmarkFromBookmarklet(): void