mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 12:11:19 +00:00
Improve test coverage.
This commit is contained in:
@@ -55,7 +55,6 @@ class ConvertControllerTest extends TestCase
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\ConvertController
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\ConvertController
|
||||
*/
|
||||
public function testIndexDepositTransfer(): void
|
||||
@@ -64,13 +63,7 @@ class ConvertControllerTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
// find deposit:
|
||||
$loop = 0;
|
||||
do {
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $deposit->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
|
||||
$deposit = $this->getRandomDeposit();
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn($deposit);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
|
||||
@@ -102,13 +95,7 @@ class ConvertControllerTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
// find deposit:
|
||||
$loop = 0;
|
||||
do {
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $deposit->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
|
||||
$deposit = $this->getRandomDeposit();
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn($deposit);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
|
||||
@@ -135,13 +122,7 @@ class ConvertControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
|
||||
// find deposit:
|
||||
$loop = 0;
|
||||
do {
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $deposit->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
|
||||
$deposit = $this->getRandomDeposit();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn($deposit);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
@@ -190,13 +171,7 @@ class ConvertControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
|
||||
// find transfer:
|
||||
$loop = 0;
|
||||
do {
|
||||
$transfer = TransactionJournal::where('transaction_type_id', 3)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $transfer->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
|
||||
$transfer = $this->getRandomTransfer();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn($transfer);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
@@ -215,13 +190,7 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexTransferWithdrawal(): void
|
||||
{
|
||||
// find transfer:
|
||||
$loop = 0;
|
||||
do {
|
||||
$transfer = TransactionJournal::where('transaction_type_id', 3)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $transfer->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
|
||||
$transfer = $this->getRandomTransfer();
|
||||
// mock stuff:
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
@@ -247,13 +216,7 @@ class ConvertControllerTest extends TestCase
|
||||
{
|
||||
|
||||
// find withdrawal:
|
||||
$loop = 0;
|
||||
do {
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $withdrawal->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
// mock stuff:
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
@@ -278,13 +241,7 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexWithdrawalTransfer(): void
|
||||
{
|
||||
// find withdrawal:
|
||||
$loop = 0;
|
||||
do {
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $withdrawal->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
// mock stuff:
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
@@ -379,13 +336,7 @@ class ConvertControllerTest extends TestCase
|
||||
$account = $this->user()->accounts()->first();
|
||||
|
||||
// find withdrawal:
|
||||
$loop = 0;
|
||||
do {
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $withdrawal->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
|
||||
// mock stuff
|
||||
$messageBag = new MessageBag;
|
||||
@@ -459,12 +410,7 @@ class ConvertControllerTest extends TestCase
|
||||
public function testPostIndexTransferDeposit(): void
|
||||
{
|
||||
// find transfer:
|
||||
$loop = 0;
|
||||
do {
|
||||
$transfer = TransactionJournal::where('transaction_type_id', 3)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $transfer->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
$transfer =$this->getRandomTransfer();
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
|
@@ -249,7 +249,9 @@ class SingleControllerTest extends TestCase
|
||||
// mock new account list:
|
||||
$currency = TransactionCurrency::first();
|
||||
$accountRepos->shouldReceive('getAccountsByType')
|
||||
->withArgs([[AccountType::ASSET, AccountType::DEFAULT, AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN,]])->andReturn(new Collection([$account]))->once();
|
||||
->withArgs(
|
||||
[[AccountType::ASSET, AccountType::DEFAULT, AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN,]]
|
||||
)->andReturn(new Collection([$account]))->once();
|
||||
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency)->times(6);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -867,13 +869,7 @@ class SingleControllerTest extends TestCase
|
||||
}
|
||||
|
||||
// find withdrawal:
|
||||
$loop = 0;
|
||||
do {
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->inRandomOrder()->where('user_id', $this->user()->id)->first();
|
||||
$count = $withdrawal->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$journalRepos->shouldReceive('update')->andReturn($withdrawal);
|
||||
|
||||
$this->session(['transactions.edit.uri' => 'http://localhost']);
|
||||
|
Reference in New Issue
Block a user