. */ declare(strict_types=1); namespace Tests\Feature\Controllers\Category; use Carbon\Carbon; use FireflyIII\Helpers\Collector\TransactionCollectorInterface; use FireflyIII\Helpers\Filter\InternalTransferFilter; use FireflyIII\Helpers\Fiscal\FiscalHelperInterface; use FireflyIII\Models\Transaction; 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 Tests\TestCase; /** * * Class ShowControllerTest */ class ShowControllerTest extends TestCase { /** * */ public function setUp(): void { parent::setUp(); Log::info(sprintf('Now in %s.', get_class($this))); } /** * @covers \FireflyIII\Http\Controllers\Category\ShowController * * @dataProvider dateRangeProvider * * @param string $range */ public function testShow(string $range): void { $this->markTestIncomplete('Needs to be rewritten for v4.8.0'); return; Log::info(sprintf('Test show(%s)', $range)); $transaction = factory(Transaction::class)->make(); $categoryRepos = $this->mock(CategoryRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $userRepos = $this->mock(UserRepositoryInterface::class); $fiscalHelper = $this->mock(FiscalHelperInterface::class); $fiscalHelper->shouldReceive('endOfFiscalYear')->andReturn(new Carbon); $fiscalHelper->shouldReceive('startOfFiscalYear')->andReturn(new Carbon); $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true); $journalRepos->shouldReceive('firstNull')->twice()->andReturn(TransactionJournal::first()); // mock stuff $categoryRepos->shouldReceive('spentInPeriodCollection')->andReturn(new Collection); $categoryRepos->shouldReceive('earnedInPeriodCollection')->andReturn(new Collection); //$accountRepos->shouldReceive('getAccountsByType')->once()->andReturn(new Collection); $collector = $this->mock(TransactionCollectorInterface::class); $collector->shouldReceive('setPage')->andReturnSelf()->once(); $collector->shouldReceive('setLimit')->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()->atLeast(2); $collector->shouldReceive('setCategory')->andReturnSelf()->atLeast(2); $collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([$transaction], 0, 10))->once(); $collector->shouldReceive('setTypes')->andReturnSelf()->atLeast(1); $collector->shouldReceive('getTransactions')->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])); $response->assertStatus(200); $response->assertSee('