Mock more repositories in tests.

This commit is contained in:
James Cole 2018-09-03 18:52:46 +02:00
parent 480b636c7e
commit 46ba0a5a5a
137 changed files with 496 additions and 222 deletions

View File

@ -525,7 +525,7 @@ class FireflyValidator extends Validator
try {
$value = Crypt::decrypt($value);
} catch (DecryptException $e) {
Log::debug(sprintf('Could not decrypt. %s', $e->getMessage()));
//Log::debug(sprintf('Could not decrypt. %s', $e->getMessage()));
}
return $value;

View File

@ -39,7 +39,7 @@ class AboutControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -44,7 +44,7 @@ class AccountControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -45,7 +45,7 @@ class AttachmentControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -99,7 +99,6 @@ class AttachmentControllerTest extends TestCase
* Download attachment but file doesn't exist.
*
* @covers \FireflyIII\Api\V1\Controllers\AttachmentController
* @expectedExceptionMessage Some error message
*/
public function testDownloadNotExisting(): void
{

View File

@ -45,7 +45,7 @@ class AvailableBudgetControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -44,7 +44,7 @@ class BillControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -43,7 +43,7 @@ class BudgetControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -44,7 +44,7 @@ class BudgetLimitControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -43,7 +43,7 @@ class CategoryControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -42,7 +42,7 @@ class ConfigurationControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -46,7 +46,7 @@ class CurrencyControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -46,7 +46,7 @@ class CurrencyExchangeRateControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -48,7 +48,7 @@ class JournalLinkControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -44,7 +44,7 @@ class LinkTypeControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -46,7 +46,7 @@ class PiggyBankControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -44,7 +44,7 @@ class PreferencesControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -44,7 +44,7 @@ class RecurrenceControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -43,7 +43,7 @@ class RuleControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -43,7 +43,7 @@ class RuleGroupControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -48,7 +48,7 @@ class TransactionControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -44,7 +44,7 @@ class UserControllerTest extends TestCase
{
parent::setUp();
Passport::actingAs($this->user());
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -33,9 +33,10 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Preferences;
use Tests\TestCase;
use Mockery;
/**
*
* Class CreateControllerTest
@ -48,7 +49,7 @@ class CreateControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
@ -66,7 +67,7 @@ class CreateControllerTest extends TestCase
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
// get all types:
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();
@ -90,8 +91,8 @@ class CreateControllerTest extends TestCase
public function testStore(): void
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@ -119,8 +120,8 @@ class CreateControllerTest extends TestCase
public function testStoreAnother(): void
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);

View File

@ -27,7 +27,6 @@ namespace Tests\Feature\Controllers\Account;
use FireflyIII\Models\AccountType;
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 Illuminate\Support\Collection;
@ -47,7 +46,7 @@ class DeleteControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -57,14 +56,14 @@ 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);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]])->andReturn(new Collection);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$this->be($this->user());
$account = $this->user()->accounts()->where('account_type_id', 3)->whereNull('deleted_at')->first();
@ -81,8 +80,8 @@ class DeleteControllerTest extends TestCase
public function testDestroy(): void
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('findNull')->withArgs([0])->once()->andReturn(null);
$repository->shouldReceive('destroy')->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);

View File

@ -49,7 +49,7 @@ class EditControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -57,10 +57,10 @@ 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);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
@ -103,10 +103,10 @@ 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);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
@ -149,10 +149,10 @@ 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);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();

View File

@ -50,7 +50,7 @@ class IndexControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
@ -71,7 +71,7 @@ class IndexControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class);
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$repository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');

View File

@ -47,7 +47,7 @@ class ReconcileControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -106,9 +106,12 @@ class ReconcileControllerTest extends TestCase
*/
public function testReconcile(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('getMetaValue')
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
@ -129,6 +132,10 @@ class ReconcileControllerTest extends TestCase
*/
public function testReconcileInitialBalance(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::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());
@ -143,9 +150,12 @@ class ReconcileControllerTest extends TestCase
*/
public function testReconcileNoDates(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('getMetaValue')
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
@ -167,9 +177,12 @@ class ReconcileControllerTest extends TestCase
*/
public function testReconcileNoEndDate(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('getMetaValue')
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
@ -207,15 +220,19 @@ class ReconcileControllerTest extends TestCase
*/
public function testShow(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos->shouldReceive('getMetaValue')
->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
$currencyRepos->shouldReceive('findNull')->atLeast()->once()->withArgs([1])->andReturn(TransactionCurrency::find(1));
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$repository->shouldReceive('getAssetTransaction')->once()->andReturn($journal->transactions()->first());
@ -238,9 +255,9 @@ class ReconcileControllerTest extends TestCase
{
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$repository = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(JournalRepositoryInterface::class);
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$repository->shouldReceive('getAssetTransaction')->once()->andReturnNull();
@ -279,8 +296,8 @@ class ReconcileControllerTest extends TestCase
*/
public function testSubmit(): void
{
$repository = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
@ -310,7 +327,7 @@ class ReconcileControllerTest extends TestCase
*/
public function testUpdate(): void
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
@ -336,6 +353,9 @@ class ReconcileControllerTest extends TestCase
*/
public function testUpdateNotReconcile(): void
{
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
$data = ['amount' => '5',];
@ -351,6 +371,9 @@ class ReconcileControllerTest extends TestCase
*/
public function testUpdateZero(): void
{
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
$data = ['amount' => '0',];

View File

@ -51,7 +51,7 @@ class ShowControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
@ -67,13 +67,15 @@ class ShowControllerTest extends TestCase
$this->session(['start' => $date, 'end' => clone $date]);
// mock stuff:
$tasker = $this->mock(AccountTaskerInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$tasker = $this->mock(AccountTaskerInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
@ -121,10 +123,11 @@ class ShowControllerTest extends TestCase
$tasker = $this->mock(AccountTaskerInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
@ -159,12 +162,16 @@ class ShowControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Account\ShowController
* @expectedExceptionMessage End is after start!
*/
public function testShowBrokenBadDates(): void
{
// mock
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('isLiability')->atLeast()->once()->andReturn(false);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->session(['start' => '2018-01-01', 'end' => '2017-12-01']);
@ -172,6 +179,7 @@ class ShowControllerTest extends TestCase
$account = $this->user()->accounts()->where('account_type_id', 3)->orderBy('id', 'ASC')->whereNull('deleted_at')->first();
$response = $this->get(route('accounts.show', [$account->id, '2018-01-01', '2017-12-01']));
$response->assertStatus(500);
$response->assertSee('End is after start!');
}
/**
@ -181,6 +189,9 @@ class ShowControllerTest extends TestCase
{
// mock
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$date = new Carbon;
$this->session(['start' => $date, 'end' => clone $date]);
@ -209,7 +220,7 @@ class ShowControllerTest extends TestCase
$repository = $this->mock(AccountRepositoryInterface::class);
// mock hasRole for user repository:
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$collector->shouldReceive('setAccounts')->andReturnSelf();
@ -244,6 +255,8 @@ class ShowControllerTest extends TestCase
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$date = new Carbon;

View File

@ -24,7 +24,9 @@ namespace Tests\Feature\Controllers\Admin;
use FireflyConfig;
use FireflyIII\Models\Configuration;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
use Tests\TestCase;
/**
@ -38,7 +40,7 @@ class ConfigurationControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -47,8 +49,11 @@ class ConfigurationControllerTest extends TestCase
*/
public function testIndex(): void
{
$this->be($this->user());
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$this->be($this->user());
$falseConfig = new Configuration;
$falseConfig->data = false;
@ -70,6 +75,11 @@ class ConfigurationControllerTest extends TestCase
*/
public function testPostIndex(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$falseConfig = new Configuration;
$falseConfig->data = false;

View File

@ -24,7 +24,9 @@ namespace Tests\Feature\Controllers\Admin;
use Event;
use FireflyIII\Events\AdminRequestedTestMessage;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
use Tests\TestCase;
/**
@ -38,7 +40,7 @@ class HomeControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -46,6 +48,10 @@ class HomeControllerTest extends TestCase
*/
public function testIndex(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$this->be($this->user());
$response = $this->get(route('admin.index'));
$response->assertStatus(200);
@ -58,6 +64,11 @@ class HomeControllerTest extends TestCase
*/
public function testTestMessage(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
Event::fake();
$this->be($this->user());

View File

@ -24,8 +24,10 @@ namespace Tests\Feature\Controllers\Admin;
use FireflyIII\Models\LinkType;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Tests\TestCase;
/**
@ -39,7 +41,7 @@ class LinkControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -47,7 +49,10 @@ class LinkControllerTest extends TestCase
*/
public function testCreate(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$this->be($this->user());
$response = $this->get(route('admin.links.create'));
$response->assertStatus(200);
@ -58,10 +63,14 @@ class LinkControllerTest extends TestCase
*/
public function testDeleteEditable(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
// create editable link type just in case:
LinkType::create(['editable' => 1, 'inward' => 'hello', 'outward' => 'bye', 'name' => 'Test type']);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$linkType = LinkType::where('editable', 1)->first();
$repository->shouldReceive('get')->once()->andReturn(new Collection([$linkType]));
$repository->shouldReceive('countJournals')->andReturn(2);
@ -75,8 +84,12 @@ class LinkControllerTest extends TestCase
*/
public function testDeleteNonEditable(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$linkType = LinkType::where('editable', 0)->first();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$this->be($this->user());
$response = $this->get(route('admin.links.delete', [$linkType->id]));
$response->assertStatus(302);
@ -88,8 +101,12 @@ class LinkControllerTest extends TestCase
*/
public function testDestroy(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
// create editable link type just in case:
LinkType::create(['editable' => 1, 'inward' => 'hellox', 'outward' => 'byex', 'name' => 'Test typeX']);
@ -108,6 +125,11 @@ class LinkControllerTest extends TestCase
*/
public function testEditEditable(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
// create editable link type just in case:
LinkType::create(['editable' => 1, 'inward' => 'hello Y', 'outward' => 'bye Y', 'name' => 'Test type Y']);
@ -122,6 +144,11 @@ class LinkControllerTest extends TestCase
*/
public function testEditNonEditable(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$linkType = LinkType::where('editable', 0)->first();
$this->be($this->user());
$response = $this->get(route('admin.links.edit', [$linkType->id]));
@ -134,6 +161,11 @@ class LinkControllerTest extends TestCase
*/
public function testIndex(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$linkTypes = LinkType::inRandomOrder()->take(3)->get();
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$repository->shouldReceive('get')->andReturn($linkTypes);
@ -148,6 +180,11 @@ class LinkControllerTest extends TestCase
*/
public function testShow(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$linkType = LinkType::first();
$this->be($this->user());
$response = $this->get(route('admin.links.show', [$linkType->id]));
@ -160,8 +197,13 @@ class LinkControllerTest extends TestCase
*/
public function testStore(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$data = [
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$data = [
'name' => 'test ' . random_int(1, 10000),
'inward' => 'test inward' . random_int(1, 10000),
'outward' => 'test outward' . random_int(1, 10000),
@ -182,8 +224,13 @@ class LinkControllerTest extends TestCase
*/
public function testStoreRedirect(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$data = [
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$data = [
'name' => 'test ' . random_int(1, 10000),
'inward' => 'test inward' . random_int(1, 10000),
'outward' => 'test outward' . random_int(1, 10000),
@ -203,8 +250,12 @@ class LinkControllerTest extends TestCase
*/
public function testUpdate(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
// create editable link type just in case:
$linkType = LinkType::create(['editable' => 1, 'inward' => 'helloxz', 'outward' => 'bzyex', 'name' => 'Test tyzpeX']);
$repository->shouldReceive('update')->once()->andReturn(new $linkType);
@ -227,8 +278,13 @@ class LinkControllerTest extends TestCase
*/
public function testUpdateNonEditable(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$linkType = LinkType::where('editable', 0)->first();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$linkType = LinkType::where('editable', 0)->first();
$data = [
'name' => 'test ' . random_int(1, 10000),
@ -249,7 +305,12 @@ class LinkControllerTest extends TestCase
*/
public function testUpdateRedirect(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
// create editable link type just in case:
$linkType = LinkType::create(['editable' => 1, 'inward' => 'healox', 'outward' => 'byaex', 'name' => 'Test tyapeX']);

View File

@ -26,6 +26,7 @@ use Carbon\Carbon;
use FireflyConfig;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Configuration;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Services\Github\Object\Release;
use FireflyIII\Services\Github\Request\UpdateRequest;
use Log;
@ -43,7 +44,7 @@ class UpdateControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -51,6 +52,10 @@ class UpdateControllerTest extends TestCase
*/
public function testIndex(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$this->be($this->user());
$config = new Configuration;
@ -74,6 +79,11 @@ class UpdateControllerTest extends TestCase
*/
public function testPost(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$falseConfig = new Configuration;
$falseConfig->data = false;
@ -93,6 +103,11 @@ class UpdateControllerTest extends TestCase
*/
public function testUpdateCheck(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$falseConfig = new Configuration;
$falseConfig->data = false;
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
@ -123,6 +138,11 @@ class UpdateControllerTest extends TestCase
*/
public function testUpdateCheckCurrent(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$falseConfig = new Configuration;
$falseConfig->data = false;
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
@ -151,6 +171,11 @@ class UpdateControllerTest extends TestCase
*/
public function testUpdateCheckError(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$falseConfig = new Configuration;
$falseConfig->data = false;
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
@ -174,6 +199,11 @@ class UpdateControllerTest extends TestCase
*/
public function testUpdateCheckNewer(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$falseConfig = new Configuration;
$falseConfig->data = false;
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);

View File

@ -39,7 +39,7 @@ class UserControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -26,8 +26,10 @@ use FireflyIII\Models\Attachment;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Tests\TestCase;
/**
@ -45,7 +47,7 @@ class AttachmentControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -56,6 +58,10 @@ class AttachmentControllerTest extends TestCase
// mock stuff
$attachRepository = $this->mock(AttachmentRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('attachments.delete', [1]));
@ -72,6 +78,8 @@ class AttachmentControllerTest extends TestCase
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AttachmentRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@ -90,6 +98,8 @@ class AttachmentControllerTest extends TestCase
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AttachmentRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('exists')->once()->andReturn(true);
$repository->shouldReceive('getContent')->once()->andReturn('This is attachment number one.');
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@ -103,13 +113,14 @@ class AttachmentControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\AttachmentController
* @expectedExceptionMessage Could not find the indicated attachment
*/
public function testDownloadFail(): void
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AttachmentRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('exists')->once()->andReturn(false);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@ -125,6 +136,10 @@ class AttachmentControllerTest extends TestCase
{
$attachRepository = $this->mock(AttachmentRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$attachRepository->shouldReceive('getNoteText')->andReturn('OK');
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@ -140,6 +155,9 @@ class AttachmentControllerTest extends TestCase
public function testIndex()
{
$repository = $this->mock(AttachmentRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$repository->shouldReceive('get')->andReturn(new Collection([Attachment::first()]))->once();
$repository->shouldReceive('exists')->andReturn(true)->once();
@ -159,6 +177,8 @@ class AttachmentControllerTest extends TestCase
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AttachmentRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('update')->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@ -181,11 +201,14 @@ class AttachmentControllerTest extends TestCase
*/
public function testView(): void
{
$repository = $this->mock(AttachmentRepositoryInterface::class);
$repository = $this->mock(AttachmentRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository->shouldReceive('exists')->once()->andReturn(true);
$repository->shouldReceive('getContent')->once()->andReturn('This is attachment number one.');
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('attachments.view', [3]));
@ -198,10 +221,13 @@ class AttachmentControllerTest extends TestCase
*/
public function testViewFail(): void
{
$repository = $this->mock(AttachmentRepositoryInterface::class);
$repository = $this->mock(AttachmentRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository->shouldReceive('exists')->once()->andReturn(false);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('attachments.view', [1]));

View File

@ -37,7 +37,7 @@ class ForgotPasswordControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -39,7 +39,7 @@ class TwoFactorControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -89,7 +89,6 @@ class TwoFactorControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Auth\TwoFactorController
* @expectedExceptionMessage Your two factor authentication secret is empty
*/
public function testIndexNoSecret(): void
{

View File

@ -29,8 +29,10 @@ use FireflyIII\Models\Bill;
use FireflyIII\Models\Rule;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\TransactionRules\TransactionMatcher;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
@ -54,7 +56,7 @@ class BillControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
@ -67,6 +69,12 @@ class BillControllerTest extends TestCase
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@ -85,6 +93,11 @@ class BillControllerTest extends TestCase
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@ -104,6 +117,9 @@ class BillControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@ -123,6 +139,12 @@ class BillControllerTest extends TestCase
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$billRepos->shouldReceive('getNoteText')->andReturn('Hello');
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@ -144,6 +166,10 @@ class BillControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$collection = new Collection([$bill]);
$repository->shouldReceive('getPaginator')->andReturn(new LengthAwarePaginator($collection, 1, 50))->once();
@ -171,10 +197,14 @@ class BillControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('getRulesForBill')->andReturn(new Collection([$rule]));
//calls for transaction matcher:
// todo bad to do this:
$matcher = $this->mock(TransactionMatcher::class);
$matcher->shouldReceive('setLimit')->once()->withArgs([100000]);
$matcher->shouldReceive('setRange')->once()->withArgs([100000]);
@ -199,6 +229,9 @@ class BillControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@ -218,6 +251,10 @@ class BillControllerTest extends TestCase
$collector = $this->mock(TransactionCollectorInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$repository->shouldReceive('getYearAverage')->andReturn('0');
$repository->shouldReceive('getOverallAverage')->andReturn('0');
$repository->shouldReceive('nextExpectedMatch')->andReturn(new Carbon);
@ -255,6 +292,9 @@ class BillControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('store')->andReturn($bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
@ -289,7 +329,10 @@ class BillControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$bill = $this->user()->bills()->first();
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$bill = $this->user()->bills()->first();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('store')->andReturn($bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
@ -325,6 +368,9 @@ class BillControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('store')->andReturn(null);
@ -357,6 +403,9 @@ class BillControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('store')->andReturn(new Bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
@ -392,6 +441,9 @@ class BillControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('update')->andReturn(new Bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');

View File

@ -48,7 +48,7 @@ class AmountControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -28,7 +28,9 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
use Tests\TestCase;
/**
@ -43,7 +45,7 @@ class CreateControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
@ -56,6 +58,9 @@ class CreateControllerTest extends TestCase
// mock stuff
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@ -76,6 +81,8 @@ class CreateControllerTest extends TestCase
$budget = factory(Budget::class)->make();
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('findNull')->andReturn($budget);
$repository->shouldReceive('store')->andReturn($budget);

View File

@ -26,7 +26,9 @@ namespace Tests\Feature\Controllers\Budget;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
use Tests\TestCase;
/**
@ -41,7 +43,7 @@ class DeleteControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
@ -54,6 +56,9 @@ class DeleteControllerTest extends TestCase
// mock stuff
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@ -72,6 +77,8 @@ class DeleteControllerTest extends TestCase
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('destroy')->andReturn(true);

View File

@ -27,7 +27,9 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
use Tests\TestCase;
/**
@ -42,7 +44,7 @@ class EditControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
@ -55,6 +57,9 @@ class EditControllerTest extends TestCase
// mock stuff
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@ -75,6 +80,8 @@ class EditControllerTest extends TestCase
$budget = factory(Budget::class)->make();
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('findNull')->andReturn($budget);
$repository->shouldReceive('update');

View File

@ -30,8 +30,10 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Tests\TestCase;
/**
@ -46,7 +48,7 @@ class IndexControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -57,6 +59,8 @@ class IndexControllerTest extends TestCase
*/
public function testIndex(string $range): void
{
Log::debug(sprintf('Now in testIndex(%s)', $range));
// mock stuff
$budget = factory(Budget::class)->make();
@ -76,6 +80,9 @@ class IndexControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
@ -122,6 +129,9 @@ class IndexControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
@ -170,6 +180,9 @@ class IndexControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
@ -216,6 +229,8 @@ class IndexControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);

View File

@ -30,9 +30,11 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Tests\TestCase;
/**
@ -47,7 +49,7 @@ class ShowControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
@ -66,8 +68,10 @@ class ShowControllerTest extends TestCase
$repository = $this->mock(BudgetRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(null);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->andReturn(null);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('getTransactions')->andReturn(new Collection);
@ -102,8 +106,10 @@ class ShowControllerTest extends TestCase
$repository = $this->mock(BudgetRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->andReturn(null);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->andReturn(null);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
@ -139,6 +145,9 @@ class ShowControllerTest extends TestCase
$repository = $this->mock(BudgetRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->andReturn(null);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
@ -177,9 +186,15 @@ class ShowControllerTest extends TestCase
$budgetLimit = factory(BudgetLimit::class)->make();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
$collector = $this->mock(TransactionCollectorInterface::class);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
@ -188,10 +203,10 @@ class ShowControllerTest extends TestCase
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
$repository = $this->mock(BudgetRepositoryInterface::class);
$repository->shouldReceive('getBudgetLimits')->andReturn(new Collection([$budgetLimit]));
$repository->shouldReceive('spentInPeriod')->andReturn('-1');
@ -208,7 +223,6 @@ class ShowControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Budget\ShowController
* @expectedExceptionMessage This budget limit is not part of
*/
public function testShowByBadBudgetLimit(): void
{
@ -216,6 +230,8 @@ class ShowControllerTest extends TestCase
// mock stuff
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@ -233,20 +249,17 @@ class ShowControllerTest extends TestCase
{
Log::debug(sprintf('Now in testShowByBudgetLimit(%s)', $range));
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
// mock account repository
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$accountRepository->shouldReceive('getAccountsByType')->andReturn(new Collection);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
// mock budget repository
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepository->shouldReceive('getAccountsByType')->andReturn(new Collection);
$budgetRepository->shouldReceive('spentInPeriod')->andReturn('1');
$budgetRepository->shouldReceive('getBudgetLimits')->andReturn(new Collection);
// mock journal collector:
$collector = $this->mock(TransactionCollectorInterface::class);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();

View File

@ -31,9 +31,11 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Navigation;
use Tests\TestCase;
@ -49,7 +51,7 @@ class NoCategoryControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
@ -61,17 +63,18 @@ class NoCategoryControllerTest extends TestCase
*/
public function testNoCategory(string $range): void
{
Log::debug(sprintf('Test noCategory(%s)', $range));
// mock stuff
$collector = $this->mock(TransactionCollectorInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
// get the journal with the most recent date for firstNull:
$journal = $this->user()->transactionJournals()->orderBy('date', 'DESC')->first();
$journalRepos->shouldReceive('firstNull')->twice()->andReturn($journal);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setTypes')->andReturnSelf();
@ -108,7 +111,9 @@ class NoCategoryControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->twice()->andReturn(TransactionJournal::first());
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setTypes')->andReturnSelf();
@ -144,7 +149,10 @@ class NoCategoryControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->twice()->andReturn(TransactionJournal::first());
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setTypes')->andReturnSelf();

View File

@ -50,7 +50,7 @@ class ShowControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -47,7 +47,7 @@ class CategoryControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -52,7 +52,7 @@ class AccountControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -43,7 +43,7 @@ class BillControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -49,7 +49,7 @@ class BudgetControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -95,7 +95,6 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Chart\BudgetController
* @expectedExceptionMessage This budget limit is not part of this budget.
*/
public function testBudgetLimitWrongLimit(): void
{

View File

@ -48,7 +48,7 @@ class BudgetReportControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -45,7 +45,7 @@ class CategoryControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -45,7 +45,7 @@ class CategoryReportControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -42,7 +42,7 @@ class ExpenseReportControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -40,7 +40,7 @@ class PiggyBankControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -41,7 +41,7 @@ class ReportControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -49,7 +49,7 @@ class TagReportControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -48,7 +48,7 @@ class CurrencyControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -42,7 +42,7 @@ class DebugControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -49,7 +49,7 @@ class ExportControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -74,7 +74,6 @@ class ExportControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\ExportController
* @expectedExceptionMessage Against all expectations
*/
public function testDownloadFailed(): void
{

View File

@ -42,7 +42,7 @@ class HelpControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -51,7 +51,7 @@ class HomeControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -42,7 +42,7 @@ class CallbackControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -49,7 +49,7 @@ class IndexControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -43,7 +43,7 @@ class JobConfigurationControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -48,7 +48,7 @@ class JobStatusControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -45,7 +45,7 @@ class PrerequisitesControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -48,7 +48,7 @@ class JavascriptControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -55,7 +55,7 @@ class AutoCompleteControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -47,7 +47,7 @@ class BoxControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -43,7 +43,7 @@ class ExchangeControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -42,7 +42,7 @@ class FrontpageControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -40,7 +40,7 @@ class IntroControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -44,7 +44,7 @@ class ReconcileControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -74,7 +74,6 @@ class ReconcileControllerTest extends TestCase
* Test overview when it's not an asset.
*
* @covers \FireflyIII\Http\Controllers\Json\ReconcileController
* @expectedExceptionMessage is not an asset account
*/
public function testOverviewNotAsset(): void
{

View File

@ -42,7 +42,7 @@ class RecurrenceControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -42,7 +42,7 @@ class JsonControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -45,7 +45,7 @@ class NewUserControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -53,7 +53,7 @@ class PiggyBankControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -49,12 +49,11 @@ class ReportControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
* @expectedExceptionMessage Could not parse end date
*/
public function testBadEndDate(): void
{
@ -168,7 +167,6 @@ class ReportControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController
* @expectedExceptionMessage Firefly cannot handle this type of info-button
*/
public function testBalanceAmountTagRole(): void
{

View File

@ -46,7 +46,7 @@ class PreferencesControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -49,7 +49,7 @@ class ProfileControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@ -97,7 +97,6 @@ class ProfileControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\ProfileController
* @expectedExceptionMessage Invalid token
*/
public function testConfirmEmailChangeNoToken(): void
{
@ -541,7 +540,6 @@ class ProfileControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\ProfileController
* @expectedExceptionMessage Invalid token
*/
public function testUndoEmailChangeBadToken(): void
{

View File

@ -46,7 +46,7 @@ class CreateControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -40,7 +40,7 @@ class DeleteControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -43,7 +43,7 @@ class EditControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -41,7 +41,7 @@ class IndexControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -41,7 +41,7 @@ class AccountControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -42,7 +42,7 @@ class BalanceControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -43,7 +43,7 @@ class BudgetControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -43,7 +43,7 @@ class CategoryControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -45,7 +45,7 @@ class ExpenseControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -41,7 +41,7 @@ class OperationsControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -59,7 +59,7 @@ class ReportControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -43,7 +43,7 @@ class CreateControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -38,7 +38,7 @@ class DeleteControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -44,7 +44,7 @@ class EditControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -46,7 +46,7 @@ class IndexControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -49,7 +49,7 @@ class SelectControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -48,7 +48,7 @@ class RuleGroupControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -42,7 +42,7 @@ class SearchControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -45,7 +45,7 @@ class CronControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**

View File

@ -48,7 +48,7 @@ class TagControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

View File

@ -45,7 +45,7 @@ class BulkControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}

Some files were not shown because too many files have changed in this diff Show More