Remove unused code.

This commit is contained in:
James Cole 2019-09-03 15:43:11 +02:00
parent 5a8146aa34
commit 401086b75f
7 changed files with 2 additions and 673 deletions

View File

@ -1,392 +0,0 @@
<?php
/**
* MetaPieChart.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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 FireflyIII\Helpers\Chart;
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Log;
/**
* Class MetaPieChart.
*/
class MetaPieChart implements MetaPieChartInterface
{
/** @var array The ways to group transactions, given the type of chart. */
static protected $grouping
= [
'account' => ['destination_account_id'],
'budget' => ['budget_id'],
'category' => ['category_id'],
'tag' => [],
];
/** @var Collection Involved accounts. */
protected $accounts;
/** @var Collection The budgets. */
protected $budgets;
/** @var Collection The categories. */
protected $categories;
/** @var bool Collect other objects. */
protected $collectOtherObjects = false;
/** @var Carbon The end date./ */
protected $end;
/** @var array The repositories. */
protected $repositories
= [
'account' => AccountRepositoryInterface::class,
'budget' => BudgetRepositoryInterface::class,
'category' => CategoryRepositoryInterface::class,
'tag' => TagRepositoryInterface::class,
];
/** @var Carbon The start date. */
protected $start;
/** @var Collection The involved tags/ */
protected $tags;
/** @var string The total amount. */
protected $total = '0';
/** @var User The user. */
protected $user;
/**
* MetaPieChart constructor.
*/
public function __construct()
{
$this->accounts = new Collection;
$this->budgets = new Collection;
$this->categories = new Collection;
$this->tags = new Collection;
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/**
* Generate the chart.
*
* @param string $direction
* @param string $group
*
* @return array
*
*/
public function generate(string $direction, string $group): array
{
$transactions = $this->getTransactions($direction);
$grouped = $this->groupByFields($transactions, self::$grouping[$group]);
$chartData = $this->organizeByType($group, $grouped);
$key = (string)trans('firefly.everything_else');
// also collect all other transactions
if ($this->collectOtherObjects && 'expense' === $direction) {
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::WITHDRAWAL]);
$sum = $collector->getSum();
$sum = bcmul($sum, '-1');
$sum = bcsub($sum, $this->total);
$chartData[$key] = $sum;
}
if ($this->collectOtherObjects && 'income' === $direction) {
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::DEPOSIT]);
$sum = $collector->getSum();
$sum = bcsub($sum, $this->total);
$chartData[$key] = $sum;
}
return $chartData;
}
/**
* Get all transactions.
*
* @param string $direction
*
* @return array
*/
protected function getTransactions(string $direction): array
{
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$types = [TransactionType::DEPOSIT, TransactionType::TRANSFER];
if ('expense' === $direction) {
$types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
}
$collector->setUser($this->user);
$collector->setAccounts($this->accounts);
$collector->setRange($this->start, $this->end);
$collector->setTypes($types);
$collector->withAccountInformation();
$collector->setBudgets($this->budgets);
$collector->setCategories($this->categories);
// @codeCoverageIgnoreStart
if ($this->tags->count() > 0) {
$collector->setTags($this->tags);
}
// @codeCoverageIgnoreEnd
return $collector->getExtractedJournals();
}
/**
* Group by a specific field.
*
* @param array $array
* @param array $fields
*
* @return array
*
*/
protected function groupByFields(array $array, array $fields): array
{
$grouped = [];
if (0 === count($fields) && $this->tags->count() > 0) {
// do a special group on tags:
$grouped = $this->groupByTag($array); // @codeCoverageIgnore
}
if (0 !== count($fields) || $this->tags->count() <= 0) {
$grouped = [];
/** @var array $journal */
foreach ($array as $journal) {
$values = [];
foreach ($fields as $field) {
$values[] = (int)$journal[$field];
}
$value = max($values);
$grouped[$value] = $grouped[$value] ?? '0';
$grouped[$value] = bcadd($journal['amount'], $grouped[$value]);
}
}
return $grouped;
}
/**
* Group by tag (slightly different).
*
* @codeCoverageIgnore
*
* @param array $array
*
* @return array
*/
private function groupByTag(array $array): array
{
$grouped = [];
/** @var array $journal */
foreach ($array as $journal) {
$tags = $journal['tags'] ?? [];
/** @var Tag $tag */
foreach ($tags as $id => $tag) {
$grouped[$id] = $grouped[$id] ?? '0';
$grouped[$id] = bcadd($journal['amount'], $grouped[$id]);
}
}
return $grouped;
}
/**
* Organise by certain type.
*
* @param string $type
* @param array $array
*
* @return array
*/
protected function organizeByType(string $type, array $array): array
{
$chartData = [];
$names = [];
$repository = app($this->repositories[$type]);
$repository->setUser($this->user);
foreach ($array as $objectId => $amount) {
if (!isset($names[$objectId])) {
$object = $repository->findNull((int)$objectId);
$name = null === $object ? '(no name)' : $object->name;
$names[$objectId] = $name ?? $object->tag;
}
$amount = app('steam')->positive($amount);
$this->total = bcadd($this->total, $amount);
$chartData[$names[$objectId]] = $amount;
}
return $chartData;
}
/**
* Accounts setter.
*
* @codeCoverageIgnore
*
* @param Collection $accounts
*
* @return MetaPieChartInterface
*/
public function setAccounts(Collection $accounts): MetaPieChartInterface
{
$this->accounts = $accounts;
return $this;
}
/**
* Budgets setter.
*
* @codeCoverageIgnore
*
* @param Collection $budgets
*
* @return MetaPieChartInterface
*/
public function setBudgets(Collection $budgets): MetaPieChartInterface
{
$this->budgets = $budgets;
return $this;
}
/**
* Categories setter.
*
* @codeCoverageIgnore
*
* @param Collection $categories
*
* @return MetaPieChartInterface
*/
public function setCategories(Collection $categories): MetaPieChartInterface
{
$this->categories = $categories;
return $this;
}
/**
* Set if other objects should be collected.
*
* @codeCoverageIgnore
*
* @param bool $collectOtherObjects
*
* @return MetaPieChartInterface
*/
public function setCollectOtherObjects(bool $collectOtherObjects): MetaPieChartInterface
{
$this->collectOtherObjects = $collectOtherObjects;
return $this;
}
/**
* Set the end date.
*
* @codeCoverageIgnore
*
* @param Carbon $end
*
* @return MetaPieChartInterface
*/
public function setEnd(Carbon $end): MetaPieChartInterface
{
$this->end = $end;
return $this;
}
/**
* Set the start date.
*
* @codeCoverageIgnore
*
* @param Carbon $start
*
* @return MetaPieChartInterface
*/
public function setStart(Carbon $start): MetaPieChartInterface
{
$this->start = $start;
return $this;
}
/**
* Set the tags.
*
* @codeCoverageIgnore
*
* @param Collection $tags
*
* @return MetaPieChartInterface
*/
public function setTags(Collection $tags): MetaPieChartInterface
{
$this->tags = $tags;
return $this;
}
/**
* Set the user.
*
* @codeCoverageIgnore
*
* @param User $user
*
* @return MetaPieChartInterface
*/
public function setUser(User $user): MetaPieChartInterface
{
$this->user = $user;
return $this;
}
}

View File

@ -1,115 +0,0 @@
<?php
/**
* MetaPieChartInterface.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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 FireflyIII\Helpers\Chart;
use Carbon\Carbon;
use FireflyIII\User;
use Illuminate\Support\Collection;
/**
* Interface MetaPieChartInterface.
*/
interface MetaPieChartInterface
{
/**
* Generate a chart.
*
* @param string $direction
* @param string $group
*
* @return array
*/
public function generate(string $direction, string $group): array;
/**
* Accounts setter.
*
* @param Collection $accounts
*
* @return MetaPieChartInterface
*/
public function setAccounts(Collection $accounts): MetaPieChartInterface;
/**
* Budgets setter.
*
* @param Collection $budgets
*
* @return MetaPieChartInterface
*/
public function setBudgets(Collection $budgets): MetaPieChartInterface;
/**
* Categories setter.
*
* @param Collection $categories
*
* @return MetaPieChartInterface
*/
public function setCategories(Collection $categories): MetaPieChartInterface;
/**
* Set if other objects should be collected.
*
* @param bool $collectOtherObjects
*
* @return MetaPieChartInterface
*/
public function setCollectOtherObjects(bool $collectOtherObjects): MetaPieChartInterface;
/**
* Set the end date.
*
* @param Carbon $end
*
* @return MetaPieChartInterface
*/
public function setEnd(Carbon $end): MetaPieChartInterface;
/**
* Set the start date.
*
* @param Carbon $start
*
* @return MetaPieChartInterface
*/
public function setStart(Carbon $start): MetaPieChartInterface;
/**
* Set the tags.
*
* @param Collection $tags
*
* @return MetaPieChartInterface
*/
public function setTags(Collection $tags): MetaPieChartInterface;
/**
* Set the user.
*
* @param User $user
*
* @return MetaPieChartInterface
*/
public function setUser(User $user): MetaPieChartInterface;
}

View File

@ -24,11 +24,9 @@ namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Tag\OperationsRepositoryInterface; use FireflyIII\Repositories\Tag\OperationsRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Http\Controllers\AugumentData; use FireflyIII\Support\Http\Controllers\AugumentData;
use FireflyIII\Support\Http\Controllers\TransactionCalculation; use FireflyIII\Support\Http\Controllers\TransactionCalculation;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
@ -66,64 +64,6 @@ class TagReportController extends Controller
); );
} }
/**
* Generate expenses for tags grouped on account.
*
* TODO this chart is not multi-currency aware.
*
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param string $others
*
* @return JsonResponse
*/
public function accountExpense(Collection $accounts, Collection $tags, Carbon $start, Carbon $end, string $others): JsonResponse
{
/** @var MetaPieChartInterface $helper */
$helper = app(MetaPieChartInterface::class);
$helper->setAccounts($accounts);
$helper->setTags($tags);
$helper->setStart($start);
$helper->setEnd($end);
$helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('expense', 'account');
$data = $this->generator->pieChart($chartData);
return response()->json($data);
}
/**
* Generate income for tag grouped by account.
*
* TODO this chart is not multi-currency aware.
*
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param string $others
*
* @return JsonResponse
*/
public function accountIncome(Collection $accounts, Collection $tags, Carbon $start, Carbon $end, string $others): JsonResponse
{
/** @var MetaPieChartInterface $helper */
$helper = app(MetaPieChartInterface::class);
$helper->setAccounts($accounts);
$helper->setTags($tags);
$helper->setStart($start);
$helper->setEnd($end);
$helper->setCollectOtherObjects(1 === (int)$others);
$chartData = $helper->generate('income', 'account');
$data = $this->generator->pieChart($chartData);
return response()->json($data);
}
/** /**
* @param Collection $accounts * @param Collection $accounts
* @param Collection $tags * @param Collection $tags
@ -304,7 +244,7 @@ class TagReportController extends Controller
* Generate main tag overview chart. * Generate main tag overview chart.
* *
* @param Collection $accounts * @param Collection $accounts
* @param Tag $tag * @param Tag $tag
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *

View File

@ -27,8 +27,6 @@ use FireflyIII\Generator\Chart\Basic\ChartJsGenerator;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Attachments\AttachmentHelper; use FireflyIII\Helpers\Attachments\AttachmentHelper;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Helpers\Chart\MetaPieChart;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelper; use FireflyIII\Helpers\Fiscal\FiscalHelper;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface; use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Helpers\Help\Help; use FireflyIII\Helpers\Help\Help;
@ -68,7 +66,6 @@ use FireflyIII\Support\Twig\Rule;
use FireflyIII\Support\Twig\TransactionGroupTwig; use FireflyIII\Support\Twig\TransactionGroupTwig;
use FireflyIII\Support\Twig\Translation; use FireflyIII\Support\Twig\Translation;
use FireflyIII\Validation\FireflyValidator; use FireflyIII\Validation\FireflyValidator;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Twig; use Twig;
use Twig_Extension_Debug; use Twig_Extension_Debug;
@ -180,19 +177,6 @@ class FireflyServiceProvider extends ServiceProvider
// chart generator: // chart generator:
$this->app->bind(GeneratorInterface::class, ChartJsGenerator::class); $this->app->bind(GeneratorInterface::class, ChartJsGenerator::class);
// chart builder
$this->app->bind(
MetaPieChartInterface::class,
function (Application $app) {
/** @var MetaPieChart $chart */
$chart = app(MetaPieChart::class);
if ($app->auth->check()) {
$chart->setUser(auth()->user());
}
return $chart;
}
);
// other generators // other generators
$this->app->bind(UserRepositoryInterface::class, UserRepository::class); $this->app->bind(UserRepositoryInterface::class, UserRepository::class);

View File

@ -24,7 +24,6 @@ namespace Tests\Feature\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface; use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
@ -60,7 +59,6 @@ class BudgetReportControllerTest extends TestCase
{ {
$budgetRepos = $this->mock(BudgetRepositoryInterface::class); $budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class); $fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon; $date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
@ -69,12 +67,6 @@ class BudgetReportControllerTest extends TestCase
// mock default session // mock default session
$this->mockDefaultSession(); $this->mockDefaultSession();
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
$pieChart->shouldReceive('setBudgets')->once()->andReturnSelf();
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'account'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -89,7 +81,6 @@ class BudgetReportControllerTest extends TestCase
{ {
$budgetRepos = $this->mock(BudgetRepositoryInterface::class); $budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class); $fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon; $date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
@ -99,12 +90,6 @@ class BudgetReportControllerTest extends TestCase
$this->mockDefaultSession(); $this->mockDefaultSession();
//Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345'); //Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
$pieChart->shouldReceive('setBudgets')->once()->andReturnSelf();
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'budget'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -114,6 +99,7 @@ class BudgetReportControllerTest extends TestCase
/** /**
* TODO something in this method makes it return a 404. * TODO something in this method makes it return a 404.
*
* @covers \FireflyIII\Http\Controllers\Chart\BudgetReportController * @covers \FireflyIII\Http\Controllers\Chart\BudgetReportController
*/ */
public function testMainChart(): void public function testMainChart(): void

View File

@ -24,7 +24,6 @@ namespace Tests\Feature\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface; use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
@ -56,7 +55,6 @@ class CategoryReportControllerTest extends TestCase
public function testAccountExpense(): void public function testAccountExpense(): void
{ {
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class); $fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon; $date = new Carbon;
@ -65,12 +63,6 @@ class CategoryReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'account'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -84,7 +76,6 @@ class CategoryReportControllerTest extends TestCase
public function testAccountIncome(): void public function testAccountIncome(): void
{ {
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class); $fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon; $date = new Carbon;
@ -93,12 +84,6 @@ class CategoryReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['income', 'account'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -112,7 +97,6 @@ class CategoryReportControllerTest extends TestCase
public function testCategoryExpense(): void public function testCategoryExpense(): void
{ {
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class); $fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon; $date = new Carbon;
@ -121,12 +105,6 @@ class CategoryReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'category'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -140,7 +118,6 @@ class CategoryReportControllerTest extends TestCase
public function testCategoryIncome(): void public function testCategoryIncome(): void
{ {
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class); $fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon; $date = new Carbon;
@ -149,12 +126,6 @@ class CategoryReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['income', 'category'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());

View File

@ -24,7 +24,6 @@ namespace Tests\Feature\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface; use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
@ -59,7 +58,6 @@ class TagReportControllerTest extends TestCase
public function testAccountExpense(): void public function testAccountExpense(): void
{ {
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class); $tagRepos = $this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class);
$tag = $this->user()->tags()->first(); $tag = $this->user()->tags()->first();
@ -74,12 +72,6 @@ class TagReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'account'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -95,7 +87,6 @@ class TagReportControllerTest extends TestCase
public function testAccountIncome(): void public function testAccountIncome(): void
{ {
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class); $tagRepos = $this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class);
$tag = $this->user()->tags()->first(); $tag = $this->user()->tags()->first();
@ -109,12 +100,6 @@ class TagReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['income', 'account'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -129,7 +114,6 @@ class TagReportControllerTest extends TestCase
public function testBudgetExpense(): void public function testBudgetExpense(): void
{ {
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class); $tagRepos = $this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class);
$tag = $this->user()->tags()->first(); $tag = $this->user()->tags()->first();
@ -143,12 +127,6 @@ class TagReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'budget'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -162,7 +140,6 @@ class TagReportControllerTest extends TestCase
public function testCategoryExpense(): void public function testCategoryExpense(): void
{ {
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class); $tagRepos = $this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class);
$tag = $this->user()->tags()->first(); $tag = $this->user()->tags()->first();
@ -176,12 +153,6 @@ class TagReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'category'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -238,7 +209,6 @@ class TagReportControllerTest extends TestCase
{ {
$this->mockDefaultSession(); $this->mockDefaultSession();
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class); $tagRepos = $this->mock(TagRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class); $this->mock(AccountRepositoryInterface::class);
$tag = $this->user()->tags()->first(); $tag = $this->user()->tags()->first();
@ -250,13 +220,6 @@ class TagReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'tag'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());
@ -271,7 +234,6 @@ class TagReportControllerTest extends TestCase
{ {
$this->mockDefaultSession(); $this->mockDefaultSession();
$generator = $this->mock(GeneratorInterface::class); $generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class); $tagRepos = $this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class);
$tag = $this->user()->tags()->first(); $tag = $this->user()->tags()->first();
@ -283,13 +245,6 @@ class TagReportControllerTest extends TestCase
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date); $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->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();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['income', 'tag'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once(); $generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user()); $this->be($this->user());