mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Improve test coverage.
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Tests\Feature\Controllers\Chart;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Category;
|
||||
@@ -110,7 +111,10 @@ class AccountControllerTest extends TestCase
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
@@ -135,12 +139,12 @@ class AccountControllerTest extends TestCase
|
||||
*/
|
||||
public function testExpenseBudgetAll(string $range): void
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
@@ -172,7 +176,10 @@ class AccountControllerTest extends TestCase
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
@@ -231,7 +238,7 @@ class AccountControllerTest extends TestCase
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
// change the preference:
|
||||
Preferences::setForUser($this->user(), 'frontPageAccounts', []);
|
||||
|
||||
@@ -262,7 +269,10 @@ class AccountControllerTest extends TestCase
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
@@ -317,10 +327,13 @@ class AccountControllerTest extends TestCase
|
||||
*/
|
||||
public function testPeriod(string $range): void
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$accountRepos->shouldReceive('oldestJournalDate')->andReturn(new Carbon);
|
||||
Steam::shouldReceive('balanceInRange')->andReturn(['2012-01-01' => '0']);
|
||||
$generator->shouldReceive('singleSet')->andReturn([]);
|
||||
@@ -339,9 +352,12 @@ class AccountControllerTest extends TestCase
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'currency_id'])->andReturn('1')->atLeast()->once();
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1), null);
|
||||
|
||||
@@ -364,7 +380,7 @@ class AccountControllerTest extends TestCase
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
// grab two expense accounts from the current user.
|
||||
$accounts = $this->user()->accounts()->where('account_type_id', 5)->take(2)->get();
|
||||
|
||||
|
@@ -25,6 +25,7 @@ namespace Tests\Feature\Controllers\Chart;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
@@ -312,6 +313,10 @@ class BudgetControllerTest extends TestCase
|
||||
$budget = factory(Budget::class)->make();
|
||||
$budgetLimit = factory(BudgetLimit::class)->make();
|
||||
$budgetLimit->budget_id = $budget->id;
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$repository->shouldReceive('getBudgetPeriodReport')->andReturn([])->once();
|
||||
$repository->shouldReceive('getBudgetLimits')->andReturn(new Collection([$budgetLimit]));
|
||||
@@ -327,8 +332,12 @@ class BudgetControllerTest extends TestCase
|
||||
*/
|
||||
public function testPeriodNoBudget(): void
|
||||
{
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$repository->shouldReceive('getNoBudgetPeriodReport')->andReturn([])->once();
|
||||
$generator->shouldReceive('singleSet')->once()->andReturn([]);
|
||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\OpposingAccountFilter;
|
||||
use FireflyIII\Helpers\Filter\PositiveAmountFilter;
|
||||
use FireflyIII\Helpers\Filter\TransferFilter;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
@@ -59,7 +60,10 @@ class BudgetReportControllerTest extends TestCase
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setBudgets')->once()->andReturnSelf();
|
||||
@@ -82,6 +86,10 @@ class BudgetReportControllerTest extends TestCase
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setBudgets')->once()->andReturnSelf();
|
||||
@@ -104,6 +112,10 @@ class BudgetReportControllerTest extends TestCase
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$one = factory(BudgetLimit::class)->make();
|
||||
$one->budget_id = 1;
|
||||
|
@@ -24,6 +24,7 @@ namespace Tests\Feature\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
@@ -63,6 +64,7 @@ class CategoryControllerTest extends TestCase
|
||||
$firstUse = new Carbon;
|
||||
$firstUse->subDays(3);
|
||||
|
||||
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('0');
|
||||
$repository->shouldReceive('firstUseDate')->andReturn($firstUse)->once();
|
||||
@@ -87,7 +89,6 @@ class CategoryControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// spent per currency data:
|
||||
$spentData = [
|
||||
1 => '-123.45',
|
||||
@@ -133,7 +134,10 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$repository->shouldReceive('periodExpenses')->andReturn([])->once();
|
||||
$repository->shouldReceive('periodIncome')->andReturn([])->once();
|
||||
$generator->shouldReceive('multiSet')->andReturn([])->once();
|
||||
@@ -150,7 +154,10 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$repository->shouldReceive('periodExpensesNoCategory')->andReturn([])->once();
|
||||
$repository->shouldReceive('periodIncomeNoCategory')->andReturn([])->once();
|
||||
$generator->shouldReceive('multiSet')->andReturn([])->once();
|
||||
@@ -172,6 +179,10 @@ class CategoryControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
|
@@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
@@ -29,6 +30,7 @@ use FireflyIII\Helpers\Filter\NegativeAmountFilter;
|
||||
use FireflyIII\Helpers\Filter\OpposingAccountFilter;
|
||||
use FireflyIII\Helpers\Filter\PositiveAmountFilter;
|
||||
use FireflyIII\Helpers\Filter\TransferFilter;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Log;
|
||||
@@ -53,9 +55,12 @@ class CategoryReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testAccountExpense(): void
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setCategories')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@@ -74,9 +79,12 @@ class CategoryReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testAccountIncome(): void
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setCategories')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@@ -95,9 +103,12 @@ class CategoryReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testCategoryExpense(): void
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setCategories')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@@ -116,9 +127,12 @@ class CategoryReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testCategoryIncome(): void
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setCategories')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@@ -140,7 +154,10 @@ class CategoryReportControllerTest extends TestCase
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transactions = factory(Transaction::class, 10)->make();
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]])->andReturnSelf();
|
||||
|
@@ -22,8 +22,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@@ -57,6 +59,11 @@ class ExpenseReportControllerTest extends TestCase
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepository->shouldReceive('findByName')->once()->andReturn($expense);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$set = new Collection;
|
||||
$transaction = new Transaction();
|
||||
$transaction->opposing_account_name = 'Somebody';
|
||||
|
@@ -22,7 +22,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Helpers\Report\NetWorthInterface;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
@@ -51,12 +54,26 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testNetWorth(): void
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$netWorth = $this->mock(NetWorthInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
//$currencyRepos->shouldReceive('setUser');
|
||||
//$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||
|
||||
$currencyRepos->shouldReceive('setUser');
|
||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||
$netWorth->shouldReceive('getNetWorthByCurrency')->andReturn(
|
||||
[
|
||||
[
|
||||
'currency' => TransactionCurrency::first(),
|
||||
'balance' => '123',
|
||||
],
|
||||
]
|
||||
);
|
||||
$netWorth->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// mock calls:
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
@@ -82,12 +99,15 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOperations(): void
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$income = [1 => ['sum' => '100']];
|
||||
$expense = [2 => ['sum' => '-100']];
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$income = [1 => ['sum' => '100']];
|
||||
$expense = [2 => ['sum' => '-100']];
|
||||
$tasker->shouldReceive('getIncomeReport')->once()->andReturn($income);
|
||||
$tasker->shouldReceive('getExpenseReport')->once()->andReturn($expense);
|
||||
$generator->shouldReceive('multiSet')->andReturn([]);
|
||||
@@ -102,10 +122,13 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testSum(): void
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$income = [];
|
||||
$expense = [];
|
||||
|
@@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
@@ -29,6 +30,7 @@ use FireflyIII\Helpers\Filter\NegativeAmountFilter;
|
||||
use FireflyIII\Helpers\Filter\OpposingAccountFilter;
|
||||
use FireflyIII\Helpers\Filter\PositiveAmountFilter;
|
||||
use FireflyIII\Helpers\Filter\TransferFilter;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
@@ -65,6 +67,11 @@ class TagReportControllerTest extends TestCase
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@@ -93,6 +100,11 @@ class TagReportControllerTest extends TestCase
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@@ -120,6 +132,11 @@ class TagReportControllerTest extends TestCase
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@@ -146,6 +163,11 @@ class TagReportControllerTest extends TestCase
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@@ -172,6 +194,11 @@ class TagReportControllerTest extends TestCase
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$set = new Collection;
|
||||
for ($i = 0; $i < 10; ++$i) {
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
@@ -211,6 +238,11 @@ class TagReportControllerTest extends TestCase
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@@ -237,6 +269,11 @@ class TagReportControllerTest extends TestCase
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
|
Reference in New Issue
Block a user