Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Expand test code.
James Colec7d4ff6f27af
diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.phpindex 04152582fe..897e4b9dee 100644--- a/app/Http/Controllers/Account/ReconcileController.php+++ b/app/Http/Controllers/Account/ReconcileController.php@@ -183,7 +183,7 @@ class ReconcileController extends Controller$currencyId = intval($account->getMeta('currency_id'));$currency = $currencyRepos->find($currencyId);if (0 === $currencyId) {- $currency = app('amount')->getDefaultCurrency();+ $currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore}// no start or end:@@ -233,9 +233,10 @@ class ReconcileController extends Controller// get main transaction:$transaction = $repository->getAssetTransaction($journal);+ $account = $transaction->account;- return view('accounts.reconcile.show', compact('journal', 'subTitle', 'transaction'));+ return view('accounts.reconcile.show', compact('journal', 'subTitle', 'transaction', 'account'));}/**@@ -250,7 +251,7 @@ class ReconcileController extends Controller{/** @var JournalRepositoryInterface $repository */$repository = app(JournalRepositoryInterface::class);- $transactions = $repository->getTransactionsById($request->get('transactions'));+ $transactions = $repository->getTransactionsById($request->get('transactions') ?? []);/** @var Transaction $transaction */foreach ($transactions as $transaction) {$repository->reconcile($transaction); // mark as reconciled.@@ -313,7 +314,7 @@ class ReconcileController extends Controller$currencyId = intval($account->getMeta('currency_id'));$currency = $currencyRepos->find($currencyId);if (0 === $currencyId) {- $currency = app('amount')->getDefaultCurrency();+ $currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore}$startBalance = round(app('steam')->balance($account, $startDate), $currency->decimal_places);@@ -383,7 +384,7 @@ class ReconcileController extends Controller/** @var Transaction $transaction */$transaction = $account->transactions()->first();if (null === $transaction) {- throw new FireflyException('Expected a transaction. This account has none. BEEP, error.');+ throw new FireflyException(sprintf('Expected a transaction. Account #%d has none. BEEP, error.', $account->id)); // @codeCoverageIgnore}$journal = $transaction->transactionJournal;diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.phpindex 858e889edb..45f273a65d 100644--- a/app/Http/Controllers/Auth/LoginController.php+++ b/app/Http/Controllers/Auth/LoginController.php@@ -32,21 +32,15 @@ use Illuminate\Http\Request;use Schema;/**+ * @codeCoverageIgnore* Class LoginController+ *+ * This controller handles authenticating users for the application and+ * redirecting them to your home screen. The controller uses a trait+ * to conveniently provide its functionality to your applications.*/class LoginController extends Controller{- /*- |--------------------------------------------------------------------------- | Login Controller- |--------------------------------------------------------------------------- |- | This controller handles authenticating users for the application and- | redirecting them to your home screen. The controller uses a trait- | to conveniently provide its functionality to your applications.- |- */-use AuthenticatesUsers;/**diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.phpindex be017a3e17..39dff86f73 100644--- a/app/Http/Controllers/Auth/RegisterController.php+++ b/app/Http/Controllers/Auth/RegisterController.php@@ -32,20 +32,15 @@ use Illuminate\Support\Facades\Validator;use Session;/**+ * @codeCoverageIgnore* Class RegisterController+ *+ * This controller handles the registration of new users as well as their+ * validation and creation. By default this controller uses a trait to+ * provide this functionality without requiring any additional code.*/class RegisterController extends Controller{- /*- |--------------------------------------------------------------------------- | Register Controller- |--------------------------------------------------------------------------- |- | This controller handles the registration of new users as well as their- | validation and creation. By default this controller uses a trait to- | provide this functionality without requiring any additional code.- |- */use RegistersUsers;diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.phpindex 3dce99c529..d07102819d 100644--- a/app/Http/Controllers/Auth/ResetPasswordController.php+++ b/app/Http/Controllers/Auth/ResetPasswordController.php@@ -26,21 +26,15 @@ use FireflyIII\Http\Controllers\Controller;use Illuminate\Foundation\Auth\ResetsPasswords;/**+ * @codeCoverageIgnore* Class ResetPasswordController+ *+ * This controller is responsible for handling password reset requests+ * and uses a simple trait to include this behavior. You're free to+ * explore this trait and override any methods you wish to tweak.*/class ResetPasswordController extends Controller{- /*- |--------------------------------------------------------------------------- | Password Reset Controller- |--------------------------------------------------------------------------- |- | This controller is responsible for handling password reset requests- | and uses a simple trait to include this behavior. You're free to- | explore this trait and override any methods you wish to tweak.- |- */-use ResetsPasswords;/**diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.phpindex 87608ada26..b1b145b07b 100644--- a/app/Http/Controllers/BudgetController.php+++ b/app/Http/Controllers/BudgetController.php@@ -303,7 +303,7 @@ class BudgetController extends Controller++$count;}if ($count === 0) {- $count = 1;+ $count = 1; // @codeCoverageIgnore}$result['available'] = bcdiv($total, strval($count));diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.phpindex c699b4a2a7..1c0a8ddcac 100644--- a/app/Http/Controllers/Chart/CategoryController.php+++ b/app/Http/Controllers/Chart/CategoryController.php@@ -73,7 +73,7 @@ class CategoryController extends Controller$start = $repository->firstUseDate($category);if (null === $start) {- $start = new Carbon;+ $start = new Carbon; // @codeCoverageIgnore}$range = Preferences::get('viewRange', '1M')->data;diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.phpindex ec042edbed..59e9b9150c 100644--- a/app/Http/Controllers/Chart/ExpenseReportController.php+++ b/app/Http/Controllers/Chart/ExpenseReportController.php@@ -82,7 +82,7 @@ class ExpenseReportController extends Controller$cache->addProperty($start);$cache->addProperty($end);if ($cache->has()) {- // return Response::json($cache->get()); // @codeCoverageIgnore+ return Response::json($cache->get()); // @codeCoverageIgnore}$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.phpindex 2dcfad0eab..2744d77fd4 100644--- a/app/Http/Controllers/RuleController.php+++ b/app/Http/Controllers/RuleController.php@@ -417,7 +417,7 @@ class RuleController extends Controller$triggers = $rule->ruleTriggers;if (0 === count($triggers)) {- return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]);+ return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore}$limit = intval(config('firefly.test-triggers.limit'));diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.phpindex 64665ece61..7d3b8acf3b 100644--- a/app/Http/breadcrumbs.php+++ b/app/Http/breadcrumbs.php@@ -98,6 +98,23 @@ Breadcrumbs::register(});+Breadcrumbs::register(+ 'accounts.reconcile',+ function (BreadCrumbGenerator $breadcrumbs, Account $account) {+ $breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon);+ $breadcrumbs->push(trans('firefly.reconcile_account', ['account' => e($account->name)]), route('accounts.reconcile', [$account->id]));+ }+);++Breadcrumbs::register(+ 'accounts.reconcile.show',+ function (BreadCrumbGenerator $breadcrumbs, Account $account, TransactionJournal $journal) {+ $breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon);+ $title = trans('firefly.reconciliation') . ' "' . $journal->description . '"';+ $breadcrumbs->push($title, route('accounts.reconcile.show', [$journal->id]));+ }+);+Breadcrumbs::register('accounts.delete',function (BreadCrumbGenerator $breadcrumbs, Account $account) {diff --git a/resources/views/accounts/reconcile/show.twig b/resources/views/accounts/reconcile/show.twigindex 0dab366f46..f18ebaf3b5 100644--- a/resources/views/accounts/reconcile/show.twig+++ b/resources/views/accounts/reconcile/show.twig@@ -1,7 +1,7 @@{% extends "./layout/default" %}{% block breadcrumbs %}- {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, journal) }}+ {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, journal) }}{% endblock %}{% block content %}diff --git a/tests/Feature/Controllers/Account/ReconcileControllerTest.php b/tests/Feature/Controllers/Account/ReconcileControllerTest.phpnew file mode 100644index 0000000000..ed20501594--- /dev/null+++ b/tests/Feature/Controllers/Account/ReconcileControllerTest.php@@ -0,0 +1,286 @@+<?php+/**+ * ReconcileControllerTest.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\Account;++use FireflyIII\Models\Transaction;+use Tests\TestCase;++/**+ * Class ConfigurationControllerTest+ *+ * @SuppressWarnings(PHPMD.TooManyPublicMethods)+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)+ */+class ReconcileControllerTest extends TestCase+{+ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::edit+ */+ public function testEdit()+ {+ $journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();++ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile.edit', [$journal->id]));+ $response->assertStatus(200);++ // has bread crumb+ $response->assertSee('<ol class="breadcrumb">');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::edit+ */+ public function testEditRedirect()+ {+ $journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();++ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile.edit', [$journal->id]));+ $response->assertStatus(302);+ $response->assertRedirect(route('transactions.edit', [$journal->id]));+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::overview()+ */+ public function testOverview()+ {+ $parameters = [+ 'startBalance' => '0',+ 'endBalance' => '10',+ 'transactions' => [1, 2, 3],+ 'cleared' => [4, 5, 6],+ ];+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile.overview', [1, '20170101', '20170131']) . '?' . http_build_query($parameters));+ $response->assertStatus(200);+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::overview()+ * @expectedExceptionMessage is not an asset account+ */+ public function testOverviewNotAsset()+ {+ $account = $this->user()->accounts()->where('account_type_id', '!=', 3)->first();+ $parameters = [+ 'startBalance' => '0',+ 'endBalance' => '10',+ 'transactions' => [1, 2, 3],+ 'cleared' => [4, 5, 6],+ ];+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile.overview', [$account->id, '20170101', '20170131']) . '?' . http_build_query($parameters));+ $response->assertStatus(500);+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::__construct+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::reconcile()+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::redirectToOriginalAccount()+ */+ public function testReconcile()+ {+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile', [1, '20170101', '20170131']));+ $response->assertStatus(200);++ // has bread crumb+ $response->assertSee('<ol class="breadcrumb">');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::__construct+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::reconcile()+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::redirectToOriginalAccount()+ */+ public function testReconcileInitialBalance()+ {+ $transaction = Transaction::leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')+ ->where('accounts.user_id', $this->user()->id)->where('accounts.account_type_id', 6)->first(['account_id']);+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile', [$transaction->account_id, '20170101', '20170131']));+ $response->assertStatus(302);+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::__construct+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::reconcile()+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::redirectToOriginalAccount()+ */+ public function testReconcileNoDates()+ {+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile', [1]));+ $response->assertStatus(200);++ // has bread crumb+ $response->assertSee('<ol class="breadcrumb">');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::__construct+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::reconcile()+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::redirectToOriginalAccount()+ */+ public function testReconcileNoEndDate()+ {+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile', [1, '20170101']));+ $response->assertStatus(200);++ // has bread crumb+ $response->assertSee('<ol class="breadcrumb">');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::__construct+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::reconcile()+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::redirectToOriginalAccount()+ */+ public function testReconcileNotAsset()+ {+ $account = $this->user()->accounts()->where('account_type_id', '!=', 6)->where('account_type_id', '!=', 3)->first();+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile', [$account->id, '20170101', '20170131']));+ $response->assertStatus(302);+ }+++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::show()+ */+ public function testShow()+ {+ $journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile.show', [$journal->id]));+ $response->assertStatus(200);++ // has bread crumb+ $response->assertSee('<ol class="breadcrumb">');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::show()+ */+ public function testShowSomethingElse()+ {+ $journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile.show', [$journal->id]));+ $response->assertStatus(302);+ $response->assertRedirect(route('transactions.show', [$journal->id]));+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::submit()+ */+ public function testSubmit()+ {+ $data = [+ 'transactions' => [1, 2, 3],+ 'reconcile' => 'create',+ 'difference' => '5',+ 'end' => '20170131',+ ];+ $this->be($this->user());+ $response = $this->post(route('accounts.reconcile.submit', [1, '20170101', '20170131']), $data);++ $response->assertStatus(302);+ $response->assertSessionHas('success');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::transactions()+ */+ public function testTransactions()+ {+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile.transactions', [1, '20170101', '20170131']));+ $response->assertStatus(200);+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::transactions()+ */+ public function testTransactionsInitialBalance()+ {+ $transaction = Transaction::leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')+ ->where('accounts.user_id', $this->user()->id)->where('accounts.account_type_id', 6)->first(['account_id']);+ $this->be($this->user());+ $response = $this->get(route('accounts.reconcile.transactions', [$transaction->account_id, '20170101', '20170131']));+ $response->assertStatus(302);+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::update+ */+ public function testUpdate()+ {+ $journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();+ $data = [+ 'amount' => '5',+ ];++ $this->be($this->user());+ $response = $this->post(route('accounts.reconcile.update', [$journal->id]), $data);+ $response->assertStatus(302);+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::update+ */+ public function testUpdateNotReconcile()+ {+ $journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();+ $data = [+ 'amount' => '5',+ ];++ $this->be($this->user());+ $response = $this->post(route('accounts.reconcile.update', [$journal->id]), $data);+ $response->assertStatus(302);+ $response->assertRedirect(route('transactions.show', [$journal->id]));+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Account\ReconcileController::update+ */+ public function testUpdateZero()+ {+ $journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();+ $data = [+ 'amount' => '0',+ ];++ $this->be($this->user());+ $response = $this->post(route('accounts.reconcile.update', [$journal->id]), $data);+ $response->assertStatus(302);+ $response->assertSessionHas('error');+ }++}\ No newline at end of filediff --git a/tests/Feature/Controllers/Admin/HomeControllerTest.php b/tests/Feature/Controllers/Admin/HomeControllerTest.phpindex c3eca89437..2189bbcd45 100644--- a/tests/Feature/Controllers/Admin/HomeControllerTest.php+++ b/tests/Feature/Controllers/Admin/HomeControllerTest.php@@ -22,6 +22,8 @@ declare(strict_types=1);namespace Tests\Feature\Controllers\Admin;+use Event;+use FireflyIII\Events\AdminRequestedTestMessage;use Tests\TestCase;/**@@ -35,6 +37,7 @@ class HomeControllerTest extends TestCase{/*** @covers \FireflyIII\Http\Controllers\Admin\HomeController::index+ * @covers \FireflyIII\Http\Controllers\Admin\HomeController::__construct*/public function testIndex(){@@ -44,4 +47,14 @@ class HomeControllerTest extends TestCase// has bread crumb$response->assertSee('<ol class="breadcrumb">');}++ public function testTestMessage() {+ Event::fake();++ $this->be($this->user());+ $response = $this->post(route('admin.test-message'));+ $response->assertStatus(302);++ Event::assertDispatched(AdminRequestedTestMessage::class);+ }}diff --git a/tests/Feature/Controllers/Admin/UserControllerTest.php b/tests/Feature/Controllers/Admin/UserControllerTest.phpindex 9a929df6c5..9885a6b39a 100644--- a/tests/Feature/Controllers/Admin/UserControllerTest.php+++ b/tests/Feature/Controllers/Admin/UserControllerTest.php@@ -35,6 +35,31 @@ use Tests\TestCase;*/class UserControllerTest extends TestCase{+ /**+ * @covers \FireflyIII\Http\Controllers\Admin\UserController::delete+ */+ public function testDelete()+ {+ $this->be($this->user());+ $response = $this->get(route('admin.users.delete', [1]));+ $response->assertStatus(200);+ // has bread crumb+ $response->assertSee('<ol class="breadcrumb">');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Admin\UserController::destroy+ */+ public function testDestroy()+ {+ $repository = $this->mock(UserRepositoryInterface::class);+ $repository->shouldReceive('destroy')->once();+ $this->be($this->user());+ $response = $this->post(route('admin.users.destroy', ['2']));+ $response->assertStatus(302);+ $response->assertSessionHas('success');+ }+/*** @covers \FireflyIII\Http\Controllers\Admin\UserController::edit*/diff --git a/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php b/tests/Feature/Controllers/Auth/TwoFactorControllerTest.phpindex 45e71b10ac..f329197162 100644--- a/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php+++ b/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php@@ -121,6 +121,7 @@ class TwoFactorControllerTest extends TestCase$data = ['code' => '123456'];$google = $this->mock(Google2FA::class);$google->shouldReceive('verifyKey')->andReturn(true)->once();+ $this->session(['remember_login' => true]);$this->be($this->user());$response = $this->post(route('two-factor.post'), $data);diff --git a/tests/Feature/Controllers/Chart/ExpenseReportControllerTest.php b/tests/Feature/Controllers/Chart/ExpenseReportControllerTest.phpnew file mode 100644index 0000000000..9ea2de17f8--- /dev/null+++ b/tests/Feature/Controllers/Chart/ExpenseReportControllerTest.php@@ -0,0 +1,78 @@+<?php+/**+ * ExpenseReportControllerTest.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\Chart;++use FireflyIII\Generator\Chart\Basic\GeneratorInterface;+use FireflyIII\Helpers\Collector\JournalCollectorInterface;+use FireflyIII\Models\Transaction;+use FireflyIII\Models\TransactionType;+use FireflyIII\Repositories\Account\AccountRepositoryInterface;+use Illuminate\Support\Collection;+use Tests\TestCase;++/**+ * Class ExpenseReportControllerTest+ *+ * @SuppressWarnings(PHPMD.TooManyPublicMethods)+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)+ */+class ExpenseReportControllerTest extends TestCase+{+++ /**+ * @covers \FireflyIII\Http\Controllers\Chart\ExpenseReportController::__construct+ * @covers \FireflyIII\Http\Controllers\Chart\ExpenseReportController::groupByName+ * @covers \FireflyIII\Http\Controllers\Chart\ExpenseReportController::mainChart()+ * @covers \FireflyIII\Http\Controllers\Chart\ExpenseReportController::getExpenses+ * @covers \FireflyIII\Http\Controllers\Chart\ExpenseReportController::getIncome+ * @covers \FireflyIII\Http\Controllers\Chart\ExpenseReportController::combineAccounts+ */+ public function testMainChart()+ {+ $expense = $this->user()->accounts()->where('account_type_id', 4)->first();+ $generator = $this->mock(GeneratorInterface::class);+ $collector = $this->mock(JournalCollectorInterface::class);+ $accountRepository = $this->mock(AccountRepositoryInterface::class);+ $accountRepository->shouldReceive('findByName')->once()->andReturn($expense);++ $set = new Collection;+ $transaction = new Transaction();+ $transaction->opposing_account_name = 'Somebody';+ $transaction->transaction_amount = '5';+ $set->push($transaction);+ $collector->shouldReceive('setAccounts')->andReturnSelf();+ $collector->shouldReceive('setRange')->andReturnSelf();+ $collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL]])->andReturnSelf();+ $collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT]])->andReturnSelf();+ $collector->shouldReceive('setOpposingAccounts')->andReturnSelf();+ $collector->shouldReceive('getJournals')->andReturn($set);+ $generator->shouldReceive('multiSet')->andReturn([])->once();++ $this->be($this->user());+ $response = $this->get(route('chart.expense.main', ['1', $expense->id, '20120101', '20120131']));+ $response->assertStatus(200);+ }++}