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

92 lines
2.9 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
*/
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-01-22 16:00:32 -06:00
$repository->shouldReceive('getExpensesPerMonth')->once()->andReturn(new Collection([new Budget]));
$repository->shouldReceive('getFirstBudgetLimitDate')->once()->andReturn(new Carbon);
$this->be($this->user());
$response = $this->call('GET', '/chart/budget/1');
$this->assertEquals(200, $response->status());
//$this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
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());
$response = $this->call('GET', '/chart/budget/1/1');
$this->assertEquals(200, $response->status());
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());
$response = $this->call('GET', '/chart/budget/frontpage');
$this->assertEquals(200, $response->status());
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());
$response = $this->call('GET', '/chart/budget/multi-year/default/20150101/20160101/1/1');
$this->assertEquals(200, $response->status());
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());
$response = $this->call('GET', '/chart/budget/year/default/20150101/20151231/1');
$this->assertEquals(200, $response->status());
2016-01-20 02:15:33 -06:00
2016-01-19 23:20:09 -06:00
}
}