mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Fix test coverage.
This commit is contained in:
@@ -107,119 +107,6 @@ class ReportControllerTest extends TestCase
|
||||
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
|
||||
*/
|
||||
public function testBalanceAmountDefaultNoBudget(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$account = $this->getRandomAsset();
|
||||
|
||||
$popupHelper->shouldReceive('balanceForNoBudget')->andReturn([]);
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn(null)->once()->withArgs([0]);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($account)->once()->withArgs([1]);
|
||||
//$popupHelper->shouldReceive('balanceForBudget')->once()->andReturn([]);
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100');
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
'attributes' => [
|
||||
'location' => 'balance-amount',
|
||||
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
|
||||
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
|
||||
'accounts' => 1,
|
||||
'accountId' => 1,
|
||||
'categoryId' => 1,
|
||||
'budgetId' => 0,
|
||||
'role' => 1, // ROLE_DEFAULTROLE
|
||||
],
|
||||
];
|
||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||
$response = $this->get($uri);
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee($account->name);
|
||||
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
|
||||
*/
|
||||
public function testBalanceAmountDefaultRole(): void
|
||||
{
|
||||
$this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$account = $this->getRandomAsset();
|
||||
$budget = $this->getRandomBudget();
|
||||
$this->mockDefaultSession();
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($account)->once()->withArgs([1]);
|
||||
$popupHelper->shouldReceive('balanceForBudget')->once()->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
'attributes' => [
|
||||
'location' => 'balance-amount',
|
||||
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
|
||||
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
|
||||
'accounts' => 1,
|
||||
'accountId' => 1,
|
||||
'categoryId' => 1,
|
||||
'budgetId' => 1,
|
||||
'role' => 1, // ROLE_DEFAULTROLE
|
||||
],
|
||||
];
|
||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||
$response = $this->get($uri);
|
||||
$response->assertStatus(200);
|
||||
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
|
||||
*/
|
||||
public function testBalanceAmountTagRole(): void
|
||||
{
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupReport = $this->mock(PopupReportInterface::class);
|
||||
$account = $this->getRandomAsset();
|
||||
$budget = $this->getRandomBudget();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($account)->once()->withArgs([1]);
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
'attributes' => [
|
||||
'location' => 'balance-amount',
|
||||
'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),
|
||||
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
|
||||
'accounts' => 1,
|
||||
'accountId' => 1,
|
||||
'categoryId' => 1,
|
||||
'budgetId' => 1,
|
||||
'role' => 2, // ROLE_TAGROLE
|
||||
],
|
||||
];
|
||||
|
||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||
$response = $this->get($uri);
|
||||
$response->assertStatus(200);
|
||||
$response->assertDontSee('Firefly III could not render the view. Please see the log files.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
|
||||
*/
|
||||
@@ -235,7 +122,7 @@ class ReportControllerTest extends TestCase
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
||||
$popupHelper->shouldReceive('byBudget')->andReturn([]);
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@@ -245,6 +132,7 @@ class ReportControllerTest extends TestCase
|
||||
'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),
|
||||
'accounts' => 1,
|
||||
'accountId' => 1,
|
||||
'currencyId' => 1,
|
||||
'categoryId' => 1,
|
||||
'budgetId' => 1,
|
||||
],
|
||||
@@ -265,7 +153,7 @@ class ReportControllerTest extends TestCase
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
$budgetRepos->shouldReceive('findNull')->andReturnNull()->once()->withArgs([1]);
|
||||
@@ -303,7 +191,8 @@ class ReportControllerTest extends TestCase
|
||||
$this->mockDefaultSession();
|
||||
$categoryRepos->shouldReceive('findNull')->andReturn($category)->once()->withArgs([1]);
|
||||
$popupHelper->shouldReceive('byCategory')->andReturn([]);
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
@@ -369,7 +258,7 @@ class ReportControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = $this->getRandomAsset();
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
|
||||
@@ -443,7 +332,8 @@ class ReportControllerTest extends TestCase
|
||||
$this->mockDefaultSession();
|
||||
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
|
||||
$popupHelper->shouldReceive('byIncome')->andReturn([]);
|
||||
Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
//Amount::shouldReceive('formatAnything')->andReturn('-100')->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Report;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collection\Balance;
|
||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||
use FireflyIII\Helpers\Report\BalanceReportHelperInterface;
|
||||
use Log;
|
||||
@@ -62,7 +61,7 @@ class BalanceControllerTest extends TestCase
|
||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$balance->shouldReceive('getBalanceReport')->andReturn(new Balance);
|
||||
$balance->shouldReceive('getBalanceReport')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('report-data.balance.general', ['1', '20120101', '20120131']));
|
||||
|
@@ -63,7 +63,7 @@ class BudgetControllerTest extends TestCase
|
||||
$date = new Carbon;
|
||||
|
||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
|
||||
//Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$helper->shouldReceive('getBudgetReport')->andReturn($return);
|
||||
|
@@ -112,11 +112,12 @@ class CategoryControllerTest extends TestCase
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||
//Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$repository->shouldReceive('getCategories')->andReturn(new Collection([$category]));
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('-1');
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('1');
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn([]);
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn([]);
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
|
@@ -55,7 +55,7 @@ class OperationsControllerTest extends TestCase
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$return = [
|
||||
1 => [
|
||||
1 => [
|
||||
'id' => 1,
|
||||
'name' => 'Some name',
|
||||
'sum' => '5',
|
||||
@@ -104,6 +104,7 @@ class OperationsControllerTest extends TestCase
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$return = [
|
||||
'sums' => [],
|
||||
1 => [
|
||||
'id' => 1,
|
||||
'name' => 'Some name',
|
||||
|
@@ -137,7 +137,7 @@ class SelectControllerTest extends TestCase
|
||||
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setTriggers')->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn(new Collection);
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$uri = route('rules.test-triggers') . '?' . http_build_query($data);
|
||||
@@ -206,7 +206,7 @@ class SelectControllerTest extends TestCase
|
||||
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setTriggers')->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn(new Collection);
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$uri = route('rules.test-triggers') . '?' . http_build_query($data);
|
||||
|
Reference in New Issue
Block a user