mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 08:35:00 +00:00
Improve test coverage.
This commit is contained in:
@@ -55,13 +55,17 @@ class MigrateAttachments extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
// @codeCoverageIgnoreStart
|
||||
$start = microtime(true);
|
||||
if ($this->isExecuted() && true !== $this->option('force')) {
|
||||
$this->warn('This command has already been executed.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
$attachments = Attachment::get();
|
||||
$count = 0;
|
||||
|
||||
/** @var Attachment $att */
|
||||
foreach ($attachments as $att) {
|
||||
@@ -69,6 +73,7 @@ class MigrateAttachments extends Command
|
||||
// move description:
|
||||
$description = (string)$att->description;
|
||||
if ('' !== $description) {
|
||||
|
||||
// find or create note:
|
||||
$note = $att->notes()->first();
|
||||
if (null === $note) {
|
||||
@@ -82,9 +87,16 @@ class MigrateAttachments extends Command
|
||||
$att->description = '';
|
||||
$att->save();
|
||||
|
||||
Log::debug(sprintf('Migrated attachment #%s description to note #%d', $att->id, $note->id));
|
||||
Log::debug(sprintf('Migrated attachment #%s description to note #%d.', $att->id, $note->id));
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
$this->line('All attachments are OK.');
|
||||
}
|
||||
if (0 !== $count) {
|
||||
$this->line(sprintf('Updated %d attachment(s).',$count));
|
||||
}
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Migrated attachment notes in %s seconds.', $end));
|
||||
$this->markAsExecuted();
|
||||
|
Reference in New Issue
Block a user