Skip to content

Firefly III: a personal finances manager

Fix various tests.

James Cole3fdb782321d3
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 68fc407b58..c2d9acc508 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -647,7 +647,6 @@ return [
'bill_will_automatch' => 'Bill will automatically linked to matching transactions',
'skips_over' => 'skips over',
-
// accounts:
'details_for_asset' => 'Details for asset account ":name"',
'details_for_expense' => 'Details for expense account ":name"',
diff --git a/resources/lang/en_US/import.php b/resources/lang/en_US/import.php
index d0be62eb6c..9459769eb5 100644
--- a/resources/lang/en_US/import.php
+++ b/resources/lang/en_US/import.php
@@ -187,4 +187,3 @@ return [
// various other strings:
'imported_from_account' => 'Imported from ":account"',
];
-
diff --git a/tests/Feature/Controllers/Transaction/SplitControllerTest.php b/tests/Feature/Controllers/Transaction/SplitControllerTest.php
index 4c9ed329f8..8ffbcdc7dc 100644
--- a/tests/Feature/Controllers/Transaction/SplitControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/SplitControllerTest.php
@@ -247,7 +247,7 @@ class SplitControllerTest extends TestCase
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
// mock for new account list and for account array
$accountRepository->shouldReceive('getAccountsByType')
- ->withArgs([[AccountType::ASSET, AccountType::DEFAULT]])->andReturn(new Collection([$account]))->twice();
+ ->withArgs([[AccountType::ASSET, AccountType::DEFAULT]])->andReturn(new Collection([$account]))->twice();
$this->be($this->user());
$response = $this->get(route('transactions.split.edit', [$deposit->id]));
@@ -287,11 +287,11 @@ class SplitControllerTest extends TestCase
'tags' => '',
'transactions' => [
[
- 'description' => 'Split #1',
- 'source_account_name' => 'Job',
+ 'transaction_description' => 'Split #1',
+ 'source_name' => 'Job',
'transaction_currency_id' => 1,
'amount' => 1591,
- 'category' => '',
+ 'category_name' => '',
],
],
];
@@ -337,11 +337,11 @@ class SplitControllerTest extends TestCase
'tags' => '',
'transactions' => [
[
- 'description' => 'Split #1',
- 'source_account_name' => 'Job',
+ 'transaction_description' => 'Split #1',
+ 'source_name' => 'Job',
'transaction_currency_id' => 1,
'amount' => 1591,
- 'category' => '',
+ 'category_name' => '',
],
],
];
@@ -385,12 +385,12 @@ class SplitControllerTest extends TestCase
'tags' => '',
'transactions' => [
[
- 'description' => 'Split #1',
+ 'transaction_description' => 'Split #1',
'source_account_id' => '1',
- 'destination_account_id' => '2',
+ 'destination_id' => '2',
'transaction_currency_id' => 1,
'amount' => 1591,
- 'category' => '',
+ 'category_name' => '',
],
],
];
@@ -441,12 +441,12 @@ class SplitControllerTest extends TestCase
'tags' => '',
'transactions' => [
[
- 'description' => 'Split #1',
- 'source_account_id' => '1',
- 'destination_account_name' => 'some expense',
- 'transaction_currency_id' => 1,
- 'amount' => 1591,
- 'category' => '',
+ 'transaction_description' => 'Split #1',
+ 'source_id' => '1',
+ 'destination_name' => 'some expense',
+ 'transaction_currency_id' => 1,
+ 'amount' => 1591,
+ 'category_name' => '',
],
],
];
diff --git a/tests/Feature/Controllers/TransactionControllerTest.php b/tests/Feature/Controllers/TransactionControllerTest.php
index 17f719b6a8..c358722098 100644
--- a/tests/Feature/Controllers/TransactionControllerTest.php
+++ b/tests/Feature/Controllers/TransactionControllerTest.php
@@ -274,6 +274,12 @@ class TransactionControllerTest extends TestCase
$linkRepos->shouldReceive('get')->andReturn(new Collection);
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
+
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $journalRepos->shouldReceive('getPiggyBankEvents')->andReturn(new Collection);
+ $journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
+ $journalRepos->shouldReceive('getMetaField')->andReturn('');
+
$this->be($this->user());
$response = $this->get(route('transactions.show', [1]));
$response->assertStatus(200);
diff --git a/tests/Unit/Import/Object/ImportAccountTest.php b/tests/Unit/Import/Object/ImportAccountTest.php
index 4caeed4aaa..c134122dc6 100644
--- a/tests/Unit/Import/Object/ImportAccountTest.php
+++ b/tests/Unit/Import/Object/ImportAccountTest.php
@@ -53,7 +53,7 @@ class ImportAccountTest extends TestCase
$repository->shouldReceive('setUser')->once()->withArgs([Mockery::any()]);
$repository->shouldReceive('getAccountType')->twice()->withArgs([AccountType::ASSET])->andReturn($accountType);
$repository->shouldReceive('getAccountsByType')->twice()->withArgs([[AccountType::ASSET]])->andReturn(new Collection());
- $repository->shouldReceive('find')->once()->withArgs([1])->andReturn($account);
+ $repository->shouldReceive('findNull')->once()->withArgs([1])->andReturn($account);
// create import account.
$importAccount = new ImportAccount;
@@ -79,8 +79,6 @@ class ImportAccountTest extends TestCase
// mock calls:
$repository->shouldReceive('setUser')->once()->withArgs([Mockery::any()]);
$repository->shouldReceive('getAccountType')->once()->withArgs([AccountType::ASSET])->andReturn($accountType);
- //$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::ASSET]])->andReturn(new Collection());
- //$repository->shouldReceive('find')->once()->withArgs([1])->andReturn($account);
// create import account.
$importAccount = new ImportAccount;
diff --git a/tests/Unit/Services/Internal/Update/AccountUpdateServiceTest.php b/tests/Unit/Services/Internal/Update/AccountUpdateServiceTest.php
index c410721bfc..4f7acf8beb 100644
--- a/tests/Unit/Services/Internal/Update/AccountUpdateServiceTest.php
+++ b/tests/Unit/Services/Internal/Update/AccountUpdateServiceTest.php
@@ -52,7 +52,7 @@ class AccountUpdateServiceTest extends TestCase
$opposing = $this->user()->accounts()->first();
$journal = TransactionJournal::create(
['user_id' => $this->user()->id, 'transaction_type_id' => 4, 'transaction_currency_id' => 1, 'description' => 'IB',
- 'date' => '2018-01-01', 'completed' => true,
+ 'date' => '2018-01-01', 'completed' => true, 'tag_count' => 0,
]
);
// transactions:
@@ -180,7 +180,7 @@ class AccountUpdateServiceTest extends TestCase
$opposing = $this->user()->accounts()->first();
$journal = TransactionJournal::create(
['user_id' => $this->user()->id, 'transaction_type_id' => 4, 'transaction_currency_id' => 1, 'description' => 'IB',
- 'date' => '2018-01-01', 'completed' => true,
+ 'date' => '2018-01-01', 'completed' => true, 'tag_count' => 0,
]
);
// transactions:
@@ -235,7 +235,7 @@ class AccountUpdateServiceTest extends TestCase
$opposing = $this->user()->accounts()->first();
$journal = TransactionJournal::create(
['user_id' => $this->user()->id, 'transaction_type_id' => 4, 'transaction_currency_id' => 1, 'description' => 'IB',
- 'date' => '2018-01-01', 'completed' => true,
+ 'date' => '2018-01-01', 'completed' => true, 'tag_count' => 0,
]
);
// transactions:
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
index 1ca1ee2b14..e0d78b94d3 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
@@ -54,8 +54,12 @@ class FromAccountEndsTest extends TestCase
*/
public function testTriggeredLonger()
{
- $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
- $transaction = $journal->transactions()->where('amount', '<', 0)->first();
+ $count = 0;
+ while ($count === 0) {
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
+ $count = $journal->transactions()->where('amount', '<', 0)->count();
+ $transaction = $journal->transactions()->where('amount', '<', 0)->first();
+ }
$account = $transaction->account;
$trigger = FromAccountEnds::makeFromStrings('bla-bla-bla' . $account->name, false);