Improve test coverage.

This commit is contained in:
James Cole
2019-08-01 06:21:44 +02:00
parent 9b574ce7ad
commit b049ca27f1
45 changed files with 336 additions and 251 deletions

View File

@@ -45,9 +45,6 @@ class SetDestinationAccountTest extends TestCase
*/
public function testActDepositExisting(): void
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$deposit = $this->getRandomDeposit();
$destinationTr = $deposit->transactions()->where('amount', '>', 0)->first();
@@ -82,9 +79,6 @@ class SetDestinationAccountTest extends TestCase
*/
public function testActDepositNotExisting(): void
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$deposit = $this->getRandomDeposit();
@@ -107,11 +101,8 @@ class SetDestinationAccountTest extends TestCase
*/
public function testActWithDrawalNotExisting(): void
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$account = $this->user()->accounts()->inRandomOrder()->where('account_type_id', 4)->first();
$account = $this->getRandomExpense();
$withdrawal = $this->getRandomWithdrawal();
// find account? Return account:
@@ -135,9 +126,6 @@ class SetDestinationAccountTest extends TestCase
*/
public function testActWithdrawalExisting(): void
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$withdrawal = $this->getRandomWithdrawal();
$destinationTr = $withdrawal->transactions()->where('amount', '>', 0)->first();
@@ -165,30 +153,4 @@ class SetDestinationAccountTest extends TestCase
$this->assertEquals($newDestination->id, $account->id);
}
/**
* Test this on a split journal.
*
* @covers \FireflyIII\TransactionRules\Actions\SetDestinationAccount
*/
public function testSplitJournal(): void
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$transaction = Transaction::orderBy('count', 'DESC')->groupBy('transaction_journal_id')
->get(['transaction_journal_id', DB::raw('COUNT(transaction_journal_id) as count')])
->first();
$journal = TransactionJournal::find($transaction->transaction_journal_id);
// mock
$accountRepos->shouldReceive('setUser');
// fire the action:
$ruleAction = new RuleAction;
$ruleAction->action_value = 'Some new asset ' . $this->randomInt();
$action = new SetDestinationAccount($ruleAction);
$result = $action->act($journal);
$this->assertFalse($result);
}
}