firefly-iii/tests/acceptance/Controllers/Chart/ChartBudgetControllerTest.php

92 lines
2.7 KiB
PHP
Raw Normal View History

2016-01-19 23:20:09 -06:00
<?php
/**
* ChartBudgetControllerTest.php
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
2016-01-22 16:00:32 -06:00
use Carbon\Carbon;
use FireflyIII\Models\Budget;
use Illuminate\Support\Collection;
2016-01-19 23:20:09 -06:00
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:57.
*/
class ChartBudgetControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::budget
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::__construct
2016-01-19 23:20:09 -06:00
*/
public function testBudget()
{
2016-01-22 16:00:32 -06:00
2016-01-22 23:59:22 -06:00
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
2016-02-10 05:01:45 -06:00
$repository->shouldReceive('spentPerDay')->once()->andReturn([]);
2016-01-22 16:00:32 -06:00
$repository->shouldReceive('getFirstBudgetLimitDate')->once()->andReturn(new Carbon);
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/chart/budget/1');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit
*/
public function testBudgetLimit()
{
2016-01-20 02:15:33 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/chart/budget/1/1');
2016-01-20 02:15:33 -06:00
2016-01-24 11:11:57 -06:00
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::frontpage
*/
public function testFrontpage()
{
2016-01-20 02:15:33 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/chart/budget/frontpage');
2016-01-20 02:15:33 -06:00
2016-01-24 11:11:57 -06:00
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::multiYear
*/
public function testMultiYear()
{
2016-01-22 16:00:32 -06:00
$budget = new Budget;
$budget->id = 1;
$budget->dateFormatted = '2015';
$budget->budgeted = 120;
2016-01-22 23:59:22 -06:00
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$repository->shouldReceive('getBudgetedPerYear')->once()->andReturn(new Collection([$budget]));
2016-01-22 16:00:32 -06:00
$repository->shouldReceive('getBudgetsAndExpensesPerYear')->once()->andReturn([]);
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/chart/budget/multi-year/default/20150101/20160101/1/1');
$this->assertResponseStatus(200);
2016-01-20 02:15:33 -06:00
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::year
*/
public function testYear()
{
2016-01-22 23:59:22 -06:00
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
2016-01-22 16:00:32 -06:00
$repository->shouldReceive('getBudgetsAndExpensesPerMonth')->once()->andReturn([]);
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/chart/budget/year/default/20150101/20151231/1');
$this->assertResponseStatus(200);
2016-01-20 02:15:33 -06:00
2016-01-19 23:20:09 -06:00
}
}