mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-23 19:51:24 +00:00
Fix test coverage.
This commit is contained in:
85
tests/Feature/Controllers/Transaction/ShowControllerTest.php
Normal file
85
tests/Feature/Controllers/Transaction/ShowControllerTest.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* ShowControllerTest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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
|
||||
*/
|
||||
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[0]['transactions'][0]['foreign_amount'] = '10';
|
||||
$array[0]['transactions'][0]['foreign_currency_symbol'] = 'x';
|
||||
$array[0]['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[0]);
|
||||
|
||||
// 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('<ol class="breadcrumb">');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user