Expand test coverage.

This commit is contained in:
James Cole 2018-01-24 11:09:21 +01:00
parent 602b35d589
commit 9a2c6c2967
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 48 additions and 9 deletions

View File

@ -84,10 +84,10 @@ class AccountController extends Controller
$step = '1W';
}
if ($months > 24) {
$step = '1M';
$step = '1M'; // @codeCoverageIgnore
}
if ($months > 100) {
$step = '1Y';
$step = '1Y'; // @codeCoverageIgnore
}
$chartData = [];
$current = clone $start;
@ -106,8 +106,8 @@ class AccountController extends Controller
}
break;
case '1W':
case '1M':
case '1Y':
case '1M': // @codeCoverageIgnore
case '1Y': // @codeCoverageIgnore
while ($end >= $current) {
$balance = floatval(Steam::balance($account, $current));
$label = app('navigation')->periodShow($current, $step);

View File

@ -33,6 +33,7 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Navigation;
use Steam;
use Tests\TestCase;
@ -229,6 +230,13 @@ class CategoryControllerTest extends TestCase
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
Navigation::shouldReceive('updateStartDate')->andReturn(new Carbon);
Navigation::shouldReceive('updateEndDate')->andReturn(new Carbon);
Navigation::shouldReceive('startOfPeriod')->andReturn(new Carbon);
Navigation::shouldReceive('endOfPeriod')->andReturn(new Carbon);
Navigation::shouldReceive('periodShow')->andReturn('Some date');
Navigation::shouldReceive('blockPeriods')->andReturn([['period' =>'1M','start' => new Carbon, 'end' => new Carbon]])->once();
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('categories.no-category', ['2016-01-01']));
@ -262,15 +270,25 @@ class CategoryControllerTest extends TestCase
$collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setPage')->andReturnSelf()->once();
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setRange')->andReturnSelf()->once();
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->atLeast(2);
$collector->shouldReceive('setRange')->andReturnSelf()->atLeast(2);
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->atLeast(2);
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
$collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once();
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->atLeast(2);
$collector->shouldReceive('setCategory')->andReturnSelf()->atLeast(2);
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10))->once();
$collector->shouldReceive('setTypes')->andReturnSelf()->atLeast(1);
$collector->shouldReceive('getJournals')->andReturn(new Collection)->atLeast(1);
Navigation::shouldReceive('updateStartDate')->andReturn(new Carbon);
Navigation::shouldReceive('updateEndDate')->andReturn(new Carbon);
Navigation::shouldReceive('startOfPeriod')->andReturn(new Carbon);
Navigation::shouldReceive('endOfPeriod')->andReturn(new Carbon);
Navigation::shouldReceive('periodShow')->andReturn('Some date');
Navigation::shouldReceive('blockPeriods')->andReturn([['period' =>'1M','start' => new Carbon, 'end' => new Carbon]])->once();
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('categories.show', [1]));

View File

@ -64,6 +64,26 @@ class AccountControllerTest extends TestCase
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::all
*/
public function testAllLongRange()
{
$generator = $this->mock(GeneratorInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$carbon = new Carbon;
$carbon->subMonths(5);
$accountRepos->shouldReceive('oldestJournalDate')->once()->andReturn($carbon);
Steam::shouldReceive('balance')->andReturn('0');
$generator->shouldReceive('singleSet')->andReturn([]);
$this->be($this->user());
$response = $this->get(route('chart.account.all', [1]));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::expenseAccounts
* @covers \FireflyIII\Generator\Chart\Basic\GeneratorInterface::singleSet

View File

@ -43,6 +43,7 @@ class DebugControllerTest extends TestCase
{
/**
* @covers \FireflyIII\Http\Controllers\DebugController::index
* @covers \FireflyIII\Http\Controllers\DebugController::__construct
* @covers \FireflyIII\Http\Controllers\DebugController::errorReporting
* @covers \FireflyIII\Http\Controllers\DebugController::collectPackages
*/