diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php index 4dc431ccfb..eb0e54edfd 100644 --- a/app/Http/Controllers/Category/ShowController.php +++ b/app/Http/Controllers/Category/ShowController.php @@ -36,7 +36,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Support\CacheProperties; use Illuminate\Http\Request; use Illuminate\Support\Collection; - +use Log; /** * @@ -88,10 +88,11 @@ class ShowController extends Controller */ public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null) { + Log::debug('Now in show()'); /** @var Carbon $start */ - $start = $start ?? session('start'); + $start = $start ?? session('start', Carbon::create()->startOfMonth()); /** @var Carbon $end */ - $end = $end ?? session('end'); + $end = $end ?? session('end', Carbon::create()->startOfMonth()); $subTitleIcon = 'fa-bar-chart'; $moment = ''; $page = (int)$request->get('page'); @@ -112,6 +113,8 @@ class ShowController extends Controller $transactions = $collector->getPaginatedJournals(); $transactions->setPath($path); + Log::debug('End of show()'); + return view('categories.show', compact('category', 'transactions', 'moment', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); } diff --git a/tests/Feature/Controllers/Category/ShowControllerTest.php b/tests/Feature/Controllers/Category/ShowControllerTest.php index b678a30176..f6a4eacf11 100644 --- a/tests/Feature/Controllers/Category/ShowControllerTest.php +++ b/tests/Feature/Controllers/Category/ShowControllerTest.php @@ -63,7 +63,7 @@ class ShowControllerTest extends TestCase */ public function testShow(string $range): void { - Log::debug('Test show()'); + Log::debug(sprintf('Test show(%s)', $range)); $transaction = factory(Transaction::class)->make(); $categoryRepos = $this->mock(CategoryRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class); @@ -113,7 +113,7 @@ class ShowControllerTest extends TestCase */ public function testShowAll(string $range): void { - Log::debug('Test showAll()'); + Log::debug(sprintf('Test showAll(%s)', $range)); // mock stuff $transaction = factory(Transaction::class)->make(); $journalRepos = $this->mock(JournalRepositoryInterface::class); @@ -151,7 +151,7 @@ class ShowControllerTest extends TestCase */ public function testShowByDate(string $range): void { - Log::debug('Test showbydate()'); + Log::debug(sprintf('Test testShowByDate(%s)', $range)); // mock stuff $transaction = factory(Transaction::class)->make(); $repository = $this->mock(CategoryRepositoryInterface::class); @@ -199,9 +199,12 @@ class ShowControllerTest extends TestCase */ public function testShowEmpty(string $range): void { - Log::debug('Test showempty()'); + $latestJournal = $this->user()->transactionJournals() + ->orderBy('date','DESC')->first(); + + Log::debug(sprintf('Test testShowEmpty(%s)', $range)); $journalRepos = $this->mock(JournalRepositoryInterface::class); - $journalRepos->shouldReceive('firstNull')->twice()->andReturn(TransactionJournal::first()); + $journalRepos->shouldReceive('firstNull')->twice()->andReturn($latestJournal); // mock stuff $repository = $this->mock(CategoryRepositoryInterface::class);