mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix test coverage.
This commit is contained in:
parent
1d4434698e
commit
b53cbbe469
@ -27,6 +27,7 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
@ -97,11 +98,24 @@ class PopupReport implements PopupReportInterface
|
||||
*/
|
||||
public function byBudget(Budget $budget, array $attributes): array
|
||||
{
|
||||
// filter by currency, if set.
|
||||
$currencyId = $attributes['currencyId'] ?? null;
|
||||
$currency = null;
|
||||
if (null !== $currencyId) {
|
||||
/** @var CurrencyRepositoryInterface $repos */
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = $repos->find((int)$currencyId);
|
||||
}
|
||||
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setAccounts($attributes['accounts'])->setRange($attributes['startDate'], $attributes['endDate']);
|
||||
|
||||
if (null !== $currency) {
|
||||
$collector->setCurrency($currency);
|
||||
}
|
||||
|
||||
if (null === $budget->id) {
|
||||
$collector->setTypes([TransactionType::WITHDRAWAL])->withoutBudget();
|
||||
}
|
||||
@ -122,12 +136,25 @@ class PopupReport implements PopupReportInterface
|
||||
*/
|
||||
public function byCategory(Category $category, array $attributes): array
|
||||
{
|
||||
// filter by currency, if set.
|
||||
$currencyId = $attributes['currencyId'] ?? null;
|
||||
$currency = null;
|
||||
if (null !== $currencyId) {
|
||||
/** @var CurrencyRepositoryInterface $repos */
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = $repos->find((int)$currencyId);
|
||||
}
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setAccounts($attributes['accounts'])->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
|
||||
$collector->setAccounts($attributes['accounts'])
|
||||
->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER, TransactionType::DEPOSIT])
|
||||
->setRange($attributes['startDate'], $attributes['endDate'])->withAccountInformation()
|
||||
->setCategory($category);
|
||||
if (null !== $currency) {
|
||||
$collector->setCurrency($currency);
|
||||
}
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
@ -142,6 +169,15 @@ class PopupReport implements PopupReportInterface
|
||||
*/
|
||||
public function byExpenses(Account $account, array $attributes): array
|
||||
{
|
||||
// filter by currency, if set.
|
||||
$currencyId = $attributes['currencyId'] ?? null;
|
||||
$currency = null;
|
||||
if (null !== $currencyId) {
|
||||
/** @var CurrencyRepositoryInterface $repos */
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = $repos->find((int)$currencyId);
|
||||
}
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
$repository->setUser($account->user);
|
||||
@ -149,20 +185,15 @@ class PopupReport implements PopupReportInterface
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])
|
||||
$collector->setAccounts(new Collection([$account]))
|
||||
->setRange($attributes['startDate'], $attributes['endDate'])
|
||||
->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER]);
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report
|
||||
|
||||
$filtered = [];
|
||||
// TODO not sure if filter is necessary.
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
if (in_array($journal['source_account_id'], $report, true)) {
|
||||
$filtered[] = $journal;
|
||||
}
|
||||
if (null !== $currency) {
|
||||
$collector->setCurrency($currency);
|
||||
}
|
||||
return $filtered;
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,9 +69,6 @@ class ReportController extends Controller
|
||||
case 'category-entry':
|
||||
$html = $this->categoryEntry($attributes);
|
||||
break;
|
||||
case 'balance-amount':
|
||||
$html = $this->balanceAmount($attributes);
|
||||
break;
|
||||
}
|
||||
|
||||
return response()->json(['html' => $html]);
|
||||
|
@ -59,13 +59,13 @@ class BalanceController extends Controller
|
||||
$helper = app(BalanceReportHelperInterface::class);
|
||||
$report = $helper->getBalanceReport($accounts, $start, $end);
|
||||
// TODO no budget.
|
||||
// try {
|
||||
try {
|
||||
$result = view('reports.partials.balance', compact('report'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
// } catch (Throwable $e) {
|
||||
// Log::debug(sprintf('Could not render reports.partials.balance: %s', $e->getMessage()));
|
||||
// $result = 'Could not render view.';
|
||||
// }
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.balance: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Http\Controllers;
|
||||
|
||||
use FireflyIII\Helpers\Collection\BalanceLine;
|
||||
use FireflyIII\Helpers\Report\PopupReportInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Budget;
|
||||
@ -76,56 +75,6 @@ trait RenderPartialViews
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* View for balance row.
|
||||
*
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*
|
||||
*/
|
||||
protected function balanceAmount(array $attributes): string // generate view for report.
|
||||
{
|
||||
$role = (int)$attributes['role'];
|
||||
/** @var BudgetRepositoryInterface $budgetRepository */
|
||||
$budgetRepository = app(BudgetRepositoryInterface::class);
|
||||
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
|
||||
/** @var PopupReportInterface $popupHelper */
|
||||
$popupHelper = app(PopupReportInterface::class);
|
||||
$budget = $budgetRepository->findNull((int)$attributes['budgetId']);
|
||||
$account = $accountRepository->findNull((int)$attributes['accountId']);
|
||||
|
||||
|
||||
switch (true) {
|
||||
case BalanceLine::ROLE_DEFAULTROLE === $role && null !== $budget && null !== $account:
|
||||
// normal row with a budget:
|
||||
$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);
|
||||
break;
|
||||
case BalanceLine::ROLE_DEFAULTROLE === $role && null === $budget && null !== $account:
|
||||
// normal row without a budget:
|
||||
$budget = new Budget;
|
||||
$journals = $popupHelper->balanceForNoBudget($account, $attributes);
|
||||
$budget->name = (string)trans('firefly.no_budget');
|
||||
break;
|
||||
case BalanceLine::ROLE_TAGROLE === $role:
|
||||
// row with tag info.
|
||||
return 'Firefly cannot handle this type of info-button (BalanceLine::TagRole)';
|
||||
}
|
||||
// @codeCoverageIgnoreStart
|
||||
try {
|
||||
$view = view('popup.report.balance-amount', compact('journals', 'budget', 'account'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render: %s', $e->getMessage()));
|
||||
$view = 'Firefly III could not render the view. Please see the log files.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get options for budget report.
|
||||
|
@ -1029,7 +1029,7 @@ return [
|
||||
'fiscal_year' => 'Fiscal year',
|
||||
'income_entry' => 'Income from account ":name" between :start and :end',
|
||||
'expense_entry' => 'Expenses to account ":name" between :start and :end',
|
||||
'category_entry' => 'Expenses in category ":name" between :start and :end',
|
||||
'category_entry' => 'Expenses and income in category ":name" between :start and :end',
|
||||
'budget_spent_amount' => 'Expenses in budget ":budget" between :start and :end',
|
||||
'balance_amount' => 'Expenses in budget ":budget" paid from account ":account" between :start and :end',
|
||||
'no_audit_activity' => 'No activity was recorded on account <a href=":url" title=":account_name">:account_name</a> between :start and :end.',
|
||||
|
@ -25,9 +25,12 @@
|
||||
<tbody>
|
||||
{# Make sum: #}
|
||||
{% set sum = 0 %}
|
||||
{% set symbol = '' %}
|
||||
{% set decimal_places =2 %}
|
||||
{% for transaction in journals %}
|
||||
{# add to sum #}
|
||||
|
||||
{% set symbol = transaction.currency_symbol %}
|
||||
{% set decimal_places = transaction.currency_decimal_places %}
|
||||
<tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}">
|
||||
<td class="hidden-xs">
|
||||
{% if transaction.transaction_type_type == 'Withdrawal' %}
|
||||
@ -134,8 +137,9 @@
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: right;"><em>{{ 'sum'|_ }}:</em></td>
|
||||
<td>
|
||||
{# TODO avoid using formatAmount #}
|
||||
{{ sum|formatAmount }}
|
||||
{% if sum != 0 %}
|
||||
{{ formatAmountBySymbol(sum, symbol, decimal_places) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
@ -9,11 +9,6 @@
|
||||
<div class="modal-body">
|
||||
{% set hideBudget = true %}
|
||||
{% include 'popup/list/journals' %}
|
||||
<p>
|
||||
<small class="text-warning">
|
||||
{{ 'sum_in_default_currency'|_ }}
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'close'|_ }}</button>
|
||||
|
@ -22,6 +22,9 @@
|
||||
{% if budget.spent[account.id] %}
|
||||
<td style="text-align: right;">
|
||||
{{ formatAmountBySymbol(budget.spent[account.id].spent, budget.spent[account.id].currency_symbol, budget.spent[account.id].currency_decimal_places) }}
|
||||
<i class="fa fa-fw fa-info-circle text-muted"></i>
|
||||
{# TODO #}
|
||||
{#data-location="category-entry" data-category-id="{{ category.id }}" data-currency-id="{{ category.currency_id }}"-->#}
|
||||
</td>
|
||||
{% else %}
|
||||
{% if report.accounts[account.id].sum != 0 %}
|
||||
@ -32,7 +35,7 @@
|
||||
{% endfor %}
|
||||
<td style="text-align: right;">
|
||||
{% for sum in report.sums[budget.budget_id] %}
|
||||
{{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}<br />
|
||||
{{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }} <i class="fa fa-fw fa-info-circle text-muted"></i><br />
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -2,8 +2,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'category'|_ }}</th>
|
||||
<th style="text-align: right;">{{ 'earned'|_ }}</th>
|
||||
<th style="text-align: right;">{{ 'spent'|_ }}</th>
|
||||
<th style="text-align: right;">{{ 'earned'|_ }}</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -22,7 +22,7 @@
|
||||
<td style="text-align: right;">{{ formatAmountBySymbol(category.earned, category.currency_symbol, category.currency_decimal_places, true) }}</td>
|
||||
<td style="width:20px;">
|
||||
<i class="fa fa-fw fa-info-circle text-muted firefly-info-button"
|
||||
data-location="category-entry" data-category-id="{{ category.id }}"
|
||||
data-location="category-entry" data-category-id="{{ category.id }}" data-currency-id="{{ category.currency_id }}"
|
||||
></i>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -26,8 +26,8 @@
|
||||
<td data-value="{{ account.sum }}" style="text-align: right;">
|
||||
{{ formatAmountBySymbol(account.sum, account.currency_symbol, account.currency_decimal_places) }}
|
||||
</td>
|
||||
<td class="hidden-xs" data-value="{{ entry.average }}" style="text-align: right;">
|
||||
{% if entry.count > 1 %}
|
||||
<td class="hidden-xs" data-value="{{ account.average }}" style="text-align: right;">
|
||||
{% if account.count > 1 %}
|
||||
{{ formatAmountBySymbol(account.average, account.currency_symbol, account.currency_decimal_places) }}
|
||||
{% else %}
|
||||
—
|
||||
@ -35,7 +35,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<i class="fa fa-fw text-muted fa-info-circle firefly-info-button" data-location="{{ type }}"
|
||||
data-account-id="{{ account.id }}"></i>
|
||||
data-account-id="{{ account.id }}" data-currency-id="{{ account.currency_id }}"></i>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -107,119 +107,6 @@ class ReportControllerTest extends TestCase
|
||||
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
|
||||
*/
|
||||
public function testBalanceAmountDefaultNoBudget(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$account = $this->getRandomAsset();
|
||||
|
||||
$popupHelper->shouldReceive('balanceForNoBudget')->andReturn([]);
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn(null)->once()->withArgs([0]);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($account)->once()->withArgs([1]);
|
||||
//$popupHelper->shouldReceive('balanceForBudget')->once()->andReturn([]);
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100');
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
'attributes' => [
|
||||
'location' => 'balance-amount',
|
||||
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
|
||||
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
|
||||
'accounts' => 1,
|
||||
'accountId' => 1,
|
||||
'categoryId' => 1,
|
||||
'budgetId' => 0,
|
||||
'role' => 1, // ROLE_DEFAULTROLE
|
||||
],
|
||||
];
|
||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||
$response = $this->get($uri);
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee($account->name);
|
||||
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
|
||||
*/
|
||||
public function testBalanceAmountDefaultRole(): void
|
||||
{
|
||||
$this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$account = $this->getRandomAsset();
|
||||
$budget = $this->getRandomBudget();
|
||||
$this->mockDefaultSession();
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($account)->once()->withArgs([1]);
|
||||
$popupHelper->shouldReceive('balanceForBudget')->once()->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
'attributes' => [
|
||||
'location' => 'balance-amount',
|
||||
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
|
||||
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
|
||||
'accounts' => 1,
|
||||
'accountId' => 1,
|
||||
'categoryId' => 1,
|
||||
'budgetId' => 1,
|
||||
'role' => 1, // ROLE_DEFAULTROLE
|
||||
],
|
||||
];
|
||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||
$response = $this->get($uri);
|
||||
$response->assertStatus(200);
|
||||
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
|
||||
*/
|
||||
public function testBalanceAmountTagRole(): void
|
||||
{
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupReport = $this->mock(PopupReportInterface::class);
|
||||
$account = $this->getRandomAsset();
|
||||
$budget = $this->getRandomBudget();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($account)->once()->withArgs([1]);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
'attributes' => [
|
||||
'location' => 'balance-amount',
|
||||
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
|
||||
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
|
||||
'accounts' => 1,
|
||||
'accountId' => 1,
|
||||
'categoryId' => 1,
|
||||
'budgetId' => 1,
|
||||
'role' => 2, // ROLE_TAGROLE
|
||||
],
|
||||
];
|
||||
|
||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||
$response = $this->get($uri);
|
||||
$response->assertStatus(200);
|
||||
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
|
||||
*/
|
||||
@ -235,7 +122,7 @@ class ReportControllerTest extends TestCase
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
||||
$popupHelper->shouldReceive('byBudget')->andReturn([]);
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@ -245,6 +132,7 @@ class ReportControllerTest extends TestCase
|
||||
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
|
||||
'accounts' => 1,
|
||||
'accountId' => 1,
|
||||
'currencyId' => 1,
|
||||
'categoryId' => 1,
|
||||
'budgetId' => 1,
|
||||
],
|
||||
@ -265,7 +153,7 @@ class ReportControllerTest extends TestCase
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
$budgetRepos->shouldReceive('findNull')->andReturnNull()->once()->withArgs([1]);
|
||||
@ -303,7 +191,8 @@ class ReportControllerTest extends TestCase
|
||||
$this->mockDefaultSession();
|
||||
$categoryRepos->shouldReceive('findNull')->andReturn($category)->once()->withArgs([1]);
|
||||
$popupHelper->shouldReceive('byCategory')->andReturn([]);
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@ -369,7 +258,7 @@ class ReportControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = $this->getRandomAsset();
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
|
||||
@ -443,7 +332,8 @@ class ReportControllerTest extends TestCase
|
||||
$this->mockDefaultSession();
|
||||
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
|
||||
$popupHelper->shouldReceive('byIncome')->andReturn([]);
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Report;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collection\Balance;
|
||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||
use FireflyIII\Helpers\Report\BalanceReportHelperInterface;
|
||||
use Log;
|
||||
@ -62,7 +61,7 @@ class BalanceControllerTest extends TestCase
|
||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$balance->shouldReceive('getBalanceReport')->andReturn(new Balance);
|
||||
$balance->shouldReceive('getBalanceReport')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('report-data.balance.general', ['1', '20120101', '20120131']));
|
||||
|
@ -63,7 +63,7 @@ class BudgetControllerTest extends TestCase
|
||||
$date = new Carbon;
|
||||
|
||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
|
||||
//Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$helper->shouldReceive('getBudgetReport')->andReturn($return);
|
||||
|
@ -112,11 +112,12 @@ class CategoryControllerTest extends TestCase
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||
//Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$repository->shouldReceive('getCategories')->andReturn(new Collection([$category]));
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('-1');
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('1');
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn([]);
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn([]);
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
|
@ -55,7 +55,7 @@ class OperationsControllerTest extends TestCase
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$return = [
|
||||
1 => [
|
||||
1 => [
|
||||
'id' => 1,
|
||||
'name' => 'Some name',
|
||||
'sum' => '5',
|
||||
@ -104,6 +104,7 @@ class OperationsControllerTest extends TestCase
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$return = [
|
||||
'sums' => [],
|
||||
1 => [
|
||||
'id' => 1,
|
||||
'name' => 'Some name',
|
||||
|
@ -137,7 +137,7 @@ class SelectControllerTest extends TestCase
|
||||
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setTriggers')->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn(new Collection);
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$uri = route('rules.test-triggers') . '?' . http_build_query($data);
|
||||
@ -206,7 +206,7 @@ class SelectControllerTest extends TestCase
|
||||
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setTriggers')->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn(new Collection);
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$uri = route('rules.test-triggers') . '?' . http_build_query($data);
|
||||
|
Loading…
Reference in New Issue
Block a user