Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Improve test coverage.
James Cole477acafc4ce6
diff --git a/tests/Feature/Controllers/CategoryControllerTest.php b/tests/Feature/Controllers/CategoryControllerTest.phpindex e8f7ccc705..ae0531d9e9 100644--- a/tests/Feature/Controllers/CategoryControllerTest.php+++ b/tests/Feature/Controllers/CategoryControllerTest.php@@ -101,11 +101,12 @@ class CategoryControllerTest extends TestCasepublic function testIndex(){// mock stuff+ $category = factory(Category::class)->make();$repository = $this->mock(CategoryRepositoryInterface::class);$journalRepos = $this->mock(JournalRepositoryInterface::class);$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);- $repository->shouldReceive('getCategories')->andReturn(new Collection);- $repository->shouldReceive('lastUseDate')->andReturn(new Carbon);+ $repository->shouldReceive('getCategories')->andReturn(new Collection([$category]))->once();+ $repository->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();$this->be($this->user());$response = $this->get(route('categories.index'));@@ -220,47 +221,6 @@ class CategoryControllerTest extends TestCase$response->assertSee('<ol class="breadcrumb">');}- /**- * @covers \FireflyIII\Http\Controllers\CategoryController::show- * @covers \FireflyIII\Http\Controllers\CategoryController::getPeriodOverview- *- * @dataProvider dateRangeProvider- *- * @param string $range- */- public function testShowEmpty(string $range)- {- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);-- // mock stuff- $repository = $this->mock(CategoryRepositoryInterface::class);- $repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon);- $repository->shouldReceive('spentInPeriod')->andReturn('0');- $repository->shouldReceive('earnedInPeriod')->andReturn('0');-- $accountRepos = $this->mock(AccountRepositoryInterface::class);- $accountRepos->shouldReceive('getAccountsByType')->once()->andReturn(new Collection);-- $collector = $this->mock(JournalCollectorInterface::class);- $collector->shouldReceive('setPage')->andReturnSelf()->times(3);- $collector->shouldReceive('setLimit')->andReturnSelf()->times(3);- $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->times(3);- $collector->shouldReceive('setRange')->andReturnSelf()->times(3);- $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->times(3);- $collector->shouldReceive('withCategoryInformation')->andReturnSelf()->times(3);- $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(3);-- $collector->shouldReceive('setCategory')->andReturnSelf()->times(3);- $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->times(3);-- $this->be($this->user());- $this->changeDateRange($this->user(), $range);- $response = $this->get(route('categories.show', [1]));- $response->assertStatus(200);- $response->assertSee('<ol class="breadcrumb">');- }-/*** @covers \FireflyIII\Http\Controllers\CategoryController::show* @covers \FireflyIII\Http\Controllers\CategoryController::getPeriodOverview@@ -379,6 +339,47 @@ class CategoryControllerTest extends TestCase$response->assertSee('<ol class="breadcrumb">');}+ /**+ * @covers \FireflyIII\Http\Controllers\CategoryController::show+ * @covers \FireflyIII\Http\Controllers\CategoryController::getPeriodOverview+ *+ * @dataProvider dateRangeProvider+ *+ * @param string $range+ */+ public function testShowEmpty(string $range)+ {+ $journalRepos = $this->mock(JournalRepositoryInterface::class);+ $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);++ // mock stuff+ $repository = $this->mock(CategoryRepositoryInterface::class);+ $repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon);+ $repository->shouldReceive('spentInPeriod')->andReturn('0');+ $repository->shouldReceive('earnedInPeriod')->andReturn('0');++ $accountRepos = $this->mock(AccountRepositoryInterface::class);+ $accountRepos->shouldReceive('getAccountsByType')->once()->andReturn(new Collection);++ $collector = $this->mock(JournalCollectorInterface::class);+ $collector->shouldReceive('setPage')->andReturnSelf()->times(3);+ $collector->shouldReceive('setLimit')->andReturnSelf()->times(3);+ $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->times(3);+ $collector->shouldReceive('setRange')->andReturnSelf()->times(3);+ $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->times(3);+ $collector->shouldReceive('withCategoryInformation')->andReturnSelf()->times(3);+ $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(3);++ $collector->shouldReceive('setCategory')->andReturnSelf()->times(3);+ $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->times(3);++ $this->be($this->user());+ $this->changeDateRange($this->user(), $range);+ $response = $this->get(route('categories.show', [1]));+ $response->assertStatus(200);+ $response->assertSee('<ol class="breadcrumb">');+ }+/*** @covers \FireflyIII\Http\Controllers\CategoryController::store*/diff --git a/tests/Feature/Controllers/NewUserControllerTest.php b/tests/Feature/Controllers/NewUserControllerTest.phpindex 9c613b64c9..aa0af56ee0 100644--- a/tests/Feature/Controllers/NewUserControllerTest.php+++ b/tests/Feature/Controllers/NewUserControllerTest.php@@ -43,8 +43,30 @@ class NewUserControllerTest extends TestCase$response->assertSee('<ol class="breadcrumb">');}+ /**+ * @covers \FireflyIII\Http\Controllers\NewUserController::index+ * @covers \FireflyIII\Http\Controllers\NewUserController::__construct+ */+ public function testIndexExisting()+ {+ // mock stuff+ $accountRepos = $this->mock(AccountRepositoryInterface::class);+ $journalRepos = $this->mock(JournalRepositoryInterface::class);+ $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);+ $accountRepos->shouldReceive('count')->andReturn(1);+++ $this->be($this->user());+ $response = $this->get(route('new-user.index'));+ $response->assertStatus(302);+ $response->assertRedirect(route('index'));+ }+/*** @covers \FireflyIII\Http\Controllers\NewUserController::submit+ * @covers \FireflyIII\Http\Controllers\NewUserController::createAssetAccount+ * @covers \FireflyIII\Http\Controllers\NewUserController::createSavingsAccount+ * @covers \FireflyIII\Http\Controllers\NewUserController::storeCreditCard*/public function testSubmit(){