Also test attachments.

This commit is contained in:
James Cole
2021-03-13 14:33:48 +01:00
parent bd040c80b2
commit bdb298740a
19 changed files with 446 additions and 99 deletions

View File

@@ -170,14 +170,19 @@ class AttachmentRepository implements AttachmentRepositoryInterface
*/
public function update(Attachment $attachment, array $data): Attachment
{
$attachment->title = $data['title'];
if (array_key_exists('title', $data)) {
$attachment->title = $data['title'];
}
// update filename, if present and different:
if (isset($data['filename']) && '' !== $data['filename'] && $data['filename'] !== $attachment->filename) {
$attachment->filename = $data['filename'];
if (array_key_exists('filename', $data)) {
if ('' !== (string)$data['filename'] && $data['filename'] !== $attachment->filename) {
$attachment->filename = $data['filename'];
}
}
$attachment->save();
$this->updateNote($attachment, $data['notes'] ?? '');
if (array_key_exists('notes', $data)) {
$this->updateNote($attachment, (string)$data['notes']);
}
return $attachment;
}