mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Built chart tests.
This commit is contained in:
parent
1f865d3ea4
commit
eecb4db34c
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Models\AccountMeta;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ChartAccountControllerTest
|
* Class ChartAccountControllerTest
|
||||||
*/
|
*/
|
||||||
@ -25,16 +30,93 @@ class ChartAccountControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testAll()
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||||
|
FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||||
|
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||||
|
$one = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
$two = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
$one->account_type_id = $asset->id;
|
||||||
|
$two->account_type_id = $asset->id;
|
||||||
|
$one->save();
|
||||||
|
$two->save();
|
||||||
|
$accounts = new Collection([$one, $two]);
|
||||||
|
$date = new Carbon;
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
// make one shared:
|
||||||
|
AccountMeta::create(
|
||||||
|
[
|
||||||
|
'account_id' => $one->id,
|
||||||
|
'name' => 'accountRole',
|
||||||
|
'data' => 'sharedAsset'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getAccounts')->once()->andReturn($accounts);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/account/month/' . $date->format('Y/m'));
|
||||||
|
$this->assertResponseOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAllShared()
|
||||||
|
{
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
$accounts = new Collection([$account]);
|
||||||
|
$date = new Carbon;
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
// make it shared:
|
||||||
|
AccountMeta::create(
|
||||||
|
[
|
||||||
|
'account_id' => $account->id,
|
||||||
|
'name' => 'accountRole',
|
||||||
|
'data' => 'sharedAsset'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getAccounts')->once()->andReturn($accounts);
|
||||||
|
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/account/month/' . $date->format('Y/m') . '/shared');
|
||||||
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFrontpage()
|
public function testFrontpage()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$accounts = new Collection([FactoryMuffin::create('FireflyIII\Models\Account')]);
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getFrontpageAccounts')->andReturn($accounts);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/account/frontpage');
|
||||||
|
$this->assertResponseOk();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSingle()
|
public function testSingle()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
$this->be($account->user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/account/' . $account->id);
|
||||||
|
$this->assertResponseOk();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ChartBillControllerTest
|
* Class ChartBillControllerTest
|
||||||
*/
|
*/
|
||||||
@ -20,17 +24,62 @@ class ChartBillControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFrontpage()
|
public function testFrontpage()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
// set!
|
||||||
|
$bills = new Collection([FactoryMuffin::create('FireflyIII\Models\Bill'), FactoryMuffin::create('FireflyIII\Models\Bill')]);
|
||||||
|
$journals = new Collection(
|
||||||
|
[FactoryMuffin::create('FireflyIII\Models\TransactionJournal'), FactoryMuffin::create('FireflyIII\Models\TransactionJournal')]
|
||||||
|
);
|
||||||
|
$creditCards = new Collection([FactoryMuffin::create('FireflyIII\Models\Account'), FactoryMuffin::create('FireflyIII\Models\Account')]);
|
||||||
|
$ranges = [['start' => new Carbon, 'end' => new Carbon]];
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface');
|
||||||
|
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||||
|
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getActiveBills')->andReturn($bills);
|
||||||
|
$repository->shouldReceive('getRanges')->andReturn($ranges);
|
||||||
|
$repository->shouldReceive('getJournalsInRange')->andReturn(new Collection, $journals);
|
||||||
|
$accounts->shouldReceive('getCreditCards')->andReturn($creditCards);
|
||||||
|
$accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection);
|
||||||
|
$repository->shouldReceive('createFakeBill')->andReturn($bills->first());
|
||||||
|
Steam::shouldReceive('balance')->andReturn(-10,0);
|
||||||
|
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/bill/frontpage');
|
||||||
|
$this->assertResponseOk();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSingle()
|
public function testSingle()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$bill = FactoryMuffin::create('FireflyIII\Models\Bill');
|
||||||
|
$this->be($bill->user);
|
||||||
|
|
||||||
|
// set
|
||||||
|
$journals = new Collection([FactoryMuffin::create('FireflyIII\Models\TransactionJournal')]);
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface');
|
||||||
|
$repository->shouldReceive('getJournals')->andReturn($journals);
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/bill/' . $bill->id);
|
||||||
|
$this->assertResponseOk();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ChartBudgetControllerTest
|
* Class ChartBudgetControllerTest
|
||||||
@ -25,17 +29,120 @@ class ChartBudgetControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testBudget()
|
public function testBudget()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||||
|
$this->be($budget->user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/budget/' . $budget->id);
|
||||||
|
$this->assertResponseOk();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testBudgetLimit()
|
||||||
|
{
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||||
|
/** @var \FireflyIII\Models\BudgetLimit $limit */
|
||||||
|
$limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit');
|
||||||
|
/** @var \FireflyIII\Models\LimitRepetition $repetition */
|
||||||
|
$repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
|
||||||
|
|
||||||
|
$start = Carbon::now()->startOfMonth();
|
||||||
|
$end = Carbon::now()->endOfMonth();
|
||||||
|
|
||||||
|
$budget->user_id = $user->id;
|
||||||
|
$limit->budget_id = $budget->id;
|
||||||
|
$limit->startdate = $start;
|
||||||
|
$repetition->budget_limit_id = $limit->id;
|
||||||
|
$repetition->startdate = $start;
|
||||||
|
$repetition->enddate = $end;
|
||||||
|
|
||||||
|
$budget->save();
|
||||||
|
$limit->save();
|
||||||
|
$repetition->save();
|
||||||
|
|
||||||
|
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/budget/' . $budget->id . '/' . $repetition->id);
|
||||||
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFrontpage()
|
public function testFrontpage()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
$start = Carbon::now()->startOfMonth();
|
||||||
|
$end = Carbon::now()->endOfMonth();
|
||||||
|
$budgets = new Collection;
|
||||||
|
$limits = [];
|
||||||
|
$repetitions = [];
|
||||||
|
|
||||||
|
for ($i = 0; $i < 5; $i++) {
|
||||||
|
/** @var \FireflyIII\Models\Budget $budget */
|
||||||
|
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||||
|
$budgets->push($budget);
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Models\BudgetLimit $limit */
|
||||||
|
$limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit');
|
||||||
|
$limit->budget_id = $budget->id;
|
||||||
|
$limit->startdate = $start;
|
||||||
|
$limit->save();
|
||||||
|
|
||||||
|
$set = new Collection([$limit]);
|
||||||
|
$limits[] = $set;
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Models\LimitRepetition $repetition */
|
||||||
|
$repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
|
||||||
|
$repetition->budget_limit_id = $limit->id;
|
||||||
|
$repetition->startdate = $start;
|
||||||
|
$repetition->enddate = $end;
|
||||||
|
$repetition->save();
|
||||||
|
$set = new Collection([$repetition]);
|
||||||
|
$repetitions[] = $set;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getBudgets')->andReturn($budgets);
|
||||||
|
$repository->shouldReceive('getBudgetLimitRepetitions')->andReturn($repetitions[0], $repetitions[1], new Collection);
|
||||||
|
$repository->shouldReceive('spentInPeriodCorrected')->andReturn(10);
|
||||||
|
$repository->shouldReceive('getWithoutBudgetSum')->andReturn(10);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/budget/frontpage');
|
||||||
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testYear()
|
public function testYear()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||||
|
$collection = new Collection([$budget]);
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getBudgets')->andReturn($collection);
|
||||||
|
$repository->shouldReceive('spentInPeriodCorrected')->andReturn(0);
|
||||||
|
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/budget/year/2015');
|
||||||
|
$this->assertResponseOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testYearShared()
|
||||||
|
{
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/budget/year/2015/shared');
|
||||||
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ChartCategoryControllerTest
|
* Class ChartCategoryControllerTest
|
||||||
*/
|
*/
|
||||||
@ -25,22 +28,83 @@ class ChartCategoryControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testAll()
|
public function testAll()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
|
||||||
|
$category = FactoryMuffin::create('FireflyIII\Models\Category');
|
||||||
|
$this->be($category->user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/category/'.$category->id.'/all');
|
||||||
|
$this->assertResponseOk();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFrontpage()
|
public function testFrontpage()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
// make data:
|
||||||
|
$set = [
|
||||||
|
['name' => 'Something', 'sum' => 100],
|
||||||
|
['name' => 'Something Else', 'sum' => 200],
|
||||||
|
['name' => 'Something Else Entirely', 'sum' => 200]
|
||||||
|
];
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getCategoriesAndExpensesCorrected')->andReturn($set);
|
||||||
|
|
||||||
|
//getCategoriesAndExpensesCorrected
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/category/frontpage');
|
||||||
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMonth()
|
public function testMonth()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$category = FactoryMuffin::create('FireflyIII\Models\Category');
|
||||||
|
$this->be($category->user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/category/'.$category->id.'/month');
|
||||||
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testYear()
|
public function testYear()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
$categories = new Collection([FactoryMuffin::create('FireflyIII\Models\Category')]);
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getCategories')->andReturn($categories);
|
||||||
|
$repository->shouldReceive('spentInPeriodCorrected')->andReturn(0);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/category/year/2015');
|
||||||
|
$this->assertResponseOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testYearShared()
|
||||||
|
{
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
$categories = new Collection([FactoryMuffin::create('FireflyIII\Models\Category')]);
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getCategories')->andReturn($categories);
|
||||||
|
$repository->shouldReceive('spentInPeriodCorrected')->andReturn(0);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/category/year/2015/shared');
|
||||||
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ChartPiggyBankControllerTest
|
* Class ChartPiggyBankControllerTest
|
||||||
*/
|
*/
|
||||||
@ -25,6 +27,24 @@ class ChartPiggyBankControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testHistory()
|
public function testHistory()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$piggy = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
|
||||||
|
$this->be($piggy->account->user);
|
||||||
|
|
||||||
|
// data:
|
||||||
|
$obj = new stdClass;
|
||||||
|
$obj->sum = 100;
|
||||||
|
$obj->date = '2015-01-01';
|
||||||
|
$set = [
|
||||||
|
$obj
|
||||||
|
];
|
||||||
|
|
||||||
|
// mock!
|
||||||
|
$repository = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
|
||||||
|
|
||||||
|
// fake!
|
||||||
|
$repository->shouldReceive('getEventSummarySet')->andReturn($set);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/piggyBank/' . $piggy->id);
|
||||||
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ChartReportControllerTest
|
* Class ChartReportControllerTest
|
||||||
*/
|
*/
|
||||||
@ -25,11 +27,39 @@ class ChartReportControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testYearInOut()
|
public function testYearInOut()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/report/in-out/2015');
|
||||||
|
$this->assertResponseOk();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testYearInOutShared()
|
||||||
|
{
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/report/in-out/2015/shared');
|
||||||
|
$this->assertResponseOk();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testYearInOutSummarized()
|
public function testYearInOutSummarized()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/report/in-out-sum/2015');
|
||||||
|
$this->assertResponseOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testYearInOutSummarizedShared()
|
||||||
|
{
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
|
||||||
|
$this->call('GET', '/chart/report/in-out-sum/2015/shared');
|
||||||
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user