mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-25 05:03:13 +00:00
Update tests so repositories are not called. Saves on DB calls, speeds up tests.
This commit is contained in:
@@ -61,6 +61,8 @@ class BoxControllerTest extends TestCase
|
||||
],
|
||||
];
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('1000');
|
||||
$repository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
$repository->shouldReceive('collectBudgetInformation')->andReturn($return);
|
||||
@@ -82,6 +84,8 @@ class BoxControllerTest extends TestCase
|
||||
],
|
||||
];
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('1000');
|
||||
$repository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
$repository->shouldReceive('collectBudgetInformation')->andReturn($return);
|
||||
@@ -99,6 +103,8 @@ class BoxControllerTest extends TestCase
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
|
||||
// try a collector for income:
|
||||
|
||||
@@ -124,6 +130,10 @@ class BoxControllerTest extends TestCase
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||
|
||||
|
||||
// try a collector for income:
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
|
||||
@@ -143,6 +153,8 @@ class BoxControllerTest extends TestCase
|
||||
public function testBills(): void
|
||||
{
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$billRepos->shouldReceive('getBillsPaidInRange')->andReturn('0');
|
||||
$billRepos->shouldReceive('getBillsUnpaidInRange')->andReturn('0');
|
||||
|
||||
@@ -165,6 +177,7 @@ class BoxControllerTest extends TestCase
|
||||
|
||||
|
||||
$netWorthHelper = $this->mock(NetWorthInterface::class);
|
||||
|
||||
$netWorthHelper->shouldReceive('setUser')->once();
|
||||
$netWorthHelper->shouldReceive('getNetWorthByCurrency')->once()->andReturn($result);
|
||||
|
||||
|
||||
@@ -27,9 +27,12 @@ namespace Tests\Feature\Controllers\Json;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -54,6 +57,9 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testOverview(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$transactions = $this->user()->transactions()->inRandomOrder()->take(3)->get();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
@@ -77,6 +83,10 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testOverviewNotAsset(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
|
||||
$account = $this->user()->accounts()->where('account_type_id', '!=', 3)->first();
|
||||
$parameters = [
|
||||
'startBalance' => '0',
|
||||
@@ -98,6 +108,11 @@ class ReconcileControllerTest extends TestCase
|
||||
public function testTransactions(): void
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -110,6 +125,11 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testTransactionsInitialBalance(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
|
||||
|
||||
$transaction = Transaction::leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->where('accounts.user_id', $this->user()->id)->where('accounts.account_type_id', 6)->first(['account_id']);
|
||||
$this->be($this->user());
|
||||
|
||||
Reference in New Issue
Block a user