mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 14:41:20 +00:00
Cleaned up reports and associated views.
This commit is contained in:
@@ -36,47 +36,6 @@ class ReportControllerTest extends TestCase
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testBudget()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$showSharedReports = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$budget->queryAmount = 100;
|
||||
$accounts = new Collection([$account]);
|
||||
$budgets = new Collection([$budget]);
|
||||
$showSharedReports->data = false;
|
||||
$this->be($user);
|
||||
$showSharedReports->save();
|
||||
|
||||
// mock stuff
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
$helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||
|
||||
// fake it!
|
||||
Preferences::shouldReceive('get')->withArgs(['showSharedReports', false])->andReturn($showSharedReports);
|
||||
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
||||
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
|
||||
Amount::shouldReceive('format')->andReturn('X');
|
||||
$query->shouldReceive('getAllAccounts')->withAnyArgs()->andReturn($accounts);
|
||||
$query->shouldReceive('getBudgetSummary')->withAnyArgs()->andReturn($budgets);
|
||||
$query->shouldReceive('balancedTransactionsSum')->withAnyArgs()->andReturn(100);
|
||||
$helper->shouldReceive('getBudgetsForMonth')->withAnyArgs()->andReturn($budgets);
|
||||
|
||||
// language preference:
|
||||
$language = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$language->data = 'en';
|
||||
$language->save();
|
||||
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
|
||||
|
||||
|
||||
$this->call('GET', '/reports/budget/2015/1');
|
||||
$this->assertResponseOk();
|
||||
|
||||
}
|
||||
|
||||
public function testIndex()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
@@ -143,82 +102,6 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
public function testMonth()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$journals = new Collection([$journal]);
|
||||
$budgets = new Collection([$budget]);
|
||||
$accounts = new Collection([$account]);
|
||||
$this->be($user);
|
||||
|
||||
$helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
|
||||
$query->shouldReceive('incomeByPeriod')->withAnyArgs()->andReturn([]);
|
||||
$query->shouldReceive('journalsByExpenseAccount')->withAnyArgs()->andReturn($journals);
|
||||
$helper->shouldReceive('getBudgetsForMonth')->withAnyArgs()->andReturn($budgets);
|
||||
$query->shouldReceive('journalsByCategory')->withAnyArgs()->andReturn($journals);
|
||||
$query->shouldReceive('sharedExpensesByCategory')->withAnyArgs()->andReturn($journals);
|
||||
$query->shouldReceive('accountList')->withAnyArgs()->andReturn($accounts);
|
||||
|
||||
// mock stuff!
|
||||
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
||||
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
|
||||
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
|
||||
Amount::shouldReceive('format')->andReturn('X');
|
||||
|
||||
$this->call('GET', '/reports/2015/1');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testMonthWithShared()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$showSharedReports = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$showSharedReports->data = true;
|
||||
|
||||
$journals = new Collection([$journal]);
|
||||
$budgets = new Collection([$budget]);
|
||||
$accounts = new Collection([$account]);
|
||||
$this->be($user);
|
||||
|
||||
$helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||
$query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
|
||||
$query->shouldReceive('incomeByPeriod')->withAnyArgs()->andReturn([]);
|
||||
$query->shouldReceive('journalsByExpenseAccount')->withAnyArgs()->andReturn($journals);
|
||||
$helper->shouldReceive('getBudgetsForMonth')->withAnyArgs()->andReturn($budgets);
|
||||
$query->shouldReceive('journalsByCategory')->withAnyArgs()->andReturn($journals);
|
||||
$query->shouldReceive('sharedExpensesByCategory')->withAnyArgs()->andReturn($journals);
|
||||
$query->shouldReceive('accountList')->withAnyArgs()->andReturn($accounts);
|
||||
|
||||
// mock stuff!
|
||||
Preferences::shouldReceive('get')->withArgs(['showSharedReports', false])->andReturn($showSharedReports);
|
||||
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
||||
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
|
||||
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
|
||||
Amount::shouldReceive('format')->andReturn('X');
|
||||
|
||||
// language preference:
|
||||
$language = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$language->data = 'en';
|
||||
$language->save();
|
||||
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
|
||||
|
||||
$this->call('GET', '/reports/2015/1');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testYear()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
|
||||
@@ -118,15 +118,6 @@ class ReportHelperTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
public function testListOfYears()
|
||||
{
|
||||
|
||||
$date = new Carbon('2015-01-01');
|
||||
$now = new Carbon;
|
||||
$diff = $now->diffInYears($date) + 1; // the year itself.
|
||||
$result = $this->object->listOfYears($date);
|
||||
$this->assertCount($diff, $result);
|
||||
}
|
||||
|
||||
public function testYearBalanceReport()
|
||||
{
|
||||
|
||||
@@ -36,31 +36,6 @@ class ReportQueryTest extends TestCase
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
||||
public function testAccountList()
|
||||
{
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
// account types:
|
||||
FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||
FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||
$type = FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||
|
||||
// create four accounts:
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$account->user_id = $user->id;
|
||||
$account->active = 1;
|
||||
$account->account_type_id = $type->id;
|
||||
$account->save();
|
||||
}
|
||||
|
||||
$set = $this->object->accountList();
|
||||
$this->assertCount(4, $set);
|
||||
|
||||
}
|
||||
|
||||
public function testBalancedTransactionsList()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
|
||||
Reference in New Issue
Block a user