Skip to content

Firefly III: a personal finances manager

Expand test coverage.

James Cole9a2c6c2967f6
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 46e332fc87..d559947d87 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -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);
diff --git a/tests/Feature/Controllers/CategoryControllerTest.php b/tests/Feature/Controllers/CategoryControllerTest.php
index 866634bd2d..19991eca10 100644
--- a/tests/Feature/Controllers/CategoryControllerTest.php
+++ b/tests/Feature/Controllers/CategoryControllerTest.php
@@ -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]));
diff --git a/tests/Feature/Controllers/Chart/AccountControllerTest.php b/tests/Feature/Controllers/Chart/AccountControllerTest.php
index 80be8da18b..ebe56a380f 100644
--- a/tests/Feature/Controllers/Chart/AccountControllerTest.php
+++ b/tests/Feature/Controllers/Chart/AccountControllerTest.php
@@ -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
diff --git a/tests/Feature/Controllers/DebugControllerTest.php b/tests/Feature/Controllers/DebugControllerTest.php
index 19efadbcd7..4c7d8f6649 100644
--- a/tests/Feature/Controllers/DebugControllerTest.php
+++ b/tests/Feature/Controllers/DebugControllerTest.php
@@ -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
*/