Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
This fixes the tests.
James Cole9c6a3e4ad573
diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.phpindex 339855c695..f83a4b0153 100644--- a/app/Http/breadcrumbs.php+++ b/app/Http/breadcrumbs.php@@ -320,6 +320,14 @@ Breadcrumbs::register(});+Breadcrumbs::register(+ 'categories.show.all', function (BreadCrumbGenerator $breadcrumbs, Category $category) {+ $breadcrumbs->parent('categories.index');+ $breadcrumbs->push(e($category->name) . '(' . strtolower(trans('firefly.all_periods')) . ')', route('categories.show.all', [$category->id]));++}+);+Breadcrumbs::register('categories.show.date', function (BreadCrumbGenerator $breadcrumbs, Category $category, Carbon $date) {diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.phpindex 4d32e42fa6..451d995d59 100644--- a/app/Repositories/Category/CategoryRepository.php+++ b/app/Repositories/Category/CategoryRepository.php@@ -145,8 +145,10 @@ class CategoryRepository implements CategoryRepositoryInterface->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy('transaction_journals.date', 'ASC')->first(['transaction_journals.date']);++// both exist, the one that is earliest "wins".- if (!is_null($firstTransaction) && !is_null($first) && $firstTransaction->date->lt($first)) {+ if (!is_null($firstTransaction) && !is_null($first) && Carbon::parse($firstTransaction->date)->lt($first)) {$first = $firstTransaction->date;}diff --git a/tests/acceptance/Controllers/AccountControllerTest.php b/tests/acceptance/Controllers/AccountControllerTest.phpindex fb03855828..f133ab166b 100644--- a/tests/acceptance/Controllers/AccountControllerTest.php+++ b/tests/acceptance/Controllers/AccountControllerTest.php@@ -128,6 +128,22 @@ class AccountControllerTest extends TestCase$this->see('<ol class="breadcrumb">');}+ /**+ * @covers FireflyIII\Http\Controllers\AccountController::showWithDate+ * @dataProvider dateRangeProvider+ *+ * @param string $range+ */+ public function testShowAll(string $range)+ {+ $this->be($this->user());+ $this->changeDateRange($this->user(), $range);+ $this->call('GET', route('accounts.show.all', [1]));+ $this->assertResponseStatus(200);+ // has bread crumb+ $this->see('<ol class="breadcrumb">');+ }+/*** @covers FireflyIII\Http\Controllers\AccountController::showWithDate* @dataProvider dateRangeProviderdiff --git a/tests/acceptance/Controllers/CategoryControllerTest.php b/tests/acceptance/Controllers/CategoryControllerTest.phpindex 856f6b44c8..3b546635d3 100644--- a/tests/acceptance/Controllers/CategoryControllerTest.php+++ b/tests/acceptance/Controllers/CategoryControllerTest.php@@ -132,6 +132,7 @@ class CategoryControllerTest extends TestCase$collector->shouldReceive('setLimit')->andReturnSelf()->once();$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();$collector->shouldReceive('setRange')->andReturnSelf()->once();+ $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();$collector->shouldReceive('setCategory')->andReturnSelf()->once();$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();@@ -147,6 +148,32 @@ class CategoryControllerTest extends TestCase$this->see('<ol class="breadcrumb">');}+ /**+ * @covers \FireflyIII\Http\Controllers\CategoryController::showAll+ * @dataProvider dateRangeProvider+ *+ * @param string $range+ */+ public function testShowAll(string $range)+ {+ $collector = $this->mock(JournalCollectorInterface::class);++ // collector stuff:+ $collector->shouldReceive('setPage')->andReturnSelf()->once();+ $collector->shouldReceive('setLimit')->andReturnSelf()->once();+ $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();+ $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();+ $collector->shouldReceive('setCategory')->andReturnSelf()->once();+ $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();+++ $this->be($this->user());+ $this->changeDateRange($this->user(), $range);+ $this->call('GET', route('categories.show.all', [1]));+ $this->assertResponseStatus(200);+ $this->see('<ol class="breadcrumb">');+ }+/*** @covers \FireflyIII\Http\Controllers\CategoryController::showByDate* @dataProvider dateRangeProvider@@ -162,6 +189,7 @@ class CategoryControllerTest extends TestCase$collector->shouldReceive('setLimit')->andReturnSelf()->once();$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();$collector->shouldReceive('setRange')->andReturnSelf()->once();+ $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();$collector->shouldReceive('setCategory')->andReturnSelf()->once();$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();