. */ namespace Tests\Feature\Controllers\Transaction; use Amount; use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Transformers\TransactionGroupTransformer; use Log; use Mockery; use Tests\TestCase; /** * Class ShowControllerTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class ShowControllerTest extends TestCase { /** * */ public function setUp(): void { parent::setUp(); Log::info(sprintf('Now in %s.', get_class($this))); } /** * @covers \FireflyIII\Http\Controllers\Transaction\ShowController */ public function testShow(): void { $this->mockDefaultSession(); // values $withdrawal = $this->getRandomWithdrawalGroup(); $array = $this->getRandomWithdrawalGroupAsArray(); $array['transactions'][0]['foreign_amount'] = '10'; $array['transactions'][0]['foreign_currency_symbol'] = 'x'; $array['transactions'][0]['foreign_currency_decimal_places'] = 2; $groupRepository = $this->mock(TransactionGroupRepositoryInterface::class); $userRepos = $this->mock(UserRepositoryInterface::class); $transformer = $this->mock(TransactionGroupTransformer::class); // mock for transformer: $transformer->shouldReceive('setParameters')->atLeast()->once(); $transformer->shouldReceive('transformObject')->atLeast()->once()->andReturn($array); // mock for repos $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true); $groupRepository->shouldReceive('getPiggyEvents')->atLeast()->once()->andReturn([]); $groupRepository->shouldReceive('getAttachments')->atLeast()->once()->andReturn([]); $groupRepository->shouldReceive('getLinks')->atLeast()->once()->andReturn([]); Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x'); $this->be($this->user()); $response = $this->get(route('transactions.show', [$withdrawal->id])); $response->assertStatus(200); // has bread crumb $response->assertSee('