. */ declare(strict_types=1); namespace Tests\Feature\Controllers\Category; use Carbon\Carbon; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Fiscal\FiscalHelperInterface; use FireflyIII\Models\Preference; use FireflyIII\Models\TransactionJournal; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Collection; use Log; use Mockery; use Navigation; use Preferences; use Tests\TestCase; /** * * Class NoCategoryControllerTest */ class NoCategoryControllerTest extends TestCase { /** * */ public function setUp(): void { parent::setUp(); Log::info(sprintf('Now in %s.', get_class($this))); } /** * @covers \FireflyIII\Http\Controllers\Category\NoCategoryController * @dataProvider dateRangeProvider * * @param string $range */ public function testNoCategory(string $range): void { $collector = $this->mock(GroupCollectorInterface::class); $categoryRepos = $this->mock(CategoryRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $userRepos = $this->mock(UserRepositoryInterface::class); $this->mockDefaultSession(); // list size $pref = new Preference; $pref->data = 50; Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref); $this->mockLastActivity(); // get the journal with the most recent date for firstNull: $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once(); $collector->shouldReceive('setTypes')->andReturnSelf()->atLeast()->once(); $collector->shouldReceive('setRange')->andReturnSelf()->atLeast()->once(); $collector->shouldReceive('withoutCategory')->andReturnSelf()->atLeast()->once(); $collector->shouldReceive('getExtractedJournals')->andReturn([])->atLeast()->once(); $collector->shouldReceive('getPaginatedGroups')->andReturn(new LengthAwarePaginator([], 0, 10))->atLeast()->once(); $collector->shouldReceive('setPage')->andReturnSelf()->atLeast()->once(); $collector->shouldReceive('setLimit')->andReturnSelf()->atLeast()->once(); $this->be($this->user()); $this->changeDateRange($this->user(), $range); $response = $this->get(route('categories.no-category')); $response->assertStatus(200); // has bread crumb $response->assertSee('