Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix test coverage.
James Cole8f9ba21f4d88
diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.phpindex 59f47f5aa0..2d1cb6e6f4 100644--- a/app/Http/Controllers/Transaction/SingleController.php+++ b/app/Http/Controllers/Transaction/SingleController.php@@ -87,403 +87,4 @@ class SingleController extends Controller);}- /**- * CLone a transaction.- *- * @param TransactionJournal $journal- *- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector- *- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)- */- public function cloneTransaction(TransactionJournal $journal)- {- $source = $this->repository->getJournalSourceAccounts($journal)->first();- $destination = $this->repository->getJournalDestinationAccounts($journal)->first();- $budgetId = $this->repository->getJournalBudgetId($journal);- $categoryName = $this->repository->getJournalCategoryName($journal);- $tags = implode(',', $this->repository->getTags($journal));- /** @var Transaction $transaction */- $transaction = $journal->transactions()->first();- $amount = app('steam')->positive($transaction->amount);- $foreignAmount = null === $transaction->foreign_amount ? null : app('steam')->positive($transaction->foreign_amount);-- // make sure previous URI is correct:- session()->put('transactions.create.fromStore', true);- session()->put('transactions.create.uri', app('url')->previous());-- $preFilled = [- 'description' => $journal->description,- 'source_id' => $source->id,- 'source_name' => $source->name,- 'destination_id' => $destination->id,- 'destination_name' => $destination->name,- 'amount' => $amount,- 'source_amount' => $amount,- 'destination_amount' => $foreignAmount,- 'foreign_amount' => $foreignAmount,- 'native_amount' => $foreignAmount,- 'amount_currency_id_amount' => $transaction->foreign_currency_id ?? 0,- 'date' => (new Carbon())->format('Y-m-d'),- 'budget_id' => $budgetId,- 'category' => $categoryName,- 'tags' => $tags,- 'interest_date' => $this->repository->getMetaField($journal, 'interest_date'),- 'book_date' => $this->repository->getMetaField($journal, 'book_date'),- 'process_date' => $this->repository->getMetaField($journal, 'process_date'),- 'due_date' => $this->repository->getMetaField($journal, 'due_date'),- 'payment_date' => $this->repository->getMetaField($journal, 'payment_date'),- 'invoice_date' => $this->repository->getMetaField($journal, 'invoice_date'),- 'internal_reference' => $this->repository->getMetaField($journal, 'internal_reference'),- 'notes' => $this->repository->getNoteText($journal),- ];-- session()->flash('preFilled', $preFilled);-- return redirect(route('transactions.create', [strtolower($journal->transactionType->type)]));- }-- /**- * Create a new journal.- *- * @param Request $request- * @param string|null $what- *- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View- *- * @SuppressWarnings(PHPMD.CyclomaticComplexity)- */- public function create(Request $request, string $what = null)- {- $what = strtolower($what ?? TransactionType::DEPOSIT);- $what = (string)($request->old('what') ?? $what);- $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());- $preFilled = session()->has('preFilled') ? session('preFilled') : [];- $subTitle = (string)trans('form.add_new_' . $what);- $subTitleIcon = 'fa-plus';- $optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;- $source = (int)$request->get('source');-- // grab old currency ID from old data:- $currencyID = (int)$request->old('amount_currency_id_amount');- $preFilled['amount_currency_id_amount'] = $currencyID;-- if (('withdrawal' === $what || 'transfer' === $what) && $source > 0) {- $preFilled['source_id'] = $source;- }- if ('deposit' === $what && $source > 0) {- $preFilled['destination_id'] = $source;- }-- session()->put('preFilled', $preFilled);-- // put previous url in session if not redirect from store (not "create another").- if (true !== session('transactions.create.fromStore')) {- $this->rememberPreviousUri('transactions.create.uri');- }- session()->forget('transactions.create.fromStore');-- return view(- 'transactions.single.create',- compact('subTitleIcon', 'budgets', 'what', 'subTitle', 'optionalFields', 'preFilled')- );- }-- /**- * Show a special JSONified view of a transaction, for easier debug purposes.- *- * @param TransactionJournal $journal- *- * @codeCoverageIgnore- * @return JsonResponse- */- public function debugShow(TransactionJournal $journal): JsonResponse- {- $array = $journal->toArray();- $array['transactions'] = [];- $array['meta'] = [];-- /** @var Transaction $transaction */- foreach ($journal->transactions as $transaction) {- $array['transactions'][] = $transaction->toArray();- }- /** @var TransactionJournalMeta $meta */- foreach ($journal->transactionJournalMeta as $meta) {- $array['meta'][] = $meta->toArray();- }-- return response()->json($array);- }-- /**- * Shows the form that allows a user to delete a transaction journal.- *- * @param TransactionJournal $journal- *- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View- */- public function delete(TransactionJournal $journal)- {- Log::debug(sprintf('Start of delete view for journal #%d', $journal->id));- // Covered by another controller's tests- // @codeCoverageIgnoreStart- if ($this->isOpeningBalance($journal)) {- return $this->redirectToAccount($journal);- }- // @codeCoverageIgnoreEnd-- $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);- $subTitle = (string)trans('firefly.delete_' . $what, ['description' => $journal->description]);-- // put previous url in session- Log::debug('Will try to remember previous URI');- $this->rememberPreviousUri('transactions.delete.uri');-- return view('transactions.single.delete', compact('journal', 'subTitle', 'what'));- }-- /**- * Actually destroys the journal.- *- * @param TransactionJournal $transactionJournal- *- * @return \Illuminate\Http\RedirectResponse- */- public function destroy(TransactionJournal $transactionJournal): RedirectResponse- {- // @codeCoverageIgnoreStart- if ($this->isOpeningBalance($transactionJournal)) {- return $this->redirectToAccount($transactionJournal);- }- // @codeCoverageIgnoreEnd- $type = $this->repository->getTransactionType($transactionJournal);- session()->flash('success', (string)trans('firefly.deleted_' . strtolower($type), ['description' => $transactionJournal->description]));-- $this->repository->destroy($transactionJournal);-- app('preferences')->mark();-- return redirect($this->getPreviousUri('transactions.delete.uri'));- }-- /**- * Edit a journal.- *- * @param TransactionJournal $journal- *- * @param JournalRepositoryInterface $repository- *- * @return mixed- *- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)- * @SuppressWarnings(PHPMD.CyclomaticComplexity)- */- public function edit(TransactionJournal $journal, JournalRepositoryInterface $repository)- {- $transactionType = $repository->getTransactionType($journal);-- // redirect to account:- if ($transactionType === TransactionType::OPENING_BALANCE) {- return $this->redirectToAccount($journal);- }- // redirect to reconcile edit:- if ($transactionType === TransactionType::RECONCILIATION) {- return redirect(route('accounts.reconcile.edit', [$journal->id]));- }-- $what = strtolower($transactionType);- $budgetList = app('expandedform')->makeSelectListWithEmpty($this->budgets->getBudgets());-- // view related code- $subTitle = (string)trans('breadcrumbs.edit_journal', ['description' => $journal->description]);-- // journal related code- $sourceAccounts = $repository->getJournalSourceAccounts($journal);- $destinationAccounts = $repository->getJournalDestinationAccounts($journal);- $optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;- $pTransaction = $repository->getFirstPosTransaction($journal);- $foreignCurrency = $pTransaction->foreignCurrency ?? $pTransaction->transactionCurrency;- $preFilled = [- 'date' => $repository->getJournalDate($journal, null), // $journal->dateAsString()- 'interest_date' => $repository->getJournalDate($journal, 'interest_date'),- 'book_date' => $repository->getJournalDate($journal, 'book_date'),- 'process_date' => $repository->getJournalDate($journal, 'process_date'),- 'category' => $repository->getJournalCategoryName($journal),- 'budget_id' => $repository->getJournalBudgetId($journal),- 'tags' => implode(',', $repository->getTags($journal)),- 'source_id' => $sourceAccounts->first()->id,- 'source_name' => $sourceAccounts->first()->edit_name,- 'destination_id' => $destinationAccounts->first()->id,- 'destination_name' => $destinationAccounts->first()->edit_name,- 'bill_id' => $journal->bill_id,- 'bill_name' => null === $journal->bill_id ? null : $journal->bill->name,-- // new custom fields:- 'due_date' => $repository->getJournalDate($journal, 'due_date'),- 'payment_date' => $repository->getJournalDate($journal, 'payment_date'),- 'invoice_date' => $repository->getJournalDate($journal, 'invoice_date'),- 'interal_reference' => $repository->getMetaField($journal, 'internal_reference'),- 'notes' => $repository->getNoteText($journal),-- // amount fields- 'amount' => $pTransaction->amount,- 'source_amount' => $pTransaction->amount,- 'native_amount' => $pTransaction->amount,- 'destination_amount' => $pTransaction->foreign_amount,- 'currency' => $pTransaction->transactionCurrency,- 'source_currency' => $pTransaction->transactionCurrency,- 'native_currency' => $pTransaction->transactionCurrency,- 'foreign_currency' => $foreignCurrency,- 'destination_currency' => $foreignCurrency,- ];-- // amounts for withdrawals and deposits:- // amount, native_amount, source_amount, destination_amount- if (null !== $pTransaction->foreign_amount && ($journal->isWithdrawal() || $journal->isDeposit())) {- $preFilled['amount'] = $pTransaction->foreign_amount;- $preFilled['currency'] = $pTransaction->foreignCurrency;- }-- session()->flash('preFilled', $preFilled);-- // put previous url in session if not redirect from store (not "return_to_edit").- if (true !== session('transactions.edit.fromUpdate')) {- $this->rememberPreviousUri('transactions.edit.uri');- }- session()->forget('transactions.edit.fromUpdate');-- return view(- 'transactions.single.edit',- compact('journal', 'optionalFields', 'what', 'budgetList', 'subTitle')- )->with('data', $preFilled);- }-- /**- * Stores a new journal.- *- * @param JournalFormRequest $request- * @param JournalRepositoryInterface $repository- *- * @return RedirectResponse- * @throws \FireflyIII\Exceptions\FireflyException- *- *- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)- * @SuppressWarnings(PHPMD.CyclomaticComplexity)- */- public function store(JournalFormRequest $request, JournalRepositoryInterface $repository): RedirectResponse- {- $doSplit = 1 === (int)$request->get('split_journal');- $createAnother = 1 === (int)$request->get('create_another');- $data = $request->getJournalData();- $group = $repository->store($data);-- throw new FireflyException('Needs refactor');- if (null === $journal->id) {- // error!- Log::error('Could not store transaction journal.');- session()->flash('error', (string)trans('firefly.unknown_journal_error'));-- return redirect(route('transactions.create', [$request->input('what')]))->withInput();- }-- /** @var array $files */- $files = $request->hasFile('attachments') ? $request->file('attachments') : null;- $this->attachments->saveAttachmentsForModel($journal, $files);-- // store the journal only, flash the rest.- Log::debug(sprintf('Count of error messages is %d', $this->attachments->getErrors()->count()));- if (count($this->attachments->getErrors()->get('attachments')) > 0) {- session()->flash('error', $this->attachments->getErrors()->get('attachments'));- }- // flash messages- if (count($this->attachments->getMessages()->get('attachments')) > 0) {- session()->flash('info', $this->attachments->getMessages()->get('attachments'));- }-- event(new StoredTransactionGroup($group));-- session()->flash('success_uri', route('transactions.show', [$journal->id]));- session()->flash('success', (string)trans('firefly.stored_journal', ['description' => $journal->description]));- app('preferences')->mark();-- // @codeCoverageIgnoreStart- if (true === $createAnother) {- session()->put('transactions.create.fromStore', true);-- return redirect(route('transactions.create', [$request->input('what')]))->withInput();- }-- if (true === $doSplit) {- return redirect(route('transactions.split.edit', [$journal->id]));- }-- // @codeCoverageIgnoreEnd-- return redirect($this->getPreviousUri('transactions.create.uri'));- }-- /**- * Update a journal.- *- * @param JournalFormRequest $request- * @param JournalRepositoryInterface $repository- * @param TransactionJournal $journal- *- * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector- *- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)- * @SuppressWarnings(PHPMD.CyclomaticComplexity)- */- public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, TransactionJournal $journal)- {- // @codeCoverageIgnoreStart- if ($this->isOpeningBalance($journal)) {- return $this->redirectToAccount($journal);- }- // @codeCoverageIgnoreEnd-- $data = $request->getJournalData();-- // keep current bill:- $data['bill_id'] = $journal->bill_id;-- // remove it if no checkbox:- if (!$request->boolean('keep_bill_id')) {- $data['bill_id'] = null;- }- throw new FireflyException('Needs refactor');-- $journal = $repository->update($journal, $data);- /** @var array $files */- $files = $request->hasFile('attachments') ? $request->file('attachments') : null;- $this->attachments->saveAttachmentsForModel($journal, $files);-- // @codeCoverageIgnoreStart- if (count($this->attachments->getErrors()->get('attachments')) > 0) {- session()->flash('error', $this->attachments->getErrors()->get('attachments'));- }- if (count($this->attachments->getMessages()->get('attachments')) > 0) {- session()->flash('info', $this->attachments->getMessages()->get('attachments'));- }- // @codeCoverageIgnoreEnd-- event(new UpdatedTransactionGroup($group));- // update, get events by date and sort DESC-- $type = strtolower($this->repository->getTransactionType($journal));- session()->flash('success', (string)trans('firefly.updated_' . $type, ['description' => $data['description']]));- app('preferences')->mark();-- // @codeCoverageIgnoreStart- if (1 === (int)$request->get('return_to_edit')) {- session()->put('transactions.edit.fromUpdate', true);-- return redirect(route('transactions.edit', [$journal->id]))->withInput(['return_to_edit' => 1]);- }- // @codeCoverageIgnoreEnd-- // redirect to previous URL.- return redirect($this->getPreviousUri('transactions.edit.uri'));- }}diff --git a/tests/Feature/Controllers/Transaction/IndexControllerTest.php b/tests/Feature/Controllers/Transaction/IndexControllerTest.phpindex 634b4881bd..b08f6a4ec8 100644--- a/tests/Feature/Controllers/Transaction/IndexControllerTest.php+++ b/tests/Feature/Controllers/Transaction/IndexControllerTest.php@@ -99,15 +99,11 @@ class IndexControllerTest extends TestCase$userRepos = $this->mock(UserRepositoryInterface::class);$collector = $this->mock(GroupCollectorInterface::class);- // generic set for the info blocks:- $groupArray = [$this->getRandomWithdrawalAsArray()];-// role?$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);// make paginator.$paginator = new LengthAwarePaginator([$group], 1, 40, 1);- //Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('10');$collector->shouldReceive('setTypes')->atLeast()->once()->andReturnSelf();$collector->shouldReceive('setRange')->atLeast()->once()->andReturnSelf();@@ -117,13 +113,10 @@ class IndexControllerTest extends TestCase$collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();$collector->shouldReceive('withAccountInformation')->atLeast()->once()->andReturnSelf();$collector->shouldReceive('getPaginatedGroups')->atLeast()->once()->andReturn($paginator);- //$collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn($groupArray);-$pref = new Preference;$pref->data = 50;Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);- //Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');$this->be($this->user());$response = $this->get(route('transactions.index.all', ['withdrawal']));diff --git a/tests/Feature/Controllers/Transaction/ShowControllerTest.php b/tests/Feature/Controllers/Transaction/ShowControllerTest.phpnew file mode 100644index 0000000000..324fd08a2d--- /dev/null+++ b/tests/Feature/Controllers/Transaction/ShowControllerTest.php@@ -0,0 +1,85 @@+<?php+/**+ * ShowControllerTest.php+ * Copyright (c) 2019 [email protected]+ *+ * 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+ * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.+ */++namespace Tests\Feature\Controllers\Transaction;+++use Amount;+use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;+use FireflyIII\Repositories\User\UserRepositoryInterface;+use FireflyIII\Transformers\TransactionGroupTransformer;+use Log;+use Mockery;+use Tests\TestCase;++/**+ * Class ShowControllerTest+ */+class ShowControllerTest extends TestCase+{+ /**+ *+ */+ public function setUp(): void+ {+ parent::setUp();+ Log::info(sprintf('Now in %s.', get_class($this)));+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Transaction\ShowController+ */+ public function testShow(): void+ {+ $this->mockDefaultSession();++ // values+ $withdrawal = $this->getRandomWithdrawalGroup();+ $array = $this->getRandomWithdrawalGroupAsArray();++ $array[0]['transactions'][0]['foreign_amount'] = '10';+ $array[0]['transactions'][0]['foreign_currency_symbol'] = 'x';+ $array[0]['transactions'][0]['foreign_currency_decimal_places'] = 2;++ $groupRepository = $this->mock(TransactionGroupRepositoryInterface::class);+ $userRepos = $this->mock(UserRepositoryInterface::class);+ $transformer = $this->mock(TransactionGroupTransformer::class);++ // mock for transformer:+ $transformer->shouldReceive('setParameters')->atLeast()->once();+ $transformer->shouldReceive('transformObject')->atLeast()->once()->andReturn($array[0]);++ // mock for repos+ $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);+ $groupRepository->shouldReceive('getPiggyEvents')->atLeast()->once()->andReturn([]);+ $groupRepository->shouldReceive('getAttachments')->atLeast()->once()->andReturn([]);+ $groupRepository->shouldReceive('getLinks')->atLeast()->once()->andReturn([]);++ Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');+++ $this->be($this->user());+ $response = $this->get(route('transactions.show', [$withdrawal->id]));+ $response->assertStatus(200);+ // has bread crumb+ $response->assertSee('<ol class="breadcrumb">');+ }+}\ No newline at end of filediff --git a/tests/Feature/Controllers/Transaction/SingleControllerTest.php b/tests/Feature/Controllers/Transaction/SingleControllerTest.phpdeleted file mode 100644index dbee579733..0000000000--- a/tests/Feature/Controllers/Transaction/SingleControllerTest.php+++ /dev/null@@ -1,1142 +0,0 @@-<?php-/**- * SingleControllerTest.php- * Copyright (c) 2017 [email protected]- *- * 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- * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace Tests\Feature\Controllers\Transaction;--use Amount;-use DB;-use Exception;-use FireflyIII\Events\StoredTransactionJournal;-use FireflyIII\Events\UpdatedTransactionJournal;-use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;--use FireflyIII\Models\AccountType;-use FireflyIII\Models\Transaction;-use FireflyIII\Models\TransactionCurrency;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Account\AccountRepositoryInterface;-use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;-use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;-use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;-use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;-use FireflyIII\Repositories\User\UserRepositoryInterface;-use FireflyIII\Transformers\TransactionTransformer;-use Illuminate\Database\Query\JoinClause;-use Illuminate\Support\Collection;-use Illuminate\Support\MessageBag;-use Log;-use Mockery;-use Steam;-use Tests\TestCase;--/**- * Class SingleControllerTest- *- * @SuppressWarnings(PHPMD.TooManyPublicMethods)- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)- */-class SingleControllerTest extends TestCase-{- /**- *- */- public function setUp(): void- {- parent::setUp();- Log::info(sprintf('Now in %s.', get_class($this)));- }--- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testCloneTransaction(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $transformer = $this->mock(TransactionTransformer::class);- $collector = $this->mock(TransactionCollectorInterface::class);-- $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);-- $account = $this->user()->accounts()->first();- $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));- $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));- $journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);- $journalRepos->shouldReceive('getJournalCategoryName')->andReturn('');- $journalRepos->shouldReceive('getTags')->andReturn([]);- $journalRepos->shouldReceive('getMetaField')->andReturnNull();--- $journalRepos->shouldReceive('getNoteText')->andReturn('I see you...')->once();--- $this->be($this->user());- $withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first();- $response = $this->get(route('transactions.clone', [$withdrawal->id]));- $response->assertStatus(302);- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testCreate(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $transformer = $this->mock(TransactionTransformer::class);- $collector = $this->mock(TransactionCollectorInterface::class);-- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);-- $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);-- Steam::shouldReceive('phpBytes')->andReturn(2048);- $budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection)->once();- $piggyRepos->shouldReceive('getPiggyBanksWithAmount')->andReturn(new Collection)->once();--- $this->be($this->user());- $response = $this->get(route('transactions.create', ['withdrawal']));- $response->assertStatus(200);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testCreateDepositWithSource(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $transformer = $this->mock(TransactionTransformer::class);- $collector = $this->mock(TransactionCollectorInterface::class);-- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);-- Steam::shouldReceive('phpBytes')->andReturn(2048);- $budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection)->once();- $piggyRepos->shouldReceive('getPiggyBanksWithAmount')->andReturn(new Collection)->once();-- $this->be($this->user());- $response = $this->get(route('transactions.create', ['deposit']) . '?source=1');- $response->assertStatus(200);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testCreateWithSource(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);-- Steam::shouldReceive('phpBytes')->andReturn(2048);- $budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection)->once();- $piggyRepos->shouldReceive('getPiggyBanksWithAmount')->andReturn(new Collection)->once();-- $this->be($this->user());- $response = $this->get(route('transactions.create', ['withdrawal']) . '?source=1');- $response->assertStatus(200);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testDelete(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);-- $this->be($this->user());- $withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first();- $response = $this->get(route('transactions.delete', [$withdrawal->id]));- $response->assertStatus(200);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testDestroy(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);--- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);- $journalRepos->shouldReceive('destroy')->once();- $journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Withdrawal');--- $this->session(['transactions.delete.uri' => 'http://localhost']);- $this->be($this->user());- $withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first();- $response = $this->post(route('transactions.destroy', [$withdrawal->id]));- $response->assertStatus(302);- $response->assertSessionHas('success');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testEdit(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('setUser')->once();- $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);- $account = $this->user()->accounts()->first();-- $budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);- $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([]);-- // 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();- Amount::shouldReceive('getDefaultCurrency')->andReturn($currency)->times(6);-- $this->be($this->user());- $withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first();- $response = $this->get(route('transactions.edit', [$withdrawal->id]));- $response->assertStatus(200);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testEditCashDeposit(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);- $journalRepos->shouldReceive('setUser')->once();-- $budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();-- $account = $this->user()->accounts()->first();- $cash = $this->user()->accounts()->where('account_type_id', 2)->first();-- $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());- $deposit = Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('accounts.account_type_id', 2)- ->where('transaction_journals.transaction_type_id', 2)- ->whereNull('transaction_journals.deleted_at')- ->where('transaction_journals.user_id', $this->user()->id)->first(['transactions.*']);--- $response = $this->get(route('transactions.edit', [$deposit->transaction_journal_id]));- $response->assertStatus(200);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- $response->assertSee(' name="source_name" type="text" value="">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testEditCashWithdrawal(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);- $journalRepos->shouldReceive('setUser')->once();--- $budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();-- $account = $this->user()->accounts()->first();- $cash = $this->user()->accounts()->where('account_type_id', 2)->first();-- $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());- $withdrawal = Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('accounts.account_type_id', 2)- ->where('transaction_journals.transaction_type_id', 1)- ->whereNull('transaction_journals.deleted_at')- ->where('transaction_journals.user_id', $this->user()->id)->first(['transactions.*']);- $response = $this->get(route('transactions.edit', [$withdrawal->transaction_journal_id]));-- $response->assertStatus(200);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- $response->assertSee(' name="destination_name" type="text" value="">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testEditReconcile(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('getTransactionType')->andReturn('Reconciliation')->once();- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);-- $this->be($this->user());- $reconcile = TransactionJournal::where('transaction_type_id', 5)- ->whereNull('transaction_journals.deleted_at')- ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->groupBy('transaction_journals.id')- ->orderBy('ct', 'DESC')- ->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')]);-- $response = $this->get(route('transactions.edit', [$reconcile->id]));- $response->assertStatus(302);- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testEditRedirect(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);- $journalRepos->shouldReceive('setUser')->once();-- $this->be($this->user());- $withdrawal = TransactionJournal::where('transaction_type_id', 1)- ->whereNull('transaction_journals.deleted_at')- ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->groupBy('transaction_journals.id')- ->orderBy('ct', 'DESC')- ->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')]);-- $journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal');- $journalRepos->shouldReceive('countTransactions')->andReturn(3);- $response = $this->get(route('transactions.edit', [$withdrawal->id]));--- $response->assertStatus(302);- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testEditRedirectOpening(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);-- $this->be($this->user());- $journalRepos->shouldReceive('getTransactionType')->andReturn('Opening balance');- $journalRepos->shouldReceive('countTransactions')->andReturn(3);- $response = $this->get(route('transactions.edit', [1]));- $response->assertStatus(302);- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testEditTransferWithForeignAmount(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);- $journalRepos->shouldReceive('setUser')->once();--- $budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();-- $this->be($this->user());- $withdrawal = TransactionJournal::where('transaction_type_id', 3)- ->whereNull('transaction_journals.deleted_at')- ->leftJoin(- 'transactions', function (JoinClause $join) {- $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('amount', '<', 0);- }- )- ->where('user_id', $this->user()->id)- ->whereNotNull('transactions.foreign_amount')- ->first(['transaction_journals.*']);-- $account = $this->user()->accounts()->first();- $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);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testEditWithForeign(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);- $journalRepos->shouldReceive('setUser')->once();-- $account = $this->user()->accounts()->first();- $budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();-- $transaction = new Transaction;- $transaction->foreign_amount = '1';- $transaction->foreign_currency_id = 2;-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);- $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($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());- $withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first();- $response = $this->get(route('transactions.edit', [$withdrawal->id]));- $response->assertStatus(200);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- */- public function testEditWithForeignAmount(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);- $journalRepos->shouldReceive('setUser')->once();-- $budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();-- $this->be($this->user());- $withdrawal = TransactionJournal::where('transaction_type_id', 1)- ->whereNull('transaction_journals.deleted_at')- ->leftJoin(- 'transactions', function (JoinClause $join) {- $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('amount', '<', 0);- }- )- ->where('user_id', $this->user()->id)- ->whereNotNull('transactions.foreign_amount')- ->first(['transaction_journals.*']);-- $account = $this->user()->accounts()->first();- $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);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Requests\JournalFormRequest- */- public function testStoreDepositInvalidNative(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;-- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);-- // mock results:- $journal = new TransactionJournal();- $journal->id = 1000;- $journal->description = 'New deposit';-- // mock attachment helper, trigger an error AND and info thing.- $this->session(['transactions.create.uri' => 'http://localhost']);- $this->be($this->user());-- $data = [- 'what' => 'deposit',- 'amount' => '10',- 'amount_currency_id_amount' => 1,- 'destination_id' => 1,- 'destination_account_currency' => 2,- 'native_amount' => '',- 'source_name' => 'Some source',- 'date' => '2016-01-01',- 'description' => 'Test descr',- ];- $response = $this->post(route('transactions.store', ['deposit']), $data);- $response->assertStatus(302);- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Requests\JournalFormRequest- */- public function testStoreError(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;-- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);-- // mock results:- $journal = new TransactionJournal();- $journal->description = 'New journal';- $journalRepos->shouldReceive('store')->andReturn($journal);- $this->session(['transactions.create.uri' => 'http://localhost']);- $this->be($this->user());-- $data = [- 'what' => 'withdrawal',- 'amount' => '10',- 'amount_currency_id_amount' => 1,- 'source_id' => 1,- 'destination_name' => 'Some destination',- 'date' => '2016-01-01',- 'description' => 'Test descr',- ];- $response = $this->post(route('transactions.store', ['withdrawal']), $data);- $response->assertStatus(302);- $response->assertSessionHas('error');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Requests\JournalFormRequest- */- public function testStoreSuccess(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;-- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);-- // mock results:- $journal = new TransactionJournal();- $journal->id = 1000;- $journal->description = 'New journal';- $journalRepos->shouldReceive('store')->andReturn($journal);- try {- $this->expectsEvents(StoredTransactionJournal::class);- } catch (Exception $e) {- $this->assertTrue(false, $e->getMessage());- }- $errors = new MessageBag;- $errors->add('attachments', 'Fake error');-- $messages = new MessageBag;- $messages->add('attachments', 'Fake error');-- // mock attachment helper, trigger an error AND and info thing.- $attRepos->shouldReceive('saveAttachmentsForModel');- $attRepos->shouldReceive('getErrors')->andReturn($errors);- $attRepos->shouldReceive('getMessages')->andReturn($messages);-- $this->session(['transactions.create.uri' => 'http://localhost']);- $this->be($this->user());-- $data = [- 'what' => 'withdrawal',- 'amount' => '10',- 'amount_currency_id_amount' => 1,- 'source_id' => 1,- 'destination_name' => 'Some destination',- 'date' => '2016-01-01',- 'description' => 'Test descr',- ];- $response = $this->post(route('transactions.store', ['withdrawal']), $data);- $response->assertStatus(302);- $response->assertSessionHas('success');- $response->assertSessionHas('error');- $response->assertSessionHas('info');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Requests\JournalFormRequest- */- public function testStoreSuccessDeposit(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);-- // mock results:- $journal = new TransactionJournal();- $journal->id = 1000;- $journal->description = 'New deposit';- $journalRepos->shouldReceive('store')->andReturn($journal);- try {- $this->expectsEvents(StoredTransactionJournal::class);- } catch (Exception $e) {- $this->assertTrue(false, $e->getMessage());- }- $errors = new MessageBag;- $errors->add('attachments', 'Fake error');-- $messages = new MessageBag;- $messages->add('attachments', 'Fake error');-- // mock attachment helper, trigger an error AND and info thing.- $attRepos->shouldReceive('saveAttachmentsForModel');- $attRepos->shouldReceive('getErrors')->andReturn($errors);- $attRepos->shouldReceive('getMessages')->andReturn($messages);-- $this->session(['transactions.create.uri' => 'http://localhost']);- $this->be($this->user());-- $data = [- 'what' => 'deposit',- 'amount' => '10',- 'amount_currency_id_amount' => 1,- 'destination_id' => 1,- 'source_name' => 'Some source',- 'date' => '2016-01-01',- 'description' => 'Test descr',- ];- $response = $this->post(route('transactions.store', ['deposit']), $data);- $response->assertStatus(302);- $response->assertSessionHas('success');- $response->assertSessionHas('error');- $response->assertSessionHas('info');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Requests\JournalFormRequest- */- public function testStoreSuccessTransfer(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;-- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);-- // mock results:- $journal = new TransactionJournal();- $journal->id = 1000;- $journal->description = 'New transfer';- $journalRepos->shouldReceive('store')->andReturn($journal);- try {- $this->expectsEvents(StoredTransactionJournal::class);- } catch (Exception $e) {- $this->assertTrue(false, $e->getMessage());- }-- $errors = new MessageBag;- $errors->add('attachments', 'Fake error');-- $messages = new MessageBag;- $messages->add('attachments', 'Fake error');-- // mock attachment helper, trigger an error AND and info thing.- $attRepos->shouldReceive('saveAttachmentsForModel');- $attRepos->shouldReceive('getErrors')->andReturn($errors);- $attRepos->shouldReceive('getMessages')->andReturn($messages);-- $this->session(['transactions.create.uri' => 'http://localhost']);- $this->be($this->user());-- $data = [- 'what' => 'transfer',- 'amount' => '10',- 'amount_currency_id_amount' => 1,- 'destination_id' => 1,- 'source_id' => 2,- 'date' => '2016-01-01',- 'description' => 'Test descr',- ];- $response = $this->post(route('transactions.store', ['transfer']), $data);- $response->assertStatus(302);- $response->assertSessionHas('success');- $response->assertSessionHas('error');- $response->assertSessionHas('info');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Requests\JournalFormRequest- */- public function testStoreSuccessTransferForeign(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);-- // mock results:- $journal = new TransactionJournal();- $journal->id = 1000;- $journal->description = 'New transfer';- $journalRepos->shouldReceive('store')->andReturn($journal);- try {- $this->expectsEvents(StoredTransactionJournal::class);- } catch (Exception $e) {- $this->assertTrue(false, $e->getMessage());- }-- $errors = new MessageBag;- $errors->add('attachments', 'Fake error');-- $messages = new MessageBag;- $messages->add('attachments', 'Fake error');-- // mock attachment helper, trigger an error AND and info thing.- $attRepos->shouldReceive('saveAttachmentsForModel');- $attRepos->shouldReceive('getErrors')->andReturn($errors);- $attRepos->shouldReceive('getMessages')->andReturn($messages);-- $this->session(['transactions.create.uri' => 'http://localhost']);- $this->be($this->user());-- $data = [- 'what' => 'transfer',- 'amount' => '10',- 'source_amount' => '10',- 'destination_amount' => '10',- 'amount_currency_id_amount' => 1,- 'source_account_currency' => 1,- 'destination_account_currency' => 2,- 'destination_id' => 1,- 'source_id' => 2,- 'date' => '2016-01-01',- 'description' => 'Test descr',- ];- $response = $this->post(route('transactions.store', ['transfer']), $data);- $response->assertStatus(302);- $response->assertSessionHas('success');- $response->assertSessionHas('error');- $response->assertSessionHas('info');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Requests\JournalFormRequest- */- public function testStoreTransferInvalidSource(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);-- $this->session(['transactions.create.uri' => 'http://localhost']);- $this->be($this->user());-- $data = [- 'what' => 'transfer',- 'amount' => '10',- 'amount_currency_id_amount' => 1,- 'source_account_currency' => 1,- 'destination_account_currency' => 2,- 'source_amount' => '',- 'destination_id' => 1,- 'source_id' => 2,- 'date' => '2016-01-01',- 'description' => 'Test descr',- ];- $response = $this->post(route('transactions.store', ['transfer']), $data);- $response->assertStatus(302);- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Requests\JournalFormRequest- */- public function testStoreWithdrawalInvalidNative(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;-- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);--- $this->session(['transactions.create.uri' => 'http://localhost']);- $this->be($this->user());-- $data = [- 'what' => 'withdrawal',- 'amount' => '10',- 'source_id' => 1,- 'amount_currency_id_amount' => 2,- 'source_account_currency' => 3,- 'native_amount' => '',- 'destination_name' => 'Some destination',- 'date' => '2016-01-01',- 'description' => 'Test descr',- ];- $response = $this->post(route('transactions.store', ['withdrawal']), $data);- $response->assertStatus(302);- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SingleController- * @covers \FireflyIII\Http\Requests\JournalFormRequest- */- public function testUpdate(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $attachmentRepos = $this->mock(AttachmentRepositoryInterface::class);- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);- $piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);- $attRepos = $this->mock(AttachmentHelperInterface::class);- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $linkRepos = $this->mock(LinkTypeRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $transformer = $this->mock(TransactionTransformer::class);- $collector = $this->mock(TransactionCollectorInterface::class);-- $transformer->shouldReceive('setParameters')->atLeast()->once();-- $collector->shouldReceive('setUser')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('withOpposingAccount')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('withBudgetInformation')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('setJournals')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('getTransactions')->atLeast()->once()->andReturn(new Collection);--- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);-- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);- $journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal');- $journalRepos->shouldReceive('getPiggyBankEvents')->andReturn(new Collection);- $journalRepos->shouldReceive('getMetaField')->andReturn('');- $journalRepos->shouldReceive('getAttachments')->andReturn(new Collection);-- $journalRepos->shouldReceive('getNoteText')->andReturn('');- $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');--- $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);- $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);--- $linkRepos->shouldReceive('get')->andReturn(new Collection);- $linkRepos->shouldReceive('getLinks')->andReturn(new Collection);- $attRepos->shouldReceive('saveAttachmentsForModel');- $attRepos->shouldReceive('getErrors')->andReturn(new MessageBag);- $attRepos->shouldReceive('getMessages')->andReturn(new MessageBag);-- // mock- try {- $this->expectsEvents(UpdatedTransactionJournal::class);- } catch (Exception $e) {- $this->assertTrue(false, $e->getMessage());- }-- // find withdrawal:- $withdrawal = $this->getRandomWithdrawal();- $journalRepos->shouldReceive('update')->andReturn($withdrawal);-- $this->session(['transactions.edit.uri' => 'http://localhost']);- $this->be($this->user());- $data = [- 'id' => 123,- 'what' => 'withdrawal',- 'description' => 'Updated groceries',- 'source_id' => 1,- 'destination_name' => 'PLUS',- 'amount' => '123',- 'amount_currency_id_amount' => 1,- 'budget_id' => 1,- 'category' => 'Daily groceries',- 'tags' => '',- 'date' => '2016-01-01',- ];-- $response = $this->post(route('transactions.update', [$withdrawal->id]), $data);- $response->assertStatus(302);- $response->assertSessionHas('success');-- $response = $this->get(route('transactions.show', [$withdrawal->id]));- $response->assertStatus(200);- $response->assertSee($withdrawal->description);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-}diff --git a/tests/Feature/Controllers/Transaction/SplitControllerTest.php b/tests/Feature/Controllers/Transaction/SplitControllerTest.phpdeleted file mode 100644index ae6f70d11f..0000000000--- a/tests/Feature/Controllers/Transaction/SplitControllerTest.php+++ /dev/null@@ -1,458 +0,0 @@-<?php-/**- * SplitControllerTest.php- * Copyright (c) 2017 [email protected]- *- * 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- * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace Tests\Feature\Controllers\Transaction;--use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Account\AccountRepositoryInterface;-use FireflyIII\Repositories\Bill\BillRepositoryInterface;-use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;-use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;-use FireflyIII\Repositories\User\UserRepositoryInterface;-use FireflyIII\Transformers\TransactionTransformer;-use Illuminate\Support\Collection;-use Illuminate\Support\MessageBag;-use Log;-use Mockery;-use Tests\TestCase;--/**- * Class SplitControllerTest- *- * @SuppressWarnings(PHPMD.TooManyPublicMethods)- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)- */-class SplitControllerTest extends TestCase-{- /**- *- */- public function setUp(): void- {- parent::setUp();- Log::info(sprintf('Now in %s.', get_class($this)));- }--- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SplitController- */- public function testEdit(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $currencyRepository = $this->mock(CurrencyRepositoryInterface::class);- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepository = $this->mock(BudgetRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $attHelper = $this->mock(AttachmentHelperInterface::class);- $transformer = $this->mock(TransactionTransformer::class);- $collector = $this->mock(TransactionCollectorInterface::class);-- $deposit = $this->getRandomDeposit();- $destination = $deposit->transactions()->where('amount', '>', 0)->first();- $account = $destination->account;-- // mock calls- $journalRepos->shouldReceive('firstNull')->once()->andReturn($deposit);- $currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);- $budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection)->atLeast()->once();- $transformer->shouldReceive('setParameters')->atLeast()->once();- $collector->shouldReceive('setUser')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('withOpposingAccount')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('withBudgetInformation')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('setJournals')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('getTransactions')->atLeast()->once()->andReturn(new Collection);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->atLeast()->once();- $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->atLeast()->once();- $journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');- $journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once();- $journalRepos->shouldReceive('getMetaField')->andReturn('')->atLeast()->once();- $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();-- $this->be($this->user());- $response = $this->get(route('transactions.split.edit', [$deposit->id]));- $response->assertStatus(200);- // has bread crumb- $response->assertSee('<ol class="breadcrumb">');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SplitController- */- public function testEditOldInput(): void- {- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $currencyRepository = $this->mock(CurrencyRepositoryInterface::class);- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $budgetRepository = $this->mock(BudgetRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $attHelper = $this->mock(AttachmentHelperInterface::class);- $userRepos = $this->mock(UserRepositoryInterface::class);- $transformer = $this->mock(TransactionTransformer::class);- $collector = $this->mock(TransactionCollectorInterface::class);-- $deposit = $this->getRandomDeposit();- $destination = $deposit->transactions()->where('amount', '>', 0)->first();- $account = $destination->account;--- // mock calls- $journalRepos->shouldReceive('firstNull')->once()->andReturn($deposit);- $currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);- $budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection)->atLeast()->once();- $transformer->shouldReceive('setParameters')->atLeast()->once();- $collector->shouldReceive('setUser')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('withOpposingAccount')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('withBudgetInformation')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('setJournals')->atLeast()->once()->andReturnSelf();- $collector->shouldReceive('getTransactions')->atLeast()->once()->andReturn(new Collection);- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);- $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->atLeast()->once();- $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->atLeast()->once();- $journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');- $journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once();- $journalRepos->shouldReceive('getMetaField')->andReturn('')->atLeast()->once();- $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();-- $old = [- 'transactions' => [- [- 'currency_id' => 1,- 'currency_code' => 'AB',- 'currency_symbol' => 'X',- 'foreign_amount' => '0',- 'foreign_currency_id' => 2,- 'foreign_currency_code' => 'CD',- 'foreign_currency_symbol' => 'Y',- ],- [- 'currency_id' => 1,- 'currency_code' => 'AB',- 'currency_symbol' => 'X',- 'foreign_amount' => '0',- 'foreign_currency_id' => 2,- 'foreign_currency_code' => 'CD',- 'foreign_currency_symbol' => 'Y',- ],- [- 'currency_id' => 1,- 'currency_code' => 'AB',- 'currency_symbol' => 'X',- 'foreign_amount' => '0',- 'foreign_currency_id' => 2,- 'foreign_currency_code' => 'CD',- 'foreign_currency_symbol' => 'Y',- ],- [- 'currency_id' => 1,- 'currency_code' => 'AB',- 'currency_symbol' => 'X',- 'foreign_amount' => '0',- 'foreign_currency_id' => 2,- 'foreign_currency_code' => 'CD',- 'foreign_currency_symbol' => 'Y',- ],- [- 'currency_id' => 1,- 'currency_code' => 'AB',- '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">');- }--- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SplitController- */- public function testEditOpeningBalance(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $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);- $userRepos = $this->mock(UserRepositoryInterface::class);--- $opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();- $journalRepos->shouldReceive('firstNull')->once()->andReturn($opening);- $this->be($this->user());- $response = $this->get(route('transactions.split.edit', [$opening->id]));- $response->assertStatus(302);- }--- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SplitController- * @covers \FireflyIII\Http\Requests\SplitJournalFormRequest- */- public function testUpdate(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $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);- $userRepos = $this->mock(UserRepositoryInterface::class);--- $billRepos->shouldReceive('scan');- $ruleRepos->shouldReceive('setUser')->once();- $ruleRepos->shouldReceive('getActiveGroups')->andReturn(new Collection);--- $this->session(['transactions.edit-split.uri' => 'http://localhost']);- $deposit = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();- $data = [- 'id' => $deposit->id,- 'what' => 'deposit',- 'journal_description' => 'Updated salary',- 'journal_currency_id' => 1,- 'journal_destination_id' => 1,- 'journal_amount' => 1591,- 'date' => '2014-01-24',- 'tags' => '',- 'transactions' => [- [- 'transaction_description' => 'Split #1',- 'source_name' => 'Job',- 'currency_id' => 1,- 'amount' => 1591,- 'category_name' => '',- ],- ],- ];-- // mock stuff- $journalRepos->shouldReceive('update')->andReturn($deposit);- $journalRepos->shouldReceive('firstNull')->andReturn($deposit);- $journalRepos->shouldReceive('getTransactionType')->andReturn('Deposit');-- $attHelper->shouldReceive('saveAttachmentsForModel');- $attHelper->shouldReceive('getMessages')->andReturn(new MessageBag);-- $this->be($this->user());- $response = $this->post(route('transactions.split.update', [$deposit->id]), $data);- $response->assertStatus(302);- $response->assertRedirect(route('index'));- $response->assertSessionHas('success');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SplitController- * @covers \FireflyIII\Http\Requests\SplitJournalFormRequest- */- public function testUpdateOpeningBalance(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $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);- $userRepos = $this->mock(UserRepositoryInterface::class);--- $this->session(['transactions.edit-split.uri' => 'http://localhost']);- $opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();- $data = [- 'id' => $opening->id,- 'what' => 'opening balance',- 'journal_description' => 'Updated salary',- 'journal_currency_id' => 1,- 'journal_destination_id' => 1,- 'journal_amount' => 1591,- 'date' => '2014-01-24',- 'tags' => '',- 'transactions' => [- [- 'transaction_description' => 'Split #1',- 'source_name' => 'Job',- 'currency_id' => 1,- 'amount' => 1591,- 'category_name' => '',- ],- ],- ];-- $journalRepos->shouldReceive('firstNull')->once()->andReturn($opening);-- $this->be($this->user());- $response = $this->post(route('transactions.split.update', [$opening->id]), $data);- $response->assertStatus(302);- $response->assertSessionMissing('success');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SplitController- * @covers \FireflyIII\Http\Requests\SplitJournalFormRequest- */- public function testUpdateTransfer(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $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);- $userRepos = $this->mock(UserRepositoryInterface::class);-- $billRepos->shouldReceive('scan');- $ruleRepos->shouldReceive('setUser')->once();- $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();- $data = [- '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' => [- [- 'transaction_description' => 'Split #1',- 'source_id' => '1',- 'destination_id' => '2',- 'currency_id' => 1,- 'amount' => 1591,- 'category_name' => '',- ],- ],- ];-- // mock stuff- $journalRepos->shouldReceive('update')->andReturn($transfer);- $journalRepos->shouldReceive('firstNull')->andReturn($transfer);- $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');- }-- /**- * @covers \FireflyIII\Http\Controllers\Transaction\SplitController- * @covers \FireflyIII\Http\Requests\SplitJournalFormRequest- */- public function testUpdateWithdrawal(): void- { $this->markTestIncomplete('Needs to be rewritten for v4.8.0');-- return;- $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);- $userRepos = $this->mock(UserRepositoryInterface::class);--- $billRepos->shouldReceive('scan');- $ruleRepos->shouldReceive('setUser')->once();- $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 = [- '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' => [- [- 'transaction_description' => 'Split #1',- 'source_id' => '1',- 'destination_name' => 'some expense',- 'currency_id' => 1,- 'amount' => 1591,- 'category_name' => '',- ],- ],- ];-- // mock stuff- $journalRepos->shouldReceive('update')->andReturn($withdrawal);- $journalRepos->shouldReceive('firstNull')->andReturn($withdrawal);- $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');- }-}diff --git a/tests/TestCase.php b/tests/TestCase.phpindex cb335f4fe7..3f00b3e1fa 100644--- a/tests/TestCase.php+++ b/tests/TestCase.php@@ -207,13 +207,14 @@ abstract class TestCase extends BaseTestCase'currency_id' => $euro->id,'foreign_currency_id' => null,'date' => $date,- 'source_account_id' => 1,- 'destination_account_id' => 4,+ 'source_id' => 1,+ 'destination_id' => 4,'currency_name' => $euro->name,'currency_code' => $euro->code,'currency_symbol' => $euro->symbol,'currency_decimal_places' => $euro->decimal_places,'amount' => '-30',+ 'foreign_amount' => null,'budget_id' => $budget->id,],],diff --git a/tests/Unit/Helpers/Report/NetWorthTest.php b/tests/Unit/Helpers/Report/NetWorthTest.phpindex 7d86491a62..11bb06099f 100644--- a/tests/Unit/Helpers/Report/NetWorthTest.php+++ b/tests/Unit/Helpers/Report/NetWorthTest.php@@ -75,7 +75,7 @@ class NetWorthTest extends TestCase// mock other calls:$accountRepos->shouldReceive('setUser')->once();$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->times(2)->andReturn('1');- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->times(2)->andReturn('defaultAsset');+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_role'])->times(2)->andReturn('defaultAsset');$currencyRepos->shouldReceive('setUser')->once();$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->times(1);@@ -112,7 +112,7 @@ class NetWorthTest extends TestCase// mock other calls:$accountRepos->shouldReceive('setUser')->once();$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->times(2)->andReturn('1');- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->times(2)->andReturn('defaultAsset', 'ccAsset');+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_role'])->times(2)->andReturn('defaultAsset', 'ccAsset');$currencyRepos->shouldReceive('setUser')->once();$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->times(1);