Fixed phpstan

This commit is contained in:
Nicolas Lœuillet 2024-10-31 17:49:44 +01:00
parent e1fef1e625
commit a7814c8129
2 changed files with 7 additions and 4 deletions

View File

@ -798,9 +798,12 @@ class EntryRestController extends WallabagRestController
$errors = $validator->validate($entry); $errors = $validator->validate($entry);
if (\count($errors) > 0) { if (\count($errors) > 0) {
$errorsString = (string) $errors; $errorsString = '';
foreach ($errors as $error) {
$errorsString .= $error->getMessage() . "\n";
}
return $this->sendResponse($errorsString); throw new BadRequestHttpException($errorsString);
} }
$this->entityManager->persist($entry); $this->entityManager->persist($entry);

View File

@ -614,10 +614,10 @@ class EntryRestControllerTest extends WallabagApiTestCase
'public' => 1, 'public' => 1,
]); ]);
$this->assertSame(200, $this->client->getResponse()->getStatusCode()); $this->assertSame(400, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true); $content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertStringContainsString('The url \'"wallabagIsAwesome"\' is not a valid url', $content); $this->assertStringContainsString('The url \'"wallabagIsAwesome"\' is not a valid url', $content['message']);
} }
public function testPostEntry() public function testPostEntry()