Full coverage for chart controller.

This commit is contained in:
James Cole 2015-05-04 19:28:49 +02:00
parent 1ff99346aa
commit 76f08b7acb

View File

@ -87,27 +87,35 @@ class GoogleChartControllerTest extends TestCase
public function testAllBudgetsHomeChart() public function testAllBudgetsHomeChart()
{ {
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
$budget1 = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget');
$this->be($budget->user); $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget');
$budget3 = FactoryMuffin::create('FireflyIII\Models\Budget');
$budget4 = FactoryMuffin::create('FireflyIII\Models\Budget');
$budgets = new Collection([$budget1, $budget2, $budget3, $budget4]);
$start = Carbon::now()->startOfMonth(); $rep1 = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
$end = Carbon::now()->endOfMonth(); $rep2 = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
$rep3 = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
$repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); $rep1->amount = 6;
$repetitions = new Collection; $rep1->save();
$repetitions->push($repetition); $rep2->amount = 18;
$emptyRepetitions = new Collection; $rep2->save();
$this->be($budget1->user);
$coll1 = new Collection([$rep1]);
$coll2 = new Collection([$rep2]);
$coll3 = new Collection([$rep3]);
$coll4 = new Collection;
$collection = new Collection;
$collection->push($budget);
$collection->push($budget1);
// mock stuff: // mock stuff:
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$repository->shouldReceive('getBudgets')->andReturn($collection); $repository->shouldReceive('getBudgets')->andReturn($budgets);
$repository->shouldReceive('getBudgetLimitRepetitions')->once()->andReturn($repetitions, $emptyRepetitions); $repository->shouldReceive('getBudgetLimitRepetitions')->andReturn($coll1, $coll2, $coll3, $coll4);
$repository->shouldReceive('sumBudgetExpensesInPeriod')->andReturn(12); $repository->shouldReceive('sumBudgetExpensesInPeriod')->andReturn(12, 12, 12, -12);
$repository->shouldReceive('getWithoutBudgetSum')->andReturn(0); $repository->shouldReceive('getWithoutBudgetSum')->andReturn(0);
$this->call('GET', '/chart/home/budgets'); $this->call('GET', '/chart/home/budgets');