[TESTS] Raise test coverage for Attachment controller to 100%

This commit is contained in:
2021-08-03 17:53:58 +00:00
parent 29d77b446f
commit e0a0df502e
2 changed files with 92 additions and 1 deletions

View File

@@ -44,8 +44,11 @@ class Attachment extends Controller
*/
private function attachment(int $id, callable $handle)
{
if ($id <= 0) {
if ($id <= 0) { // This should never happen coming from the router, but let's bail if it does
// @codeCoverageIgnoreStart
Log::critical("Attachment controller called with {$id}, which should not be possible");
throw new ClientException(_m('No such attachment'), 404);
// @codeCoverageIgnoreEnd
} else {
if (Event::handle('AttachmentFileInfo', [$id, &$res]) != Event::stop) {
// If no one else claims this attachment, use the default representation
@@ -56,7 +59,9 @@ class Attachment extends Controller
if (!empty($res)) {
return $handle($res);
} else {
// @codeCoverageIgnoreStart
throw new ClientException(_m('No such attachment'), 404);
// @codeCoverageIgnoreEnd
}
}
@@ -112,9 +117,11 @@ class Attachment extends Controller
$attachment = DB::findOneBy('attachment', ['id' => $id]);
if (!is_null($attachment->getScope())) {
// @codeCoverageIgnoreStart
// && ($attachment->scope | VisibilityScope::PUBLIC) != 0
// $user = Common::ensureLoggedIn();
assert(false, 'Attachment scope not implemented');
// @codeCoverageIgnoreEnd
}
$default_width = Common::config('thumbnail', 'width');