mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-06 04:20:48 +00:00
Built chart tests.
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
|
||||
/**
|
||||
* Class ChartBudgetControllerTest
|
||||
@@ -25,17 +29,120 @@ class ChartBudgetControllerTest extends TestCase
|
||||
|
||||
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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user