Fix various tests.

This commit is contained in:
James Cole 2018-03-11 21:19:35 +01:00
parent c8f52a1c40
commit 3fdb782321
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
7 changed files with 32 additions and 26 deletions

View File

@ -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"',

View File

@ -187,4 +187,3 @@ return [
// various other strings:
'imported_from_account' => 'Imported from ":account"',
];

View File

@ -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' => '',
],
],
];

View File

@ -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);

View File

@ -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;

View File

@ -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:

View File

@ -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);