mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Test improv
This commit is contained in:
parent
2630732b8a
commit
4c10f2b960
@ -76,7 +76,8 @@ class FixLongDescriptions extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$end = round(microtime(true) - $start, 2);
|
$end = round(microtime(true) - $start, 2);
|
||||||
$this->info(sprintf('Verified all transaction group and journal title lengths in %s seconds.', $end));
|
$this->info('Verified all transaction group and journal title lengths.');
|
||||||
|
$this->info(sprintf('Took %s seconds.', $end));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class FixRecurringTransactions extends Command
|
|||||||
|
|
||||||
|
|
||||||
$end = round(microtime(true) - $start, 2);
|
$end = round(microtime(true) - $start, 2);
|
||||||
$this->info(sprintf('Corrected recurring transactions %s seconds.', $end));
|
$this->info(sprintf('Corrected recurring transactions in %s seconds.', $end));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ use Tests\TestCase;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FixGroupAccountsTest
|
* Class FixGroupAccountsTest
|
||||||
* @package Tests\Feature\Console\Commands\Correction
|
|
||||||
*/
|
*/
|
||||||
class FixGroupAccountsTest extends TestCase
|
class FixGroupAccountsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -34,9 +34,40 @@ class FixLongDescriptionsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testHandle(): void
|
public function testHandle(): void
|
||||||
{
|
{
|
||||||
|
$journal = $this->getRandomWithdrawal();
|
||||||
|
$original = $journal->description;
|
||||||
|
$journal->description = str_repeat('ABCDEF123456x', 200);
|
||||||
|
$journal->save();
|
||||||
|
|
||||||
|
|
||||||
$this->artisan('firefly-iii:fix-long-descriptions')
|
$this->artisan('firefly-iii:fix-long-descriptions')
|
||||||
->expectsOutput('Verified all transaction group and journal title lengths')
|
->expectsOutput(sprintf('Truncated description of transaction journal #%d', $journal->id))
|
||||||
|
->expectsOutput('Verified all transaction group and journal title lengths.')
|
||||||
->assertExitCode(0);
|
->assertExitCode(0);
|
||||||
|
|
||||||
|
$journal->description = $original;
|
||||||
|
$journal->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Console\Commands\Correction\FixLongDescriptions
|
||||||
|
*/
|
||||||
|
public function testHandleGroup(): void
|
||||||
|
{
|
||||||
|
$journal = $this->getRandomWithdrawal();
|
||||||
|
$group = $journal->transactionGroup;
|
||||||
|
$original = $group->title;
|
||||||
|
$group->title = str_repeat('ABCDEF123456x', 200);
|
||||||
|
$group->save();
|
||||||
|
|
||||||
|
|
||||||
|
$this->artisan('firefly-iii:fix-long-descriptions')
|
||||||
|
->expectsOutput(sprintf('Truncated description of transaction group #%d', $group->id))
|
||||||
|
->expectsOutput('Verified all transaction group and journal title lengths.')
|
||||||
|
->assertExitCode(0);
|
||||||
|
|
||||||
|
$group->title = $original;
|
||||||
|
$group->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* FixRecurringTransactionsTest.php
|
||||||
|
* Copyright (c) 2020 james@firefly-iii.org
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\Feature\Console\Commands\Correction;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Models\Recurrence;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class FixRecurringTransactionsTest
|
||||||
|
*/
|
||||||
|
class FixRecurringTransactionsTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Console\Commands\Correction\FixRecurringTransactions
|
||||||
|
*/
|
||||||
|
public function testHandle(): void
|
||||||
|
{
|
||||||
|
// test DB contains a broken recurring transaction.
|
||||||
|
$recurring = Recurrence::whereTitle('broken_recurrence')->first();
|
||||||
|
|
||||||
|
|
||||||
|
$this->artisan('firefly-iii:fix-recurring-transactions')
|
||||||
|
->expectsOutput(sprintf('Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.',
|
||||||
|
$recurring->id, 'Withdrawal','Transfer',
|
||||||
|
))
|
||||||
|
->assertExitCode(0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* FixTransactionTypesTest.php
|
||||||
|
* Copyright (c) 2020 james@firefly-iii.org
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\Feature\Console\Commands\Correction;
|
||||||
|
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class FixTransactionTypesTest
|
||||||
|
*/
|
||||||
|
class FixTransactionTypesTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Console\Commands\Correction\FixTransactionTypes
|
||||||
|
*/
|
||||||
|
public function testHandle(): void
|
||||||
|
{
|
||||||
|
$this->artisan('firefly-iii:fix-transaction-types')
|
||||||
|
->expectsOutput(sprintf('Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.',
|
||||||
|
$recurring->id, 'Withdrawal','Transfer',
|
||||||
|
))
|
||||||
|
->assertExitCode(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -149,7 +149,7 @@ trait CollectsValues
|
|||||||
]
|
]
|
||||||
)->first();
|
)->first();
|
||||||
if (null === $result) {
|
if (null === $result) {
|
||||||
throw new FireflyException(sprintf('Cannot find suitable %s to use.', $type));
|
throw new FireflyException(sprintf('Cannot find suitable journal "%s" to use.', $type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TransactionJournal::find((int) $result->transaction_journal_id);
|
return TransactionJournal::find((int) $result->transaction_journal_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user