Merge pull request #1577 from ArthurHoaro/fix/edit-zero
Fix a bug preventing to edit bookmark with ID #0
This commit is contained in:
commit
1db2ebbd79
2 changed files with 25 additions and 1 deletions
|
@ -127,7 +127,7 @@ public function save(Request $request, Response $response): Response
|
||||||
$this->checkToken($request);
|
$this->checkToken($request);
|
||||||
|
|
||||||
// lf_id should only be present if the link exists.
|
// lf_id should only be present if the link exists.
|
||||||
$id = $request->getParam('lf_id') ? intval(escape($request->getParam('lf_id'))) : null;
|
$id = $request->getParam('lf_id') !== null ? intval(escape($request->getParam('lf_id'))) : null;
|
||||||
if (null !== $id && true === $this->container->bookmarkService->exists($id)) {
|
if (null !== $id && true === $this->container->bookmarkService->exists($id)) {
|
||||||
// Edit
|
// Edit
|
||||||
$bookmark = $this->container->bookmarkService->get($id);
|
$bookmark = $this->container->bookmarkService->get($id);
|
||||||
|
|
|
@ -238,6 +238,30 @@ public function testSaveBookmarkWithThumbnail(): void
|
||||||
static::assertSame(302, $result->getStatusCode());
|
static::assertSame(302, $result->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test save a bookmark - with ID #0
|
||||||
|
*/
|
||||||
|
public function testSaveBookmarkWithIdZero(): void
|
||||||
|
{
|
||||||
|
$parameters = ['lf_id' => '0'];
|
||||||
|
|
||||||
|
$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->expects(static::once())->method('exists')->with(0)->willReturn(true);
|
||||||
|
$this->container->bookmarkService->expects(static::once())->method('get')->with(0)->willReturn(new Bookmark());
|
||||||
|
|
||||||
|
$result = $this->controller->save($request, $response);
|
||||||
|
|
||||||
|
static::assertSame(302, $result->getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the password with a wrong existing password
|
* Change the password with a wrong existing password
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue