mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fixed some tests. [skip ci]
This commit is contained in:
parent
fd01b54a14
commit
6765f08b07
@ -16,7 +16,7 @@ namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Generator\Report\Category\MonthReportGenerator;
|
||||
use FireflyIII\Generator\Report\Support;
|
||||
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
@ -237,7 +237,7 @@ class BudgetReportController extends Controller
|
||||
->setBudgets($budgets)->withOpposingAccount()->disableFilter();
|
||||
$accountIds = $accounts->pluck('id')->toArray();
|
||||
$transactions = $collector->getJournals();
|
||||
$set = MonthReportGenerator::filterExpenses($transactions, $accountIds);
|
||||
$set = Support::filterExpenses($transactions, $accountIds);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
@ -45,8 +45,6 @@ class CategoryController extends Controller
|
||||
$cache->addProperty('category-period-expenses-report');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
Log::debug('Return report from cache');
|
||||
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
/** @var CategoryRepositoryInterface $repository */
|
||||
@ -79,8 +77,6 @@ class CategoryController extends Controller
|
||||
$cache->addProperty('category-period-income-report');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
Log::debug('Return report from cache');
|
||||
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
/** @var CategoryRepositoryInterface $repository */
|
||||
|
@ -21,6 +21,7 @@ use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BudgetReportControllerTest extends TestCase
|
||||
@ -85,14 +86,19 @@ class BudgetReportControllerTest extends TestCase
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$one = factory(BudgetLimit::class)->make();
|
||||
$one->budget_id = 1;
|
||||
$two = factory(BudgetLimit::class)->make();
|
||||
$two->budget_id = 1;
|
||||
$two->start_date = new Carbon('2012-01-01');
|
||||
$two->end_date = new Carbon('2012-01-31');
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
$transaction->transaction_amount = '-100';
|
||||
$one = factory(BudgetLimit::class)->make();
|
||||
$one->budget_id = 1;
|
||||
$two = factory(BudgetLimit::class)->make();
|
||||
$two->budget_id = 1;
|
||||
$two->start_date = new Carbon('2012-01-01');
|
||||
$two->end_date = new Carbon('2012-01-31');
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
$transaction->transaction_amount = '-100';
|
||||
$transaction->destination_amount = '-100';
|
||||
$transaction->amount = '-100';
|
||||
$transaction->opposing_account_id = 8;
|
||||
|
||||
Log::debug('Transaction', $transaction->toArray());
|
||||
|
||||
$budgetRepos->shouldReceive('getAllBudgetLimits')->andReturn(new Collection([$one, $two]))->once();
|
||||
|
||||
|
@ -14,12 +14,12 @@ namespace Tests\Feature\Controllers\Popup;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Helpers\Report\PopupReportInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
@ -36,6 +36,7 @@ class ReportControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::__construct
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::general
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::parseAttributes
|
||||
* @expectedExceptionMessage Could not parse end date
|
||||
@ -93,15 +94,12 @@ class ReportControllerTest extends TestCase
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$popupHelper->shouldReceive('balanceForNoBudget')->once()->andReturn(new Collection);
|
||||
$budgetRepos->shouldReceive('find')->andReturn(new Budget)->once()->withArgs([0]);
|
||||
$accountRepos->shouldReceive('find')->andReturn($account)->once()->withArgs([1]);
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setRange')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('withoutBudget')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@ -131,15 +129,13 @@ class ReportControllerTest extends TestCase
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$budget = factory(Budget::class)->make();
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$budgetRepos->shouldReceive('find')->andReturn($budget)->once()->withArgs([1]);
|
||||
$accountRepos->shouldReceive('find')->andReturn($account)->once()->withArgs([1]);
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setRange')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('setBudget')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
|
||||
$popupHelper->shouldReceive('balanceForBudget')->once()->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@ -169,21 +165,20 @@ class ReportControllerTest extends TestCase
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
|
||||
|
||||
$budget = factory(Budget::class)->make();
|
||||
$account = factory(Account::class)->make();
|
||||
$one = factory(Transaction::class)->make();
|
||||
$two = factory(Transaction::class)->make();
|
||||
$tag = factory(Tag::class)->make();
|
||||
$tag = factory(Tag::class)->make();
|
||||
$tag->tagMode = 'balancingAct';
|
||||
$two->transactionJournal->tags()->save($tag);
|
||||
|
||||
$budgetRepos->shouldReceive('find')->andReturn($budget)->once()->withArgs([1]);
|
||||
$accountRepos->shouldReceive('find')->andReturn($account)->once()->withArgs([1]);
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL]])->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('withoutBudget')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection([$one, $two]));
|
||||
$popupHelper->shouldReceive('balanceDifference')->once()->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@ -203,6 +198,44 @@ class ReportControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::general
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::parseAttributes
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::balanceAmount
|
||||
* @expectedExceptionMessage Firefly cannot handle this type of info-button
|
||||
*/
|
||||
public function testBalanceAmountTagRole()
|
||||
{
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$budget = factory(Budget::class)->make();
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$budgetRepos->shouldReceive('find')->andReturn($budget)->once()->withArgs([1]);
|
||||
$accountRepos->shouldReceive('find')->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(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::general
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::parseAttributes
|
||||
@ -212,13 +245,11 @@ class ReportControllerTest extends TestCase
|
||||
{
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$budget = factory(Budget::class)->make();
|
||||
|
||||
$budgetRepos->shouldReceive('find')->andReturn($budget)->once()->withArgs([1]);
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setRange')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('setBudget')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
|
||||
$popupHelper->shouldReceive('byBudget')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@ -246,14 +277,11 @@ class ReportControllerTest extends TestCase
|
||||
{
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$category = factory(Category::class)->make();
|
||||
|
||||
$categoryRepos->shouldReceive('find')->andReturn($category)->once()->withArgs([1]);
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf()->once()->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]]);
|
||||
$collector->shouldReceive('setRange')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('setCategory')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
|
||||
$popupHelper->shouldReceive('byCategory')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@ -280,14 +308,12 @@ class ReportControllerTest extends TestCase
|
||||
public function testExpenseEntry()
|
||||
{
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$accountRepos->shouldReceive('find')->withArgs([1])->andReturn($account)->once();
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf()->once()->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]]);
|
||||
$collector->shouldReceive('setRange')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
|
||||
$popupHelper->shouldReceive('byExpenses')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@ -314,14 +340,12 @@ class ReportControllerTest extends TestCase
|
||||
public function testIncomeEntry()
|
||||
{
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$accountRepos->shouldReceive('find')->withArgs([1])->andReturn($account)->once();
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf()->once()->withArgs([[TransactionType::DEPOSIT, TransactionType::TRANSFER]]);
|
||||
$collector->shouldReceive('setRange')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
|
||||
$popupHelper->shouldReceive('byIncome')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@ -347,6 +371,7 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testWrongLocation()
|
||||
{
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
'attributes' => [
|
||||
|
Loading…
Reference in New Issue
Block a user