X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Ffront%2Fcontroller%2Fadmin%2FShaareManageControllerTest%2FDeleteBookmarkTest.php;h=42d0c0d658f395cfe0be64d0478baf93b1405347;hb=93175b6e9d5cfa4d4319bd58b9de01824d596288;hp=a276d988f0d1993c7278cbbf30debdab02055e17;hpb=330ac859fb13a3a15875f185a611bfaa6c5f5587;p=github%2Fshaarli%2FShaarli.git
diff --git a/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php b/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php
index a276d988..42d0c0d6 100644
--- a/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php
+++ b/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php
@@ -363,6 +363,7 @@ class DeleteBookmarkTest extends TestCase
$this->container->bookmarkService->method('get')->with('123')->willReturn(
(new Bookmark())->setId(123)->setUrl('http://domain.tld')->setTitle('Title 123')
);
+ $this->container->bookmarkService->expects(static::once())->method('remove');
$this->container->formatterFactory = $this->createMock(FormatterFactory::class);
$this->container->formatterFactory
@@ -379,6 +380,48 @@ class DeleteBookmarkTest extends TestCase
$result = $this->controller->deleteBookmark($request, $response);
static::assertSame(200, $result->getStatusCode());
- static::assertSame('', (string) $result->getBody('location'));
+ static::assertSame('', (string) $result->getBody());
+ }
+
+ /**
+ * Delete bookmark - from batch view
+ */
+ public function testDeleteBookmarkFromBatch(): void
+ {
+ $parameters = [
+ 'id' => '123',
+ 'source' => 'batch',
+ ];
+
+ $request = $this->createMock(Request::class);
+ $request
+ ->method('getParam')
+ ->willReturnCallback(function (string $key) use ($parameters): ?string {
+ return $parameters[$key] ?? null;
+ })
+ ;
+ $response = new Response();
+
+ $this->container->bookmarkService->method('get')->with('123')->willReturn(
+ (new Bookmark())->setId(123)->setUrl('http://domain.tld')->setTitle('Title 123')
+ );
+ $this->container->bookmarkService->expects(static::once())->method('remove');
+
+ $this->container->formatterFactory = $this->createMock(FormatterFactory::class);
+ $this->container->formatterFactory
+ ->expects(static::once())
+ ->method('getFormatter')
+ ->willReturnCallback(function (): BookmarkFormatter {
+ $formatter = $this->createMock(BookmarkFormatter::class);
+ $formatter->method('format')->willReturn(['formatted']);
+
+ return $formatter;
+ })
+ ;
+
+ $result = $this->controller->deleteBookmark($request, $response);
+
+ static::assertSame(204, $result->getStatusCode());
+ static::assertEmpty((string) $result->getBody());
}
}