mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 22:58:09 +00:00
Some code optimisations.
This commit is contained in:
@@ -48,42 +48,6 @@ class ConvertToDepositTest extends TestCase
|
||||
Log::info(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a withdrawal to a deposit.
|
||||
*
|
||||
* @covers \FireflyIII\TransactionRules\Actions\ConvertToDeposit
|
||||
*/
|
||||
public function testActWithdrawal()
|
||||
{
|
||||
$revenue = $this->getRandomRevenue();
|
||||
$name = 'Random revenue #' . random_int(1, 10000);
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
|
||||
// journal is a withdrawal:
|
||||
$this->assertEquals(TransactionType::WITHDRAWAL, $journal->transactionType->type);
|
||||
|
||||
// mock used stuff:
|
||||
$factory = $this->mock(AccountFactory::class);
|
||||
$factory->shouldReceive('setUser')->once();
|
||||
$factory->shouldReceive('findOrCreate')->once()->withArgs([$name, AccountType::REVENUE])->andReturn($revenue);
|
||||
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $name;
|
||||
$action = new ConvertToDeposit($ruleAction);
|
||||
try {
|
||||
$result = $action->act($journal);
|
||||
} catch (Exception $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
$this->assertTrue($result);
|
||||
|
||||
// journal is now a deposit.
|
||||
$journal->refresh();
|
||||
$this->assertEquals(TransactionType::DEPOSIT, $journal->transactionType->type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a transfer to a deposit.
|
||||
*
|
||||
@@ -120,5 +84,41 @@ class ConvertToDepositTest extends TestCase
|
||||
$this->assertEquals(TransactionType::DEPOSIT, $journal->transactionType->type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a withdrawal to a deposit.
|
||||
*
|
||||
* @covers \FireflyIII\TransactionRules\Actions\ConvertToDeposit
|
||||
*/
|
||||
public function testActWithdrawal()
|
||||
{
|
||||
$revenue = $this->getRandomRevenue();
|
||||
$name = 'Random revenue #' . random_int(1, 10000);
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
|
||||
// journal is a withdrawal:
|
||||
$this->assertEquals(TransactionType::WITHDRAWAL, $journal->transactionType->type);
|
||||
|
||||
// mock used stuff:
|
||||
$factory = $this->mock(AccountFactory::class);
|
||||
$factory->shouldReceive('setUser')->once();
|
||||
$factory->shouldReceive('findOrCreate')->once()->withArgs([$name, AccountType::REVENUE])->andReturn($revenue);
|
||||
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $name;
|
||||
$action = new ConvertToDeposit($ruleAction);
|
||||
try {
|
||||
$result = $action->act($journal);
|
||||
} catch (Exception $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
$this->assertTrue($result);
|
||||
|
||||
// journal is now a deposit.
|
||||
$journal->refresh();
|
||||
$this->assertEquals(TransactionType::DEPOSIT, $journal->transactionType->type);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user