Make sure tests work.

This commit is contained in:
James Cole 2018-03-31 21:05:06 +02:00
parent 7110c1178a
commit 5ce35a50c2
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
6 changed files with 38 additions and 9 deletions

View File

@ -58,7 +58,7 @@ MAIL_PASSWORD=null
MAIL_ENCRYPTION=null MAIL_ENCRYPTION=null
# Firefly III can send you the following messages # Firefly III can send you the following messages
SEND_REGISTRATION_MAIL=false SEND_REGISTRATION_MAIL=true
SEND_ERROR_MESSAGE=false SEND_ERROR_MESSAGE=false

View File

@ -37,10 +37,11 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Mockery;
use Preferences; use Preferences;
use Steam; use Steam;
use Tests\TestCase; use Tests\TestCase;
use Mockery;
/** /**
* Class AccountControllerTest * Class AccountControllerTest
* *
@ -142,12 +143,12 @@ class AccountControllerTest extends TestCase
$accountRepos->shouldReceive('getNote')->andReturn($note)->once(); $accountRepos->shouldReceive('getNote')->andReturn($note)->once();
$accountRepos->shouldReceive('getOpeningBalanceAmount')->andReturnNull(); $accountRepos->shouldReceive('getOpeningBalanceAmount')->andReturnNull();
$accountRepos->shouldReceive('getOpeningBalanceDate')->andReturnNull(); $accountRepos->shouldReceive('getOpeningBalanceDate')->andReturnNull();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'currency_id'])->andReturn('1'); $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'accountNumber'])->andReturn('123'); $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountNumber'])->andReturn('123');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'accountRole'])->andReturn('defaultAsset'); $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('defaultAsset');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'ccType'])->andReturn(''); $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'ccType'])->andReturn('');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'ccMonthlyPaymentDate'])->andReturn(''); $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'ccMonthlyPaymentDate'])->andReturn('');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'BIC'])->andReturn('BIC'); $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'BIC'])->andReturn('BIC');
$this->be($this->user()); $this->be($this->user());
$account = $this->user()->accounts()->where('account_type_id', 3)->whereNull('deleted_at')->first(); $account = $this->user()->accounts()->where('account_type_id', 3)->whereNull('deleted_at')->first();
@ -175,7 +176,9 @@ class AccountControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class); $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account])); $repository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
Steam::shouldReceive('balancesByAccounts')->andReturn([$account->id => '100']); Steam::shouldReceive('balancesByAccounts')->andReturn([$account->id => '100']);
Steam::shouldReceive('getLastActivities')->andReturn([]); Steam::shouldReceive('getLastActivities')->andReturn([]);

View File

@ -22,12 +22,15 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers; namespace Tests\Feature\Controllers;
use FireflyIII\Models\TransactionCurrency;
use Mockery;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
@ -141,11 +144,14 @@ class HomeControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class); $accountRepos = $this->mock(AccountRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class); $billRepos = $this->mock(BillRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('count')->andReturn(1); $accountRepos->shouldReceive('count')->andReturn(1);
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection([$account])); $accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection([$account]));
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account])); $accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$billRepos->shouldReceive('getBills')->andReturn(new Collection); $billRepos->shouldReceive('getBills')->andReturn(new Collection);
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
$collector->shouldReceive('setAccounts')->andReturnSelf(); $collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf(); $collector->shouldReceive('setRange')->andReturnSelf();

View File

@ -382,6 +382,10 @@ class ProfileControllerTest extends TestCase
$newToken = Preference::where('user_id', $this->user()->id)->where('name', 'access_token')->first(); $newToken = Preference::where('user_id', $this->user()->id)->where('name', 'access_token')->first();
$this->assertNotEquals($newToken->data, $token); $this->assertNotEquals($newToken->data, $token);
// reset token for later test:
$newToken->data = 'token';
$newToken->save();
} }
/** /**

View File

@ -25,6 +25,7 @@ namespace Tests\Feature\Controllers\Transaction;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
@ -35,6 +36,7 @@ use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
use Log; use Log;
use Mockery;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -71,6 +73,10 @@ class SplitControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class); $attHelper = $this->mock(AttachmentHelperInterface::class);
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first(); $deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$destination = $deposit->transactions()->where('amount', '>', 0)->first(); $destination = $deposit->transactions()->where('amount', '>', 0)->first();
@ -124,6 +130,10 @@ class SplitControllerTest extends TestCase
$account = $destination->account; $account = $destination->account;
$transactions = factory(Transaction::class, 3)->make(); $transactions = factory(Transaction::class, 3)->make();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection); $currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection); $budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
@ -243,6 +253,10 @@ class SplitControllerTest extends TestCase
$destination = $deposit->transactions()->where('amount', '>', 0)->first(); $destination = $deposit->transactions()->where('amount', '>', 0)->first();
$account = $destination->account; $account = $destination->account;
$accountRepository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
$journalRepos->shouldReceive('first')->once()->andReturn($deposit); $journalRepos->shouldReceive('first')->once()->andReturn($deposit);
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account])); $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account])); $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));

View File

@ -71,6 +71,8 @@ class CreateImportTest extends TestCase
$routine->shouldReceive('getJournals')->once()->andReturn(new Collection()); $routine->shouldReceive('getJournals')->once()->andReturn(new Collection());
$routine->shouldReceive('getLines')->once()->andReturn(7); $routine->shouldReceive('getLines')->once()->andReturn(7);
Storage::fake('upload'); Storage::fake('upload');
$output = $this->artisan( $output = $this->artisan(