. */ declare(strict_types=1); namespace Tests\Feature\Controllers\Transaction; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Models\AccountType; use FireflyIII\Models\Transaction; 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\Journal\JournalTaskerInterface; use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; use Illuminate\Support\Collection; use Illuminate\Support\MessageBag; use Tests\TestCase; /** * Class SplitControllerTest * * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SplitControllerTest extends TestCase { /** * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::edit * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::__construct * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::arrayFromJournal * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::updateWithPrevious * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::getTransactionDataFromJournal */ public function testEdit() { $currencyRepository = $this->mock(CurrencyRepositoryInterface::class); $accountRepository = $this->mock(AccountRepositoryInterface::class); $budgetRepository = $this->mock(BudgetRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $tasker = $this->mock(JournalTaskerInterface::class); $attHelper = $this->mock(AttachmentHelperInterface::class); $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(); $journalRepos->shouldReceive('first')->once()->andReturn($deposit); $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account])); $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account])); $journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit'); $journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once(); $journalRepos->shouldReceive('getMetaField')->andReturn(''); $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once(); $journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0); $journalRepos->shouldReceive('getCategoryName')->andReturn(''); $journalRepos->shouldReceive('getJournalTotal')->andReturn('0'); $currencyRepository->shouldReceive('get')->once()->andReturn(new Collection); $accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]]) ->andReturn(new Collection([$account]))->once(); $budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection); $tasker->shouldReceive('getTransactionsOverview')->andReturn($transactions->toArray()); $this->be($this->user()); $response = $this->get(route('transactions.split.edit', [$deposit->id])); $response->assertStatus(200); // has bread crumb $response->assertSee('