mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Improve test coverage and efficiency for accounts and budgets.
This commit is contained in:
@@ -63,28 +63,19 @@ class CreateControllerTest extends TestCase
|
||||
public function testCreate(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||
|
||||
// used for session range.
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
// mock default calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
// mock default calls
|
||||
$this->mockDefaultSession();
|
||||
$this->mockIntroPreference('shown_demo_accounts_create_asset');
|
||||
|
||||
// mock default calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
|
||||
// get all types:
|
||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();
|
||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();
|
||||
@@ -105,31 +96,22 @@ class CreateControllerTest extends TestCase
|
||||
public function testStore(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$euro = $this->getEuro();
|
||||
$repository->shouldReceive('store')->once()->andReturn($asset);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
// mock default calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
$repository->shouldReceive('store')->once()->andReturn($asset);
|
||||
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// change the preference:
|
||||
$emptyPref = new Preference;
|
||||
$emptyPref->data = [];
|
||||
Preferences::shouldReceive('get')->atLeast()->once()->withArgs(['frontPageAccounts', []])->andReturn($emptyPref);
|
||||
Preferences::shouldReceive('set')->atLeast()->once()->withArgs(['frontPageAccounts', [$asset->id]]);
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
|
||||
Preferences::shouldReceive('mark')->atLeast()->once()->withNoArgs();
|
||||
|
||||
// mock default calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
|
||||
|
||||
$this->session(['accounts.create.uri' => 'http://localhost/x']);
|
||||
$this->be($this->user());
|
||||
$data = [
|
||||
@@ -151,28 +133,20 @@ class CreateControllerTest extends TestCase
|
||||
public function testStoreAnother(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$euro = $this->getEuro();
|
||||
|
||||
$repository->shouldReceive('store')->once()->andReturn($asset);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
// change the preference:
|
||||
$emptyPref = new Preference;
|
||||
$emptyPref->data = [];
|
||||
Preferences::shouldReceive('get')->atLeast()->once()->withArgs(['frontPageAccounts', []])->andReturn($emptyPref);
|
||||
Preferences::shouldReceive('set')->atLeast()->once()->withArgs(['frontPageAccounts', [$asset->id]]);
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
|
||||
// mock default calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
//$this->mockIntroPreference('shown_demo_accounts_create_asset');
|
||||
|
||||
// mock default calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
|
||||
|
||||
@@ -201,28 +175,18 @@ class CreateControllerTest extends TestCase
|
||||
public function testStoreLiability(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$liability = $this->getRandomLoan();
|
||||
$loan = AccountType::where('type', AccountType::LOAN)->first();
|
||||
$euro = $this->getEuro();
|
||||
$repository->shouldReceive('store')->once()->andReturn($liability);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// change the preference:
|
||||
$emptyPref = new Preference;
|
||||
$emptyPref->data = [];
|
||||
Preferences::shouldReceive('get')->atLeast()->once()->withArgs(['frontPageAccounts', []])->andReturn($emptyPref);
|
||||
|
||||
// mock default calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
//$this->mockIntroPreference('shown_demo_accounts_create_asset');
|
||||
|
||||
// mock default calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
|
||||
Preferences::shouldReceive('mark')->atLeast()->once()->withNoArgs();
|
||||
|
||||
$this->session(['accounts.create.uri' => 'http://localhost']);
|
||||
|
@@ -62,25 +62,15 @@ class DeleteControllerTest extends TestCase
|
||||
public function testDelete(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]])->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]])->andReturn(new Collection);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
// mock Amount
|
||||
$euro = $this->getEuro();
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
// mock calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
// mock calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.delete', [$asset->id]));
|
||||
@@ -96,25 +86,16 @@ class DeleteControllerTest extends TestCase
|
||||
public function testDestroy(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$euro = $this->getEuro();
|
||||
$repository->shouldReceive('findNull')->withArgs([0])->once()->andReturn(null);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
// mock calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
// mock calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
||||
// mock Amount
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
$this->session(['accounts.delete.uri' => 'http://localhost/accounts/show/1']);
|
||||
|
||||
$this->be($this->user());
|
||||
|
@@ -62,25 +62,20 @@ class EditControllerTest extends TestCase
|
||||
*/
|
||||
public function testEdit(): void
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$euro = $this->getEuro();
|
||||
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// mock preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
//$repository->shouldReceive('findNull')->withArgs([1])->andReturn($euro)->atLeast()->once();
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('get')->andReturn(new Collection)->atLeast()->once();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('getAccountCurrency')->andReturn($euro)->once();
|
||||
$accountRepos->shouldReceive('getNoteText')->andReturn('Some text')->once();
|
||||
$accountRepos->shouldReceive('getOpeningBalanceAmount')->andReturnNull()->atLeast()->once();
|
||||
@@ -100,12 +95,6 @@ class EditControllerTest extends TestCase
|
||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();
|
||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Mortgage'])->andReturn(AccountType::find(12))->once();
|
||||
|
||||
// mock calls to Preferences:
|
||||
//$this->mockDefaultPreferences();
|
||||
|
||||
// mock calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.edit', [$asset->id]));
|
||||
$response->assertStatus(200);
|
||||
@@ -120,7 +109,6 @@ class EditControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditLiability(): void
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
@@ -131,7 +119,7 @@ class EditControllerTest extends TestCase
|
||||
|
||||
//$repository->shouldReceive('findNull')->once()->andReturn($euro);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$accountRepos->shouldReceive('getNoteText')->andReturn('Some text')->once();
|
||||
$accountRepos->shouldReceive('getOpeningBalanceAmount')->andReturnNull();
|
||||
$accountRepos->shouldReceive('getOpeningBalanceDate')->andReturnNull();
|
||||
@@ -151,16 +139,8 @@ class EditControllerTest extends TestCase
|
||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();
|
||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Mortgage'])->andReturn(AccountType::find(12))->once();
|
||||
|
||||
// mock Amount
|
||||
$euro = $this->getEuro();
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
// mock calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
// mock calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.edit', [$loan->id]));
|
||||
@@ -177,7 +157,6 @@ class EditControllerTest extends TestCase
|
||||
public function testEditNull(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
@@ -185,10 +164,7 @@ class EditControllerTest extends TestCase
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
Amount::shouldReceive('getDefaultCurrency')->andReturn(TransactionCurrency::find(2));
|
||||
//$repository->shouldReceive('findNull')->once()->andReturn(null);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('getNoteText')->andReturn('Some text')->once();
|
||||
$accountRepos->shouldReceive('getOpeningBalanceAmount')->andReturnNull();
|
||||
$accountRepos->shouldReceive('getOpeningBalanceDate')->andReturnNull();
|
||||
@@ -203,11 +179,8 @@ class EditControllerTest extends TestCase
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'interest_period'])->andReturn('monthly');
|
||||
$accountRepos->shouldReceive('getAccountCurrency')->andReturn($euro)->once();
|
||||
|
||||
// mock calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
// mock calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// get all types:
|
||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();
|
||||
@@ -232,18 +205,15 @@ class EditControllerTest extends TestCase
|
||||
public function testUpdate(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('update')->once();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
||||
$euro = $this->getEuro();
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$this->session(['accounts.edit.uri' => 'http://localhost/javascript/account']);
|
||||
$this->be($this->user());
|
||||
$data = [
|
||||
@@ -252,12 +222,6 @@ class EditControllerTest extends TestCase
|
||||
'what' => 'asset',
|
||||
];
|
||||
|
||||
// mock calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
// mock calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
|
||||
$response = $this->post(route('accounts.update', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
@@ -271,11 +235,9 @@ class EditControllerTest extends TestCase
|
||||
public function testUpdateAgain(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('update')->once();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->session(['accounts.edit.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
@@ -286,15 +248,10 @@ class EditControllerTest extends TestCase
|
||||
'return_to_edit' => '1',
|
||||
];
|
||||
|
||||
$euro = $this->getEuro();
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
||||
// mock calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
// mock calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$response = $this->post(route('accounts.update', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
|
@@ -67,7 +67,6 @@ class IndexControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$account = $this->getRandomAsset();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
@@ -76,17 +75,12 @@ class IndexControllerTest extends TestCase
|
||||
|
||||
$repository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn($euro);
|
||||
Steam::shouldReceive('balancesByAccounts')->andReturn([$account->id => '100']);
|
||||
Steam::shouldReceive('getLastActivities')->andReturn([]);
|
||||
|
||||
|
||||
// mock calls to Preferences:
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
// mock calls to Configuration:
|
||||
$this->mockDefaultConfiguration();
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// list size
|
||||
$pref = new Preference;
|
||||
@@ -94,7 +88,6 @@ class IndexControllerTest extends TestCase
|
||||
Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
Amount::shouldReceive('formatAnything')->andReturn('123');
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'interest'])->andReturn('1');
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'interest_period'])->andReturn('monthly');
|
||||
|
@@ -23,16 +23,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Account;
|
||||
|
||||
use Amount;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\TransactionGroupFactory;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Log;
|
||||
use Mockery;
|
||||
@@ -67,24 +64,21 @@ class ReconcileControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$this->mock(GroupCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
$asset = $this->getRandomAsset();
|
||||
$date = new Carbon;
|
||||
$euro = $this->getEuro();
|
||||
$asset = $this->getRandomAsset();
|
||||
$date = new Carbon;
|
||||
|
||||
// used for session range.
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->atLeast()->once()->withArgs([Mockery::any(), 'owner'])->andReturnTrue();
|
||||
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$this->mockDefaultConfiguration();
|
||||
$this->mockDefaultPreferences();
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
Steam::shouldReceive('balance')->atLeast()->once()->andReturn('100');
|
||||
$accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile', [$asset->id, '20170101', '20170131']));
|
||||
$response->assertStatus(200);
|
||||
@@ -103,7 +97,7 @@ class ReconcileControllerTest extends TestCase
|
||||
{
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos = $this->mockDefaultSession();
|
||||
$asset = $this->getRandomAsset();
|
||||
$euro = $this->getEuro();
|
||||
$date = new Carbon;
|
||||
@@ -112,16 +106,9 @@ class ReconcileControllerTest extends TestCase
|
||||
$this->mock(CurrencyRepositoryInterface::class);
|
||||
$this->mock(GroupCollectorInterface::class);
|
||||
|
||||
|
||||
// used for session range.
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
$this->mockDefaultPreferences();
|
||||
$this->mockDefaultConfiguration();
|
||||
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
||||
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$journalRepos->shouldReceive('reconcileById')->times(3);
|
||||
@@ -130,6 +117,7 @@ class ReconcileControllerTest extends TestCase
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('create')->andReturn($group);
|
||||
|
||||
|
||||
$data = [
|
||||
'journals' => [1, 2, 3],
|
||||
'reconcile' => 'create',
|
||||
@@ -154,23 +142,14 @@ class ReconcileControllerTest extends TestCase
|
||||
{
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos = $this->mockDefaultSession();
|
||||
$asset = $this->getRandomAsset();
|
||||
$euro = $this->getEuro();
|
||||
$date = new Carbon;
|
||||
$factory = $this->mock(TransactionGroupFactory::class);
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
$this->mock(CurrencyRepositoryInterface::class);
|
||||
$this->mock(GroupCollectorInterface::class);
|
||||
|
||||
|
||||
// used for session range.
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
$this->mockDefaultPreferences();
|
||||
$this->mockDefaultConfiguration();
|
||||
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
@@ -27,11 +27,9 @@ use Amount;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Log;
|
||||
@@ -68,12 +66,10 @@ class ShowControllerTest extends TestCase
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
|
||||
// mock stuff:
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
//$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(CurrencyRepositoryInterface::class);
|
||||
//$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journal = $this->getRandomWithdrawalAsArray();
|
||||
@@ -81,26 +77,19 @@ class ShowControllerTest extends TestCase
|
||||
$asset = $this->getRandomAsset();
|
||||
$euro = $this->getEuro();
|
||||
|
||||
// mock stuff
|
||||
$this->mockDefaultConfiguration();
|
||||
$this->mockDefaultPreferences();
|
||||
$this->mockDefaultSession();
|
||||
|
||||
// amount mocks:
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('-100');
|
||||
|
||||
$repository->shouldReceive('getAccountCurrency')->andReturn($euro)->atLeast()->once();
|
||||
$repository->shouldReceive('oldestJournalDate')->andReturn(clone $date)->once();
|
||||
|
||||
|
||||
// used for session range.
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
// list size
|
||||
$pref = new Preference;
|
||||
$pref->data = 50;
|
||||
Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);
|
||||
Preferences::shouldReceive('lastActivity')->atLeast()->once();
|
||||
$this->mockLastActivity();
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
@@ -132,8 +121,6 @@ class ShowControllerTest extends TestCase
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
// mock stuff:
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
@@ -145,22 +132,12 @@ class ShowControllerTest extends TestCase
|
||||
$euro = $this->getEuro();
|
||||
$asset = $this->getRandomAsset();
|
||||
|
||||
// mock stuff
|
||||
$this->mockDefaultConfiguration();
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
// amount mocks:
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
// Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('-100');
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$repository->shouldReceive('isLiability')->andReturn(false)->atLeast()->once();
|
||||
$repository->shouldReceive('getAccountCurrency')->andReturn($euro)->atLeast()->once();
|
||||
$repository->shouldReceive('oldestJournalDate')->andReturn(clone $date)->once();
|
||||
|
||||
|
||||
// used for session range.
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
// list size
|
||||
$pref = new Preference;
|
||||
$pref->data = 50;
|
||||
|
Reference in New Issue
Block a user