firefly-iii/tests/Feature/Controllers/Transaction/SplitControllerTest.php

471 lines
22 KiB
PHP
Raw Normal View History

2017-02-12 11:40:39 -06:00
<?php
/**
* SplitControllerTest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
2017-10-21 01:40:00 -05:00
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 07:42:21 -06:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
2017-02-12 11:40:39 -06:00
*/
2017-06-05 00:37:53 -05:00
declare(strict_types=1);
2017-02-12 11:40:39 -06:00
namespace Tests\Feature\Controllers\Transaction;
2017-03-04 08:29:20 -06:00
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Models\Transaction;
2018-03-31 14:05:06 -05:00
use FireflyIII\Models\TransactionCurrency;
2017-02-12 11:40:39 -06:00
use FireflyIII\Models\TransactionJournal;
2017-03-03 23:53:46 -06:00
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
2018-02-28 08:50:00 -06:00
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
2017-03-03 23:53:46 -06:00
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
2017-03-04 08:29:20 -06:00
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
2018-02-28 08:50:00 -06:00
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
2017-03-03 23:53:46 -06:00
use Illuminate\Support\Collection;
2017-03-04 08:29:20 -06:00
use Illuminate\Support\MessageBag;
2018-03-24 00:08:50 -05:00
use Log;
2018-03-31 14:05:06 -05:00
use Mockery;
2017-02-12 11:40:39 -06:00
use Tests\TestCase;
/**
* Class SplitControllerTest
*
2017-08-12 03:27:45 -05:00
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2017-02-12 11:40:39 -06:00
*/
class SplitControllerTest extends TestCase
{
2018-03-24 00:08:50 -05:00
/**
*
*/
public function setUp()
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
2018-03-24 00:08:50 -05:00
}
2017-03-05 11:15:38 -06:00
/**
2018-08-09 13:17:15 -05:00
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController
2017-03-05 11:15:38 -06:00
*/
2018-05-11 12:58:10 -05:00
public function testEdit(): void
2017-03-05 11:15:38 -06:00
{
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
2018-03-07 03:18:22 -06:00
$accountRepos = $this->mock(AccountRepositoryInterface::class);
2017-03-05 11:15:38 -06:00
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
2018-02-25 10:38:24 -06:00
$journalRepos = $this->mock(JournalRepositoryInterface::class);
2018-02-28 08:50:00 -06:00
$attHelper = $this->mock(AttachmentHelperInterface::class);
2018-03-31 14:05:06 -05:00
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
2018-03-03 10:16:47 -06:00
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
$account = $destination->account;
$transactions = factory(Transaction::class, 3)->make();
$array = $transactions->toArray();
2018-03-03 07:24:06 -06:00
$array[0]['category'] = '';
2017-03-05 11:15:38 -06:00
$journalRepos->shouldReceive('firstNull')->once()->andReturn($deposit);
2018-02-25 10:38:24 -06:00
$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('');
2018-02-28 08:50:00 -06:00
$journalRepos->shouldReceive('getJournalTotal')->andReturn('0');
2018-03-03 07:24:06 -06:00
$journalRepos->shouldReceive('getJournalCategoryName')->andReturn('Some');
2018-02-25 10:38:24 -06:00
2017-03-05 11:15:38 -06:00
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
$this->be($this->user());
$response = $this->get(route('transactions.split.edit', [$deposit->id]));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
2017-12-24 04:29:16 -06:00
/**
2018-08-09 13:17:15 -05:00
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController
2017-12-24 04:29:16 -06:00
*/
2018-05-11 12:58:10 -05:00
public function testEditOldInput(): void
2017-12-24 04:29:16 -06:00
{
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
2018-03-07 03:18:22 -06:00
$accountRepos = $this->mock(AccountRepositoryInterface::class);
2017-12-24 04:29:16 -06:00
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
2018-02-25 10:38:24 -06:00
$journalRepos = $this->mock(JournalRepositoryInterface::class);
2018-02-28 08:50:00 -06:00
$attHelper = $this->mock(AttachmentHelperInterface::class);
2017-12-24 04:29:16 -06:00
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
$account = $destination->account;
$transactions = factory(Transaction::class, 3)->make();
2018-02-28 08:50:00 -06:00
2018-03-31 14:05:06 -05:00
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
2017-12-24 04:29:16 -06:00
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
2018-03-07 03:18:22 -06:00
$journalRepos->shouldReceive('firstNull')->once()->andReturn($deposit);
2018-02-25 10:38:24 -06:00
$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('');
2018-02-28 08:50:00 -06:00
$journalRepos->shouldReceive('getJournalTotal')->andReturn('0');
2018-02-25 10:38:24 -06:00
2017-12-24 04:29:16 -06:00
$old = [
'transactions' => [
[
'transaction_currency_id' => 1,
'transaction_currency_code' => 'AB',
'transaction_currency_symbol' => 'X',
'foreign_amount' => '0',
'foreign_currency_id' => 2,
'foreign_currency_code' => 'CD',
'foreign_currency_symbol' => 'Y',
],
[
'transaction_currency_id' => 1,
'transaction_currency_code' => 'AB',
'transaction_currency_symbol' => 'X',
'foreign_amount' => '0',
'foreign_currency_id' => 2,
'foreign_currency_code' => 'CD',
'foreign_currency_symbol' => 'Y',
],
[
'transaction_currency_id' => 1,
'transaction_currency_code' => 'AB',
'transaction_currency_symbol' => 'X',
'foreign_amount' => '0',
'foreign_currency_id' => 2,
'foreign_currency_code' => 'CD',
'foreign_currency_symbol' => 'Y',
],
[
'transaction_currency_id' => 1,
'transaction_currency_code' => 'AB',
'transaction_currency_symbol' => 'X',
'foreign_amount' => '0',
'foreign_currency_id' => 2,
'foreign_currency_code' => 'CD',
'foreign_currency_symbol' => 'Y',
],
[
'transaction_currency_id' => 1,
'transaction_currency_code' => 'AB',
'transaction_currency_symbol' => 'X',
'foreign_amount' => '0',
'foreign_currency_id' => 2,
'foreign_currency_code' => 'CD',
'foreign_currency_symbol' => 'Y',
],
],
];
$this->session(['_old_input' => $old]);
$this->be($this->user());
$response = $this->get(route('transactions.split.edit', [$deposit->id]));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
2017-06-05 00:37:53 -05:00
/**
2018-08-09 13:17:15 -05:00
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController
2017-06-05 00:37:53 -05:00
*/
2018-05-11 12:58:10 -05:00
public function testEditOpeningBalance(): void
2017-06-05 00:37:53 -05:00
{
2018-02-28 08:50:00 -06:00
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
2018-02-25 10:38:24 -06:00
2017-06-05 00:37:53 -05:00
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
$journalRepos->shouldReceive('firstNull')->once()->andReturn($opening);
2017-06-05 00:37:53 -05:00
$this->be($this->user());
$response = $this->get(route('transactions.split.edit', [$opening->id]));
$response->assertStatus(302);
}
2017-03-05 11:15:38 -06:00
2017-02-12 11:40:39 -06:00
/**
2018-08-09 13:17:15 -05:00
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController
2017-02-12 11:40:39 -06:00
*/
2018-05-11 12:58:10 -05:00
public function testEditSingle(): void
2017-02-12 11:40:39 -06:00
{
2017-03-03 23:53:46 -06:00
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
2018-02-28 08:50:00 -06:00
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
2017-03-03 23:53:46 -06:00
2018-02-28 08:50:00 -06:00
$transactions = factory(Transaction::class, 1)->make();
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
$account = $destination->account;
2018-03-31 14:05:06 -05:00
$accountRepository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
$journalRepos->shouldReceive('firstNull')->once()->andReturn($deposit);
2018-02-28 08:50:00 -06:00
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
$journalRepos->shouldReceive('getJournalDate')->once()->andReturn('2018-01-01');
$journalRepos->shouldReceive('getMetaField')->andReturn('');
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1');
2017-12-24 04:29:16 -06:00
2017-03-03 23:53:46 -06:00
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
2017-02-12 11:40:39 -06:00
$this->be($this->user());
$response = $this->get(route('transactions.split.edit', [$deposit->id]));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/**
2018-08-09 13:17:15 -05:00
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController
2018-03-03 10:16:47 -06:00
* @covers \FireflyIII\Http\Requests\SplitJournalFormRequest
2017-02-12 11:40:39 -06:00
*/
2018-05-11 12:58:10 -05:00
public function testUpdate(): void
2017-02-12 11:40:39 -06:00
{
2018-02-28 08:50:00 -06:00
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$billRepos->shouldReceive('scan');
2018-08-24 14:14:17 -05:00
$ruleRepos->shouldReceive('setUser')->once();
2018-02-28 08:50:00 -06:00
$ruleRepos->shouldReceive('getActiveGroups')->andReturn(new Collection);
2017-03-18 14:53:44 -05:00
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
2017-12-23 14:05:12 -06:00
$deposit = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
2017-02-12 11:40:39 -06:00
$data = [
2018-08-06 12:14:30 -05:00
'id' => $deposit->id,
'what' => 'deposit',
'journal_description' => 'Updated salary',
'journal_currency_id' => 1,
2018-06-29 22:21:21 -05:00
'journal_destination_id' => 1,
2018-08-06 12:14:30 -05:00
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
2017-02-12 11:40:39 -06:00
[
2018-03-11 15:19:35 -05:00
'transaction_description' => 'Split #1',
'source_name' => 'Job',
2017-06-05 00:37:53 -05:00
'transaction_currency_id' => 1,
'amount' => 1591,
2018-03-11 15:19:35 -05:00
'category_name' => '',
2017-02-12 11:40:39 -06:00
],
],
];
2017-03-04 08:29:20 -06:00
// mock stuff
2018-02-28 08:50:00 -06:00
$journalRepos->shouldReceive('update')->andReturn($deposit);
$journalRepos->shouldReceive('firstNull')->andReturn($deposit);
2018-02-28 08:50:00 -06:00
$journalRepos->shouldReceive('getTransactionType')->andReturn('Deposit');
2017-07-26 11:40:48 -05:00
2018-02-28 08:50:00 -06:00
$attHelper->shouldReceive('saveAttachmentsForModel');
$attHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
2017-03-04 08:29:20 -06:00
2017-02-12 11:40:39 -06:00
$this->be($this->user());
$response = $this->post(route('transactions.split.update', [$deposit->id]), $data);
$response->assertStatus(302);
2017-12-23 14:05:12 -06:00
$response->assertRedirect(route('index'));
2017-02-12 11:40:39 -06:00
$response->assertSessionHas('success');
}
2017-03-03 23:53:46 -06:00
/**
2018-08-09 13:17:15 -05:00
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController
2018-03-03 10:16:47 -06:00
* @covers \FireflyIII\Http\Requests\SplitJournalFormRequest
2017-03-03 23:53:46 -06:00
*/
2018-05-11 12:58:10 -05:00
public function testUpdateOpeningBalance(): void
2017-03-03 23:53:46 -06:00
{
2018-02-28 08:50:00 -06:00
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
2017-03-18 14:53:44 -05:00
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
2017-03-03 23:53:46 -06:00
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
$data = [
2018-08-06 12:14:30 -05:00
'id' => $opening->id,
'what' => 'opening balance',
'journal_description' => 'Updated salary',
'journal_currency_id' => 1,
2018-06-29 22:21:21 -05:00
'journal_destination_id' => 1,
2018-08-06 12:14:30 -05:00
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
2017-12-24 04:29:16 -06:00
[
2018-03-11 15:19:35 -05:00
'transaction_description' => 'Split #1',
'source_name' => 'Job',
2017-12-24 04:29:16 -06:00
'transaction_currency_id' => 1,
'amount' => 1591,
2018-03-11 15:19:35 -05:00
'category_name' => '',
2017-12-24 04:29:16 -06:00
],
],
2017-03-03 23:53:46 -06:00
];
2018-02-25 10:38:24 -06:00
$journalRepos->shouldReceive('firstNull')->once()->andReturn($opening);
2018-02-25 10:38:24 -06:00
2017-03-03 23:53:46 -06:00
$this->be($this->user());
$response = $this->post(route('transactions.split.update', [$opening->id]), $data);
$response->assertStatus(302);
$response->assertSessionMissing('success');
}
2018-03-03 10:16:47 -06:00
/**
2018-08-09 13:17:15 -05:00
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController
2018-03-03 10:16:47 -06:00
* @covers \FireflyIII\Http\Requests\SplitJournalFormRequest
*/
2018-05-11 12:58:10 -05:00
public function testUpdateTransfer(): void
2018-03-03 10:16:47 -06:00
{
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$billRepos->shouldReceive('scan');
2018-08-24 14:14:17 -05:00
$ruleRepos->shouldReceive('setUser')->once();
2018-03-03 10:16:47 -06:00
$ruleRepos->shouldReceive('getActiveGroups')->andReturn(new Collection);
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
2018-03-07 03:18:22 -06:00
$data = [
2018-08-06 12:14:30 -05:00
'id' => $transfer->id,
'what' => 'transfer',
'journal_description' => 'Some updated withdrawal',
'journal_currency_id' => 1,
'journal_source_id' => 1,
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
2018-03-03 10:16:47 -06:00
[
2018-03-11 15:19:35 -05:00
'transaction_description' => 'Split #1',
2018-08-06 12:14:30 -05:00
'source_id' => '1',
2018-03-11 15:19:35 -05:00
'destination_id' => '2',
2018-03-03 10:16:47 -06:00
'transaction_currency_id' => 1,
'amount' => 1591,
2018-03-11 15:19:35 -05:00
'category_name' => '',
2018-03-03 10:16:47 -06:00
],
],
];
// mock stuff
$journalRepos->shouldReceive('update')->andReturn($transfer);
$journalRepos->shouldReceive('firstNull')->andReturn($transfer);
2018-03-03 10:16:47 -06:00
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal');
$attHelper->shouldReceive('saveAttachmentsForModel');
$attHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
$this->be($this->user());
$response = $this->post(route('transactions.split.update', [$transfer->id]), $data);
$response->assertStatus(302);
$response->assertRedirect(route('index'));
$response->assertSessionHas('success');
}
/**
2018-08-09 13:17:15 -05:00
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController
2018-03-03 10:16:47 -06:00
* @covers \FireflyIII\Http\Requests\SplitJournalFormRequest
*/
2018-05-11 12:58:10 -05:00
public function testUpdateWithdrawal(): void
2018-03-03 10:16:47 -06:00
{
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$billRepos->shouldReceive('scan');
2018-08-24 14:14:17 -05:00
$ruleRepos->shouldReceive('setUser')->once();
2018-03-03 10:16:47 -06:00
$ruleRepos->shouldReceive('getActiveGroups')->andReturn(new Collection);
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$withdrawal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->first();
$data = [
2018-08-06 12:14:30 -05:00
'id' => $withdrawal->id,
'what' => 'withdrawal',
'journal_description' => 'Some updated withdrawal',
'journal_currency_id' => 1,
'journal_source_id' => 1,
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
2018-03-03 10:16:47 -06:00
[
2018-03-11 15:19:35 -05:00
'transaction_description' => 'Split #1',
'source_id' => '1',
'destination_name' => 'some expense',
'transaction_currency_id' => 1,
'amount' => 1591,
'category_name' => '',
2018-03-03 10:16:47 -06:00
],
],
];
// mock stuff
$journalRepos->shouldReceive('update')->andReturn($withdrawal);
$journalRepos->shouldReceive('firstNull')->andReturn($withdrawal);
2018-03-03 10:16:47 -06:00
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal');
$attHelper->shouldReceive('saveAttachmentsForModel');
$attHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
$this->be($this->user());
$response = $this->post(route('transactions.split.update', [$withdrawal->id]), $data);
$response->assertStatus(302);
$response->assertRedirect(route('index'));
$response->assertSessionHas('success');
}
2017-02-16 15:33:32 -06:00
}