mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-21 11:48:53 +00:00
Expand tests
This commit is contained in:
@@ -143,9 +143,6 @@ class SplitController extends Controller
|
|||||||
}
|
}
|
||||||
$data = $request->getAll();
|
$data = $request->getAll();
|
||||||
$journal = $this->repository->update($journal, $data);
|
$journal = $this->repository->update($journal, $data);
|
||||||
var_dump($request->all());
|
|
||||||
var_dump($data);
|
|
||||||
exit;
|
|
||||||
|
|
||||||
/** @var array $files */
|
/** @var array $files */
|
||||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
@@ -161,7 +158,7 @@ class SplitController extends Controller
|
|||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
$type = strtolower($this->repository->getTransactionType($journal));
|
$type = strtolower($this->repository->getTransactionType($journal));
|
||||||
Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => $data['journal_description']])));
|
Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => $data['description']])));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
|
@@ -84,7 +84,7 @@ class SplitJournalFormRequest extends Request
|
|||||||
'destination_id' => $destinationId,
|
'destination_id' => $destinationId,
|
||||||
'destination_name' => $destinationName,
|
'destination_name' => $destinationName,
|
||||||
'foreign_amount' => $foreignAmount,
|
'foreign_amount' => $foreignAmount,
|
||||||
'foreign_currency_id' => $foreignCurrency,
|
'foreign_currency_id' => null,
|
||||||
'foreign_currency_code' => null,
|
'foreign_currency_code' => null,
|
||||||
'reconciled' => false,
|
'reconciled' => false,
|
||||||
'identifier' => $index,
|
'identifier' => $index,
|
||||||
|
@@ -129,19 +129,26 @@ class SingleControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEdit()
|
public function testEdit()
|
||||||
{
|
{
|
||||||
|
$account = $this->user()->accounts()->first();
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||||
|
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
||||||
|
|
||||||
$note = new Note();
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$note->id = 5;
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$note->text = 'I see you...';
|
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal')->once();
|
||||||
$repository->shouldReceive('getNote')->andReturn($note)->once();
|
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->once();
|
||||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->once();
|
||||||
$repository->shouldReceive('countTransactions')->andReturn(2);
|
$journalRepos->shouldReceive('getNoteText')->andReturn('Some Note')->once();
|
||||||
|
$journalRepos->shouldReceive('getFirstPosTransaction')->andReturn(new Transaction)->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalDate')->withAnyArgs()->andReturn('2017-09-01');
|
||||||
|
$journalRepos->shouldReceive('getMetaField')->withAnyArgs()->andReturn('')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalCategoryName')->once()->andReturn('');
|
||||||
|
$journalRepos->shouldReceive('getJournalBudgetId')->once()->andReturn(0);
|
||||||
|
$journalRepos->shouldReceive('getTags')->once()->andReturn([]);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first();
|
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first();
|
||||||
@@ -163,14 +170,33 @@ class SingleControllerTest extends TestCase
|
|||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
||||||
|
|
||||||
|
$account = $this->user()->accounts()->first();
|
||||||
|
$cash = $this->user()->accounts()->where('account_type_id', 2)->first();
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
|
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||||
|
$journalRepos->shouldReceive('getTransactionType')->andReturn('Deposit')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$cash]))->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->once();
|
||||||
|
$journalRepos->shouldReceive('getNoteText')->andReturn('Some Note')->once();
|
||||||
|
$journalRepos->shouldReceive('getFirstPosTransaction')->andReturn(new Transaction)->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalDate')->withAnyArgs()->andReturn('2017-09-01');
|
||||||
|
$journalRepos->shouldReceive('getMetaField')->withAnyArgs()->andReturn('')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalCategoryName')->once()->andReturn('');
|
||||||
|
$journalRepos->shouldReceive('getJournalBudgetId')->once()->andReturn(0);
|
||||||
|
$journalRepos->shouldReceive('getTags')->once()->andReturn([]);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$withdrawal = Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
$deposit = Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('accounts.account_type_id', 2)
|
->where('accounts.account_type_id', 2)
|
||||||
->where('transaction_journals.transaction_type_id', 2)
|
->where('transaction_journals.transaction_type_id', 2)
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
->where('transaction_journals.user_id', $this->user()->id)->first(['transactions.transaction_journal_id']);
|
->where('transaction_journals.user_id', $this->user()->id)->first(['transactions.*']);
|
||||||
$response = $this->get(route('transactions.edit', [$withdrawal->transaction_journal_id]));
|
|
||||||
|
$journalRepos->shouldReceive('first')->once()->andReturn($deposit->transactionJournal);
|
||||||
|
|
||||||
|
$response = $this->get(route('transactions.edit', [$deposit->transaction_journal_id]));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
// has bread crumb
|
// has bread crumb
|
||||||
$response->assertSee('<ol class="breadcrumb">');
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
@@ -189,14 +215,33 @@ class SingleControllerTest extends TestCase
|
|||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
||||||
|
|
||||||
|
$account = $this->user()->accounts()->first();
|
||||||
|
$cash = $this->user()->accounts()->where('account_type_id', 2)->first();
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
|
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||||
|
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$cash]))->once();
|
||||||
|
$journalRepos->shouldReceive('getNoteText')->andReturn('Some Note')->once();
|
||||||
|
$journalRepos->shouldReceive('getFirstPosTransaction')->andReturn(new Transaction)->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalDate')->withAnyArgs()->andReturn('2017-09-01');
|
||||||
|
$journalRepos->shouldReceive('getMetaField')->withAnyArgs()->andReturn('')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalCategoryName')->once()->andReturn('');
|
||||||
|
$journalRepos->shouldReceive('getJournalBudgetId')->once()->andReturn(0);
|
||||||
|
$journalRepos->shouldReceive('getTags')->once()->andReturn([]);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$withdrawal = Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
$withdrawal = Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('accounts.account_type_id', 2)
|
->where('accounts.account_type_id', 2)
|
||||||
->where('transaction_journals.transaction_type_id', 1)
|
->where('transaction_journals.transaction_type_id', 1)
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
->where('transaction_journals.user_id', $this->user()->id)->first(['transactions.transaction_journal_id']);
|
->where('transaction_journals.user_id', $this->user()->id)->first(['transactions.*']);
|
||||||
$response = $this->get(route('transactions.edit', [$withdrawal->transaction_journal_id]));
|
$journalRepos->shouldReceive('first')->once()->andReturn($withdrawal->transactionJournal);
|
||||||
|
|
||||||
|
$response = $this->get(route('transactions.edit', [$withdrawal->transaction_journal_id]));
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
// has bread crumb
|
// has bread crumb
|
||||||
$response->assertSee('<ol class="breadcrumb">');
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
@@ -209,14 +254,20 @@ class SingleControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEditReconcile()
|
public function testEditReconcile()
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$repository->shouldReceive('getTransactionType')->andReturn('Reconciliation')->once();
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$withdrawal = TransactionJournal::where('transaction_type_id', 5)
|
$reconcile = TransactionJournal::where('transaction_type_id', 5)
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->groupBy('transaction_journals.id')
|
->groupBy('transaction_journals.id')
|
||||||
->orderBy('ct', 'DESC')
|
->orderBy('ct', 'DESC')
|
||||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')]);
|
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')]);
|
||||||
$response = $this->get(route('transactions.edit', [$withdrawal->id]));
|
|
||||||
|
$repository->shouldReceive('first')->once()->andReturn($reconcile);
|
||||||
|
|
||||||
|
$response = $this->get(route('transactions.edit', [$reconcile->id]));
|
||||||
$response->assertStatus(302);
|
$response->assertStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,6 +277,8 @@ class SingleControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEditRedirect()
|
public function testEditRedirect()
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)
|
$withdrawal = TransactionJournal::where('transaction_type_id', 1)
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
@@ -233,7 +286,12 @@ class SingleControllerTest extends TestCase
|
|||||||
->groupBy('transaction_journals.id')
|
->groupBy('transaction_journals.id')
|
||||||
->orderBy('ct', 'DESC')
|
->orderBy('ct', 'DESC')
|
||||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')]);
|
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')]);
|
||||||
$response = $this->get(route('transactions.edit', [$withdrawal->id]));
|
$repository->shouldReceive('first')->once()->andReturn($withdrawal);
|
||||||
|
$repository->shouldReceive('getTransactionType')->andReturn('Withdrawal');
|
||||||
|
$repository->shouldReceive('countTransactions')->andReturn(3);
|
||||||
|
$response = $this->get(route('transactions.edit', [$withdrawal->id]));
|
||||||
|
|
||||||
|
|
||||||
$response->assertStatus(302);
|
$response->assertStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +318,23 @@ class SingleControllerTest extends TestCase
|
|||||||
->where('user_id', $this->user()->id)
|
->where('user_id', $this->user()->id)
|
||||||
->whereNotNull('transactions.foreign_amount')
|
->whereNotNull('transactions.foreign_amount')
|
||||||
->first(['transaction_journals.*']);
|
->first(['transaction_journals.*']);
|
||||||
$response = $this->get(route('transactions.edit', [$withdrawal->id]));
|
|
||||||
|
$account = $this->user()->accounts()->first();
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$journalRepos->shouldReceive('first')->once()->andReturn($withdrawal);
|
||||||
|
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||||
|
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->once();
|
||||||
|
$journalRepos->shouldReceive('getNoteText')->andReturn('Some Note')->once();
|
||||||
|
$journalRepos->shouldReceive('getFirstPosTransaction')->andReturn(new Transaction)->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalDate')->withAnyArgs()->andReturn('2017-09-01');
|
||||||
|
$journalRepos->shouldReceive('getMetaField')->withAnyArgs()->andReturn('')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalCategoryName')->once()->andReturn('');
|
||||||
|
$journalRepos->shouldReceive('getJournalBudgetId')->once()->andReturn(0);
|
||||||
|
$journalRepos->shouldReceive('getTags')->once()->andReturn([]);
|
||||||
|
|
||||||
|
$response = $this->get(route('transactions.edit', [$withdrawal->id]));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
// has bread crumb
|
// has bread crumb
|
||||||
$response->assertSee('<ol class="breadcrumb">');
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
@@ -289,7 +363,24 @@ class SingleControllerTest extends TestCase
|
|||||||
->where('user_id', $this->user()->id)
|
->where('user_id', $this->user()->id)
|
||||||
->whereNotNull('transactions.foreign_amount')
|
->whereNotNull('transactions.foreign_amount')
|
||||||
->first(['transaction_journals.*']);
|
->first(['transaction_journals.*']);
|
||||||
$response = $this->get(route('transactions.edit', [$withdrawal->id]));
|
|
||||||
|
$account = $this->user()->accounts()->first();
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$journalRepos->shouldReceive('first')->once()->andReturn($withdrawal);
|
||||||
|
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||||
|
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->once();
|
||||||
|
$journalRepos->shouldReceive('getNoteText')->andReturn('Some Note')->once();
|
||||||
|
$journalRepos->shouldReceive('getFirstPosTransaction')->andReturn(new Transaction)->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalDate')->withAnyArgs()->andReturn('2017-09-01');
|
||||||
|
$journalRepos->shouldReceive('getMetaField')->withAnyArgs()->andReturn('')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalCategoryName')->once()->andReturn('');
|
||||||
|
$journalRepos->shouldReceive('getJournalBudgetId')->once()->andReturn(0);
|
||||||
|
$journalRepos->shouldReceive('getTags')->once()->andReturn([]);
|
||||||
|
|
||||||
|
|
||||||
|
$response = $this->get(route('transactions.edit', [$withdrawal->id]));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
// has bread crumb
|
// has bread crumb
|
||||||
$response->assertSee('<ol class="breadcrumb">');
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
|
@@ -58,11 +58,23 @@ class SplitControllerTest extends TestCase
|
|||||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||||
$account = $destination->account;
|
$account = $destination->account;
|
||||||
$transactions = factory(Transaction::class, 3)->make();
|
$transactions = factory(Transaction::class, 3)->make();
|
||||||
$tasker = $this->mock(JournalTaskerInterface::class);
|
$tasker = $this->mock(JournalTaskerInterface::class);
|
||||||
|
|
||||||
|
$journalRepos->shouldReceive('first')->once()->andReturn($deposit);
|
||||||
|
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
|
||||||
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));
|
||||||
|
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
|
||||||
|
$journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once();
|
||||||
|
$journalRepos->shouldReceive('getMetaField')->andReturn('');
|
||||||
|
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||||
|
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
|
||||||
|
|
||||||
|
|
||||||
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
||||||
$accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])
|
$accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])
|
||||||
->andReturn(new Collection([$account]))->once();
|
->andReturn(new Collection([$account]))->once();
|
||||||
@@ -88,6 +100,7 @@ class SplitControllerTest extends TestCase
|
|||||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||||
$account = $destination->account;
|
$account = $destination->account;
|
||||||
@@ -100,6 +113,17 @@ class SplitControllerTest extends TestCase
|
|||||||
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||||
$tasker->shouldReceive('getTransactionsOverview')->andReturn($transactions->toArray());
|
$tasker->shouldReceive('getTransactionsOverview')->andReturn($transactions->toArray());
|
||||||
|
|
||||||
|
$journalRepos->shouldReceive('first')->once()->andReturn($deposit);
|
||||||
|
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
|
||||||
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));
|
||||||
|
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
|
||||||
|
$journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once();
|
||||||
|
$journalRepos->shouldReceive('getMetaField')->andReturn('');
|
||||||
|
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||||
|
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||||
|
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
|
||||||
|
|
||||||
|
|
||||||
$old = [
|
$old = [
|
||||||
'transactions' => [
|
'transactions' => [
|
||||||
[
|
[
|
||||||
@@ -165,7 +189,10 @@ class SplitControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEditOpeningBalance()
|
public function testEditOpeningBalance()
|
||||||
{
|
{
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
|
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
|
||||||
|
$journalRepos->shouldReceive('first')->once()->andReturn($opening);
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('transactions.split.edit', [$opening->id]));
|
$response = $this->get(route('transactions.split.edit', [$opening->id]));
|
||||||
$response->assertStatus(302);
|
$response->assertStatus(302);
|
||||||
@@ -184,17 +211,21 @@ class SplitControllerTest extends TestCase
|
|||||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$note = new Note();
|
|
||||||
$note->id = 1;
|
|
||||||
$note->text = 'Hallo';
|
|
||||||
$transactions = factory(Transaction::class, 1)->make();
|
$transactions = factory(Transaction::class, 1)->make();
|
||||||
$tasker = $this->mock(JournalTaskerInterface::class);
|
$tasker = $this->mock(JournalTaskerInterface::class);
|
||||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||||
$account = $destination->account;
|
$account = $destination->account;
|
||||||
|
|
||||||
$repository->shouldReceive('getNote')->andReturn($note);
|
$repository->shouldReceive('first')->once()->andReturn($deposit);
|
||||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
|
||||||
|
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));
|
||||||
|
$repository->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
|
||||||
|
$repository->shouldReceive('getJournalDate')->once()->andReturn('2018-01-01');
|
||||||
|
$repository->shouldReceive('getMetaField')->andReturn('');
|
||||||
|
$repository->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||||
|
$repository->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||||
|
$repository->shouldReceive('getCategoryName')->andReturn('');
|
||||||
|
|
||||||
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
||||||
$accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])
|
$accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])
|
||||||
@@ -240,8 +271,9 @@ class SplitControllerTest extends TestCase
|
|||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository->shouldReceive('updateSplitJournal')->andReturn($deposit);
|
$repository->shouldReceive('update')->andReturn($deposit);
|
||||||
$repository->shouldReceive('first')->times(2)->andReturn(new TransactionJournal);
|
$repository->shouldReceive('first')->andReturn($deposit);
|
||||||
|
$repository->shouldReceive('getTransactionType')->andReturn('Deposit');
|
||||||
|
|
||||||
$attachmentRepos = $this->mock(AttachmentHelperInterface::class);
|
$attachmentRepos = $this->mock(AttachmentHelperInterface::class);
|
||||||
$attachmentRepos->shouldReceive('saveAttachmentsForModel');
|
$attachmentRepos->shouldReceive('saveAttachmentsForModel');
|
||||||
@@ -252,13 +284,6 @@ class SplitControllerTest extends TestCase
|
|||||||
$response->assertStatus(302);
|
$response->assertStatus(302);
|
||||||
$response->assertRedirect(route('index'));
|
$response->assertRedirect(route('index'));
|
||||||
$response->assertSessionHas('success');
|
$response->assertSessionHas('success');
|
||||||
|
|
||||||
// journal is updated?
|
|
||||||
$response = $this->get(route('transactions.show', [$deposit->id]));
|
|
||||||
$response->assertStatus(200);
|
|
||||||
$response->assertSee('Updated salary');
|
|
||||||
// has bread crumb
|
|
||||||
$response->assertSee('<ol class="breadcrumb">');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,11 +292,12 @@ class SplitControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdateOpeningBalance()
|
public function testUpdateOpeningBalance()
|
||||||
{
|
{
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||||
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
|
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
|
||||||
$data = [
|
$data = [
|
||||||
'id' => $opening->id,
|
'id' => $opening->id,
|
||||||
'what' => 'deposit',
|
'what' => 'opening balance',
|
||||||
'journal_description' => 'Updated salary',
|
'journal_description' => 'Updated salary',
|
||||||
'journal_currency_id' => 1,
|
'journal_currency_id' => 1,
|
||||||
'journal_destination_account_id' => 1,
|
'journal_destination_account_id' => 1,
|
||||||
@@ -288,6 +314,18 @@ class SplitControllerTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$journalRepos->shouldReceive('first')->once()->andReturn($opening);
|
||||||
|
// $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
|
||||||
|
// $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));
|
||||||
|
//$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Opening balance');
|
||||||
|
// $journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once();
|
||||||
|
// $journalRepos->shouldReceive('getMetaField')->andReturn('');
|
||||||
|
// $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||||
|
// $journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||||
|
// $journalRepos->shouldReceive('getCategoryName')->andReturn('');
|
||||||
|
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->post(route('transactions.split.update', [$opening->id]), $data);
|
$response = $this->post(route('transactions.split.update', [$opening->id]), $data);
|
||||||
$response->assertStatus(302);
|
$response->assertStatus(302);
|
||||||
|
Reference in New Issue
Block a user