Improve test coverage.

This commit is contained in:
James Cole
2019-07-25 14:19:49 +02:00
parent ee95606ec0
commit 6ff4a0b45c
61 changed files with 822 additions and 599 deletions

View File

@@ -23,9 +23,7 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
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;
@@ -63,7 +61,7 @@ class AttachmentControllerTest extends TestCase
// mock stuff
$this->mock(AttachmentRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
@@ -122,8 +120,8 @@ class AttachmentControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$attachment = $this->getRandomAttachment();
$repository = $this->mock(AttachmentRepositoryInterface::class);
$attachment = $this->getRandomAttachment();
$repository = $this->mock(AttachmentRepositoryInterface::class);
$repository->shouldReceive('exists')->once()->andReturn(false);
@@ -207,7 +205,7 @@ class AttachmentControllerTest extends TestCase
$attachment = $this->getRandomAttachment();
$this->mockDefaultSession();
$repository = $this->mock(AttachmentRepositoryInterface::class);
$repository = $this->mock(AttachmentRepositoryInterface::class);
$repository->shouldReceive('exists')->once()->andReturn(true);
$repository->shouldReceive('getContent')->once()->andReturn('This is attachment number one.');

View File

@@ -160,10 +160,10 @@ class BillControllerTest extends TestCase
// mock stuff
$this->mock(AttachmentHelperInterface::class);
$bill = $this->getRandomBill();
$repository = $this->mock(BillRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$transformer = $this->mock(BillTransformer::class);
$bill = $this->getRandomBill();
$repository = $this->mock(BillRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$transformer = $this->mock(BillTransformer::class);
$pref = new Preference;
$pref->data = 50;
@@ -172,8 +172,8 @@ class BillControllerTest extends TestCase
$transformer->shouldReceive('setParameters')->atLeast()->once();
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
['id' => 5, 'active' => true, 'name' => 'x', 'next_expected_match' => '2018-01-01',
'currency' => $this->getEuro(),
['id' => 5, 'active' => true, 'name' => 'x', 'next_expected_match' => '2018-01-01',
'currency' => $this->getEuro(),
]
);
@@ -201,8 +201,8 @@ class BillControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$rule = $this->getRandomRule();
$repository = $this->mock(BillRepositoryInterface::class);
$rule = $this->getRandomRule();
$repository = $this->mock(BillRepositoryInterface::class);
$this->mock(AttachmentHelperInterface::class);
@@ -414,8 +414,8 @@ class BillControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('store')->andReturn(new Bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
@@ -450,8 +450,8 @@ class BillControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('update')->andReturn(new Bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');

View File

@@ -57,7 +57,7 @@ class DeleteControllerTest extends TestCase
// mock stuff
$this->mock(BudgetRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
@@ -77,7 +77,7 @@ class DeleteControllerTest extends TestCase
$budget = $this->getRandomBudget();
Log::debug('Now in testDestroy()');
// mock stuff
$repository = $this->mock(BudgetRepositoryInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);

View File

@@ -54,7 +54,7 @@ class EditControllerTest extends TestCase
Log::debug('Now in testEdit()');
// mock stuff
$this->mock(BudgetRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$this->mockDefaultSession();
@@ -74,7 +74,7 @@ class EditControllerTest extends TestCase
Log::debug('Now in testUpdate()');
// mock stuff
$budget = $this->getRandomBudget();
$repository = $this->mock(BudgetRepositoryInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('findNull')->andReturn($budget);

View File

@@ -65,7 +65,7 @@ class IndexControllerTest extends TestCase
public function testIndex(string $range): void
{
// mock stuff
$budget = $this->getRandomBudget();
$budget = $this->getRandomBudget();
$budgetLimit = $this->getRandomBudgetLimit();
$budgetLimit->start_date = Carbon::now()->startOfMonth();
$budgetLimit->end_date = Carbon::now()->endOfMonth();
@@ -102,7 +102,7 @@ class IndexControllerTest extends TestCase
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('budgets.index'));
$response = $this->get(route('budgets.index'));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');

View File

@@ -222,7 +222,7 @@ class ShowControllerTest extends TestCase
{
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);

View File

@@ -52,7 +52,7 @@ class CreateControllerTest extends TestCase
Log::debug('TestCreate()');
// mock stuff
$this->mock(CategoryRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->mockDefaultSession();
@@ -71,7 +71,7 @@ class CreateControllerTest extends TestCase
public function testStore(): void
{
Log::debug('Test store()');
$repository = $this->mock(CategoryRepositoryInterface::class);
$repository = $this->mock(CategoryRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$repository->shouldReceive('findNull')->andReturn(new Category);

View File

@@ -53,7 +53,7 @@ class DeleteControllerTest extends TestCase
// mock stuff
$this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);

View File

@@ -67,7 +67,6 @@ class EditControllerTest extends TestCase
}
/**
* @covers \FireflyIII\Http\Controllers\Category\EditController
* @covers \FireflyIII\Http\Requests\CategoryFormRequest
@@ -75,8 +74,8 @@ class EditControllerTest extends TestCase
public function testUpdate(): void
{
Log::debug('Test update()');
$category = Category::first();
$repository = $this->mock(CategoryRepositoryInterface::class);
$category = Category::first();
$repository = $this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();

View File

@@ -67,10 +67,10 @@ class NoCategoryControllerTest extends TestCase
*/
public function testNoCategory(string $range): void
{
$collector = $this->mock(GroupCollectorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
// list size
@@ -108,11 +108,11 @@ class NoCategoryControllerTest extends TestCase
*/
public function testNoCategoryAll(string $range): void
{
$collector = $this->mock(GroupCollectorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$this->mockDefaultSession();
// list size
@@ -150,12 +150,12 @@ class NoCategoryControllerTest extends TestCase
*/
public function testNoCategoryDate(string $range): void
{
$collector = $this->mock(GroupCollectorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$userRepos = $this->mock(UserRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);

View File

@@ -123,10 +123,10 @@ class ShowControllerTest extends TestCase
*/
public function testShowAll(string $range): void
{
$withdrawal = $this->getRandomWithdrawalAsArray();
$repository = $this->mock(CategoryRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$withdrawal = $this->getRandomWithdrawalAsArray();
$repository = $this->mock(CategoryRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$pref = new Preference;

View File

@@ -26,12 +26,9 @@ use Carbon\Carbon;
use Exception;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -118,14 +115,14 @@ class AccountControllerTest extends TestCase
*/
public function testExpenseBudget(string $range): void
{
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$withdrawal = $this->getRandomWithdrawalAsArray();
$budget = $this->user()->budgets()->find($withdrawal['budget_id']);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$withdrawal = $this->getRandomWithdrawalAsArray();
$budget = $this->user()->budgets()->find($withdrawal['budget_id']);
// mock default session
$this->mockDefaultSession();
@@ -158,14 +155,14 @@ class AccountControllerTest extends TestCase
*/
public function testExpenseBudgetAll(string $range): void
{
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(FiscalHelperInterface::class);
$withdrawal = $this->getRandomWithdrawalAsArray();
$budget = $this->user()->budgets()->find($withdrawal['budget_id']);
$withdrawal = $this->getRandomWithdrawalAsArray();
$budget = $this->user()->budgets()->find($withdrawal['budget_id']);
// mock default session
$this->mockDefaultSession();
@@ -202,9 +199,9 @@ class AccountControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$withdrawal = $this->getRandomWithdrawalAsArray();
$category = $this->user()->categories()->find($withdrawal['category_id']);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$withdrawal = $this->getRandomWithdrawalAsArray();
$category = $this->user()->categories()->find($withdrawal['category_id']);
// mock default session
$this->mockDefaultSession();
@@ -245,8 +242,8 @@ class AccountControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
$withdrawal = $this->getRandomWithdrawalAsArray();
$category = $this->user()->categories()->find($withdrawal['category_id']);
$withdrawal = $this->getRandomWithdrawalAsArray();
$category = $this->user()->categories()->find($withdrawal['category_id']);
// mock default session
$this->mockDefaultSession();
@@ -404,7 +401,7 @@ class AccountControllerTest extends TestCase
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
$date = new Carbon;
$date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
$accountRepos->shouldReceive('oldestJournalDate')->andReturn(new Carbon);
@@ -433,7 +430,7 @@ class AccountControllerTest extends TestCase
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
$date = new Carbon;
$date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();

View File

@@ -27,9 +27,7 @@ use Exception;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
@@ -309,8 +307,8 @@ class BudgetControllerTest extends TestCase
public function testFrontpageNoLimits(string $range): void
{
$repository = $this->mock(BudgetRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$budget = $this->getRandomBudget();
@@ -341,11 +339,11 @@ class BudgetControllerTest extends TestCase
*/
public function testPeriod(): void
{
$repository = $this->mock(BudgetRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
$budgetLimit = $this->getRandomBudgetLimit();
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$repository = $this->mock(BudgetRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
$budgetLimit = $this->getRandomBudgetLimit();
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
// mock default session
$this->mockDefaultSession();

View File

@@ -26,10 +26,6 @@ use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\TransactionType;
@@ -39,6 +35,7 @@ use Log;
use Preferences;
use Tests\TestCase;
/**
* Class BudgetReportControllerTest
*/
@@ -134,7 +131,7 @@ class BudgetReportControllerTest extends TestCase
$limit3->budget_id = $budget->id;
$limit3->start_date = new Carbon('2012-01-01');
$limit3->end_date = new Carbon('2012-01-31');
$limit3->amount = '100';
$limit3->amount = '100';
$limit3->save();

View File

@@ -26,18 +26,13 @@ use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use Log;
use Preferences;
use Tests\TestCase;
/**
* Class CategoryReportControllerTest
*/
@@ -173,7 +168,7 @@ class CategoryReportControllerTest extends TestCase
$collector = $this->mock(GroupCollectorInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$withdrawal = $this->getRandomWithdrawalAsArray();
$withdrawal = $this->getRandomWithdrawalAsArray();
$this->mockDefaultSession();
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');

View File

@@ -58,7 +58,7 @@ class ExpenseReportControllerTest extends TestCase
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$expense = $this->getRandomExpense();
$date = new Carbon;
$withdrawal = $this->getRandomWithdrawalAsArray();
$withdrawal = $this->getRandomWithdrawalAsArray();
$accountRepository->shouldReceive('findByName')->once()->andReturn($expense);

View File

@@ -52,7 +52,7 @@ class PiggyBankControllerTest extends TestCase
$generator = $this->mock(GeneratorInterface::class);
$repository = $this->mock(PiggyBankRepositoryInterface::class);
/** @var PiggyBankEvent $event */
$event = PiggyBankEvent::inRandomOrder()->first();
$event = PiggyBankEvent::inRandomOrder()->first();
$piggy = $event->piggy_bank_id;
$this->mockDefaultSession();

View File

@@ -194,9 +194,9 @@ class TagReportControllerTest extends TestCase
public function testMainChart(): void
{
$this->mock(AccountRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$withdrawal = $this->getRandomWithdrawalAsArray();
@@ -234,11 +234,11 @@ class TagReportControllerTest extends TestCase
public function testTagExpense(): void
{
$this->mockDefaultSession();
$generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$tag = $this->user()->tags()->first();
$tag = $this->user()->tags()->first();
$tagRepos->shouldReceive('setUser');
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));

View File

@@ -24,9 +24,7 @@ namespace Tests\Feature\Controllers;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
@@ -169,9 +167,9 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$euro = $this->getEuro();
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$euro = $this->getEuro();
$repository->shouldReceive('currencyInUse')->andReturn(false);
@@ -192,9 +190,9 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$euro = $this->getEuro();
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$euro = $this->getEuro();
$repository->shouldReceive('currencyInUse')->andReturn(false);
$repository->shouldReceive('destroy')->andReturn(true)->once();
@@ -350,8 +348,8 @@ class CurrencyControllerTest extends TestCase
$this->mockIntroPreference('shown_demo_currencies_index');
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$currencies = TransactionCurrency::get();
@@ -385,8 +383,8 @@ class CurrencyControllerTest extends TestCase
$this->mockIntroPreference('shown_demo_currencies_index');
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('getCurrencyByPreference')->andReturn(new TransactionCurrency);
@@ -418,8 +416,8 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
@@ -447,8 +445,8 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('store')->andReturnNull();
@@ -476,8 +474,8 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
@@ -505,8 +503,8 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(CurrencyRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('update')->andReturn(new TransactionCurrency);

View File

@@ -22,8 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
@@ -55,7 +53,7 @@ class DebugControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
$this->be($this->user());
@@ -71,7 +69,7 @@ class DebugControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
Preferences::shouldReceive('mark')->atLeast()->once();
@@ -115,7 +113,7 @@ class DebugControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);

View File

@@ -29,9 +29,9 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\MessageBag;
use Log;
use Mockery;
use Preferences;
use Tests\TestCase;
use Preferences;
/**
* Class AccountControllerTest
*
@@ -56,8 +56,8 @@ class PrerequisitesControllerTest extends TestCase
public function testIndex(): void
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
$job = new ImportJob;
@@ -69,10 +69,9 @@ class PrerequisitesControllerTest extends TestCase
$job->file_type = '';
$job->save();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
@@ -97,7 +96,7 @@ class PrerequisitesControllerTest extends TestCase
public function testIndexBadState(): void
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mock(ImportJobRepositoryInterface::class);
@@ -110,10 +109,10 @@ class PrerequisitesControllerTest extends TestCase
$job->file_type = '';
$job->save();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'fake_api_key',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'fake_api_key', null])->andReturnNull();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
@@ -134,9 +133,9 @@ class PrerequisitesControllerTest extends TestCase
$prereq = $this->mock(FakePrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$job = new ImportJob;
$job->user_id = $this->user()->id;
@@ -171,9 +170,9 @@ class PrerequisitesControllerTest extends TestCase
$prereq = $this->mock(FakePrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
//Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'fake_api_key',null])->andReturnNull();
@@ -206,13 +205,13 @@ class PrerequisitesControllerTest extends TestCase
public function testPostBadState(): void
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$job = new ImportJob;
$job->user_id = $this->user()->id;
@@ -242,13 +241,13 @@ class PrerequisitesControllerTest extends TestCase
public function testPostNoJob(): void
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
@@ -272,13 +271,13 @@ class PrerequisitesControllerTest extends TestCase
public function testPostWithMessages(): void
{
$this->mockDefaultSession();
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
//Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'fake_api_key',null])->andReturnNull();
$job = new ImportJob;

View File

@@ -62,8 +62,8 @@ class JavascriptControllerTest extends TestCase
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$account = $this->getRandomAsset();
$euro = $this->getEuro();
$pref = new Preference;
$pref->data = 'EUR';
$pref = new Preference;
$pref->data = 'EUR';
Preferences::shouldReceive('get')->withArgs(['currencyPreference', 'EUR'])->atLeast()->once()->andReturn($pref);

View File

@@ -111,7 +111,8 @@ class BoxControllerTest extends TestCase
* @covers \FireflyIII\Http\Controllers\Json\BoxController
*/
public function testBalance(): void
{ $this->mockDefaultSession();
{
$this->mockDefaultSession();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
@@ -138,11 +139,11 @@ class BoxControllerTest extends TestCase
*/
public function testBalanceTransactions(): void
{
$withdrawal = $this->getRandomWithdrawalAsArray();
$withdrawal = $this->getRandomWithdrawalAsArray();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$euro =$this->getEuro();
$euro = $this->getEuro();
$this->mockDefaultSession();
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');

View File

@@ -24,7 +24,6 @@ namespace Tests\Feature\Controllers\Json;
use Carbon\Carbon;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\CurrencyExchangeRate;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Services\Currency\ExchangeRateInterface;
use Log;
@@ -58,7 +57,7 @@ class ExchangeControllerTest extends TestCase
$this->mockDefaultSession();
$date = new Carbon;
$date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
$rate = $this->getRandomCer();
@@ -77,7 +76,7 @@ class ExchangeControllerTest extends TestCase
$this->mockDefaultSession();
$repository = $this->mock(CurrencyRepositoryInterface::class);
$rate = $this->getRandomCer();
$rate = $this->getRandomCer();
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);

View File

@@ -23,8 +23,8 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Json;
use Log;
use Tests\TestCase;
use Preferences;
use Tests\TestCase;
/**
* Class IntroControllerTest

View File

@@ -27,14 +27,10 @@ namespace Tests\Feature\Controllers\Json;
use Amount;
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Preferences;
@@ -110,13 +106,13 @@ class ReconcileControllerTest extends TestCase
$this->mock(RecurringRepositoryInterface::class);
$this->mockDefaultSession();
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$date = new Carbon;
$euro =$this->getEuro();
$withdrawal = $this->getRandomWithdrawalAsArray();
$repository = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$date = new Carbon;
$euro = $this->getEuro();
$withdrawal = $this->getRandomWithdrawalAsArray();
$accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);

View File

@@ -22,8 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
use Tests\TestCase;

View File

@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;

View File

@@ -425,7 +425,7 @@ class PiggyBankControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class);
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
$repetition = PiggyBankRepetition::first();
$piggyBank = $this->getRandomPiggyBank();
$piggyBank = $this->getRandomPiggyBank();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
@@ -449,8 +449,8 @@ class PiggyBankControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$piggyBank = $this->getRandomPiggyBank();
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$piggyBank = $this->getRandomPiggyBank();
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
@@ -471,12 +471,12 @@ class PiggyBankControllerTest extends TestCase
$this->mockDefaultSession();
$this->mockIntroPreference('shown_demo_piggy-banks_show');
// mock stuff
$first = $this->user()->transactionJournals()->inRandomOrder()->first();
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$transformer = $this->mock(PiggyBankTransformer::class);
$piggyBank = $this->getRandomPiggyBank();
$first = $this->user()->transactionJournals()->inRandomOrder()->first();
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$transformer = $this->mock(PiggyBankTransformer::class);
$piggyBank = $this->getRandomPiggyBank();
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
@@ -506,7 +506,7 @@ class PiggyBankControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
@@ -535,8 +535,8 @@ class PiggyBankControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$piggyBank = $this->getRandomPiggyBank();
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$piggyBank = $this->getRandomPiggyBank();
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);

View File

@@ -25,13 +25,10 @@ namespace Tests\Feature\Controllers\Popup;
use Amount;
use Carbon\Carbon;
use FireflyIII\Helpers\Report\PopupReportInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Tests\TestCase;
@@ -192,8 +189,8 @@ class ReportControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$popupReport = $this->mock(PopupReportInterface::class);
$account = $this->getRandomAsset();
$budget = $this->getRandomBudget();
$account = $this->getRandomAsset();
$budget = $this->getRandomBudget();
$this->mockDefaultSession();
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
@@ -227,7 +224,7 @@ class ReportControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$budget = $this->getRandomBudget();
$budget = $this->getRandomBudget();
$this->mockDefaultSession();
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
@@ -259,7 +256,7 @@ class ReportControllerTest extends TestCase
$this->mock(AccountRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$category = $this->getRandomCategory();
$category = $this->getRandomCategory();
$this->mockDefaultSession();
$categoryRepos->shouldReceive('findNull')->andReturn($category)->once()->withArgs([1]);
@@ -292,7 +289,7 @@ class ReportControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$account = $this->getRandomAsset();
$account = $this->getRandomAsset();
$this->mockDefaultSession();
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
@@ -325,7 +322,7 @@ class ReportControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$account = $this->getRandomAsset();
$account = $this->getRandomAsset();
$this->mockDefaultSession();
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();

View File

@@ -24,9 +24,7 @@ namespace Tests\Feature\Controllers;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
@@ -104,7 +102,7 @@ class PreferencesControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->andReturn(false);

View File

@@ -24,8 +24,6 @@ namespace Tests\Feature\Controllers;
use Amount;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Google2FA;
@@ -33,6 +31,7 @@ use Illuminate\Support\Collection;
use Log;
use Mockery;
use Preferences;
use stdClass;
use Tests\TestCase;
/**
@@ -133,7 +132,7 @@ class ProfileControllerTest extends TestCase
$repository->shouldReceive('unblockUser');
$preference = new Preference;
$preference->data = 'existing-token';
/** @var \stdClass $preference */
/** @var stdClass $preference */
$preference->user = $this->user();
Preferences::shouldReceive('findByName')->withArgs(['email_change_confirm_token'])->andReturn(new Collection([$preference]));
// email_change_confirm_token
@@ -205,8 +204,8 @@ class ProfileControllerTest extends TestCase
{
//$this->mockDefaultSession(); // DISABLED ON PURPOSE
$this->mockDefaultConfiguration();
$repository = $this->mock(UserRepositoryInterface::class);
$euro = $this->getEuro();
$repository = $this->mock(UserRepositoryInterface::class);
$euro = $this->getEuro();
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->times(1)->andReturn(false);
@@ -534,12 +533,12 @@ class ProfileControllerTest extends TestCase
$hash = hash('sha256', 'previous@example.com');
$tokenPreference = new Preference;
$tokenPreference->data = 'token';
/** @var \stdClass $tokenPreference */
/** @var stdClass $tokenPreference */
$tokenPreference->user = $this->user();
$hashPreference = new Preference;
$hashPreference->data = 'previous@example.com';
/** @var \stdClass $hashPreference */
/** @var stdClass $hashPreference */
$hashPreference->user = $this->user();
Preferences::shouldReceive('findByName')->once()->andReturn(new Collection([$tokenPreference]));
@@ -567,12 +566,12 @@ class ProfileControllerTest extends TestCase
$hash = hash('sha256', 'previous@example.comX');
$tokenPreference = new Preference;
$tokenPreference->data = 'token';
/** @var \stdClass $tokenPreference */
/** @var stdClass $tokenPreference */
$tokenPreference->user = $this->user();
$hashPreference = new Preference;
$hashPreference->data = 'previous@example.com';
/** @var \stdClass $hashPreference */
/** @var stdClass $hashPreference */
$hashPreference->user = $this->user();
Preferences::shouldReceive('findByName')->once()->andReturn(new Collection([$tokenPreference]));

View File

@@ -29,7 +29,6 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Recurring;
use FireflyConfig;
use FireflyIII\Factory\CategoryFactory;
use FireflyIII\Models\Configuration;
use FireflyIII\Models\Preference;
@@ -91,7 +92,7 @@ class IndexControllerTest extends TestCase
$collection = $this->user()->recurrences()->take(2)->get();
// mock cron job config:
\FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->once()->andReturn($config);
FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->once()->andReturn($config);
$repository->shouldReceive('get')->andReturn($collection)->once();
@@ -125,9 +126,9 @@ class IndexControllerTest extends TestCase
'recurrence_repetitions' => [
[
'occurrences' => [
'2019-01-01'
]
]
'2019-01-01',
],
],
],
]
);

View File

@@ -295,7 +295,7 @@ class ReportControllerTest extends TestCase
$this->mockDefaultSession();
$this->mock(BudgetRepositoryInterface::class);
$this->mock(ReportHelperInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$account = new Account();
$account->name = 'Something';
@@ -338,7 +338,7 @@ class ReportControllerTest extends TestCase
{
Log::debug(sprintf('Now in test %s', __METHOD__));
$this->mockDefaultSession();
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$this->mock(BudgetRepositoryInterface::class);
$this->mock(ReportHelperInterface::class);
$category = $this->getRandomCategory();
@@ -383,8 +383,8 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$asset = $this->getRandomAsset();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$asset = $this->getRandomAsset();
// find the user's asset account
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($asset)->atLeast()->once();
@@ -414,7 +414,7 @@ class ReportControllerTest extends TestCase
{
Log::debug(sprintf('Now in test %s', __METHOD__));
$this->mockDefaultSession();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$this->mock(BudgetRepositoryInterface::class);
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
@@ -446,7 +446,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
$data = [
@@ -472,7 +472,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
$data = [
@@ -530,7 +530,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -558,8 +558,8 @@ class ReportControllerTest extends TestCase
$this->mock(BudgetRepositoryInterface::class);
$this->mock(ReportHelperInterface::class);
$this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$categoryRepos->shouldReceive('findNull')->andReturn($this->user()->categories()->find(1))->twice();
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -588,7 +588,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -615,7 +615,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -642,7 +642,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -672,8 +672,8 @@ class ReportControllerTest extends TestCase
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
Log::debug(sprintf('Now in test %s', __METHOD__));
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
/** @var Tag $tag */
$tag = $this->user()->tags()->find(1);
@@ -710,8 +710,8 @@ class ReportControllerTest extends TestCase
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
Log::debug(sprintf('Now in test %s', __METHOD__));
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
$tag2 = $this->user()->tags()->find(3);

View File

@@ -25,9 +25,7 @@ namespace tests\Feature\Controllers\Rule;
use FireflyIII\Models\Rule;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;

View File

@@ -24,8 +24,6 @@ declare(strict_types=1);
namespace tests\Feature\Controllers\Rule;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
@@ -55,15 +53,14 @@ class DeleteControllerTest extends TestCase
public function testDelete(): void
{
// mock stuff
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
$response = $this->get(route('rules.delete', [1]));
$response->assertStatus(200);
@@ -76,7 +73,7 @@ class DeleteControllerTest extends TestCase
public function testDestroy(): void
{
// mock stuff
$repository = $this->mock(RuleRepositoryInterface::class);
$repository = $this->mock(RuleRepositoryInterface::class);
$repository->shouldReceive('destroy');
$this->mockDefaultSession();

View File

@@ -25,8 +25,6 @@ namespace tests\Feature\Controllers\Rule;
use FireflyIII\Models\Rule;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
@@ -56,9 +54,9 @@ class EditControllerTest extends TestCase
public function testEdit(): void
{
// mock stuff
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$repository = $this->mock(RuleRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$repository = $this->mock(RuleRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
@@ -88,9 +86,9 @@ class EditControllerTest extends TestCase
$this->session(['_old_input' => $old]);
// mock stuff
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$repository = $this->mock(RuleRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$repository = $this->mock(RuleRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->mockDefaultSession();
@@ -111,8 +109,8 @@ class EditControllerTest extends TestCase
public function testUpdate(): void
{
// mock stuff
$repository = $this->mock(RuleRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(RuleRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();

View File

@@ -23,8 +23,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;

View File

@@ -26,10 +26,7 @@ namespace tests\Feature\Controllers\Rule;
use Carbon\Carbon;
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
use FireflyIII\Jobs\Job;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\TransactionRules\TransactionMatcher;
@@ -82,7 +79,7 @@ class SelectControllerTest extends TestCase
Queue::assertPushed(
ExecuteRuleOnExistingTransactions::class, function (Job $job) {
return 1=== $job->getRule()->id;
return 1 === $job->getRule()->id;
}
);
}
@@ -193,7 +190,6 @@ class SelectControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$matcher->shouldReceive('setStrict')->once()->withArgs([false]);
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();

View File

@@ -52,7 +52,7 @@ class CreateControllerTest extends TestCase
{
$this->mockDefaultSession();
$this->mock(RuleGroupRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -69,7 +69,7 @@ class CreateControllerTest extends TestCase
public function testStore(): void
{
$this->mockDefaultSession();
$repository = $this->mock(RuleGroupRepositoryInterface::class);
$repository = $this->mock(RuleGroupRepositoryInterface::class);
Preferences::shouldReceive('mark')->atLeast()->once();

View File

@@ -24,9 +24,7 @@ namespace Tests\Feature\Controllers\RuleGroup;
use Carbon\Carbon;
use FireflyIII\Jobs\ExecuteRuleGroupOnExistingTransactions;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;

View File

@@ -75,7 +75,7 @@ class SearchControllerTest extends TestCase
public function testSearch(): void
{
$this->mockDefaultSession();
$search = $this->mock(SearchInterface::class);
$search = $this->mock(SearchInterface::class);
$search->shouldReceive('parseQuery')->once();
$search->shouldReceive('setLimit')->withArgs([50])->once();

View File

@@ -30,6 +30,7 @@ use FireflyIII\Support\Cronjobs\RecurringCronjob;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Preferences;
use Tests\TestCase;
/**
@@ -61,7 +62,7 @@ class CronControllerTest extends TestCase
$job->shouldReceive('fire')->once()->andReturn(true);
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('all')->andReturn($users);
\Preferences::shouldReceive('getForUser')
Preferences::shouldReceive('getForUser')
->withArgs([Mockery::any(), 'access_token', null])
->andReturn($preference)->once();
$response = $this->get(route('cron.cron', ['token']));
@@ -83,7 +84,7 @@ class CronControllerTest extends TestCase
$job->shouldReceive('fire')->once()->andThrow(new FireflyException('Exception noted.'));
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('all')->andReturn($users);
\Preferences::shouldReceive('getForUser')
Preferences::shouldReceive('getForUser')
->withArgs([Mockery::any(), 'access_token', null])
->andReturn($preference)->once();
$response = $this->get(route('cron.cron', ['token']));
@@ -105,7 +106,7 @@ class CronControllerTest extends TestCase
$job->shouldReceive('fire')->once()->andReturn(false);
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('all')->andReturn($users);
\Preferences::shouldReceive('getForUser')
Preferences::shouldReceive('getForUser')
->withArgs([Mockery::any(), 'access_token', null])
->andReturn($preference)->once();
$response = $this->get(route('cron.cron', ['token']));

View File

@@ -29,11 +29,9 @@ use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Preferences;
@@ -65,8 +63,8 @@ class TagControllerTest extends TestCase
{
$this->mockDefaultSession();
$this->mock(TagRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -82,9 +80,9 @@ class TagControllerTest extends TestCase
{
$this->mockDefaultSession();
$this->mock(TagRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -99,7 +97,7 @@ class TagControllerTest extends TestCase
public function testDestroy(): void
{
$this->mockDefaultSession();
$repository = $this->mock(TagRepositoryInterface::class);
$repository = $this->mock(TagRepositoryInterface::class);
$repository->shouldReceive('destroy');
Preferences::shouldReceive('mark')->atLeast()->once();
@@ -117,8 +115,8 @@ class TagControllerTest extends TestCase
{
$this->mockDefaultSession();
$this->mock(TagRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -133,11 +131,11 @@ class TagControllerTest extends TestCase
public function testIndex(): void
{
$this->mockDefaultSession();
$repository = $this->mock(TagRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(TagRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$repository->shouldReceive('count')->andReturn(0);
$repository->shouldReceive('tagCloud')->andReturn([]);
$repository->shouldReceive('oldestTag')->andReturn(null)->once();
@@ -315,7 +313,7 @@ class TagControllerTest extends TestCase
public function testStore(): void
{
$this->mockDefaultSession();
$repository = $this->mock(TagRepositoryInterface::class);
$repository = $this->mock(TagRepositoryInterface::class);
Preferences::shouldReceive('mark')->atLeast()->once();
$repository->shouldReceive('findNull')->andReturn(null);
@@ -341,8 +339,8 @@ class TagControllerTest extends TestCase
public function testUpdate(): void
{
$this->mockDefaultSession();
$repository = $this->mock(TagRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(TagRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
Preferences::shouldReceive('mark')->atLeast()->once();

View File

@@ -24,10 +24,8 @@ namespace Tests\Feature\Controllers\Transaction;
use Amount;
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\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
@@ -193,8 +191,6 @@ class ConvertControllerTest extends TestCase
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
$data = ['source_account_id' => 1];
$this->be($this->user());
$response = $this->post(route('transactions.convert.index.post', ['transfer', $deposit->id]), $data);

View File

@@ -26,9 +26,9 @@ use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
use Preferences;
use Tests\TestCase;
use Mockery;
/**
* Class CreateControllerTest
@@ -56,7 +56,7 @@ class CreateControllerTest extends TestCase
$empty = new Preference;
$empty->data = [];
$userRepos->shouldReceive('hasRole')->atLeast()->once()->withArgs([Mockery::any(),'owner'])->andReturn(true);
$userRepos->shouldReceive('hasRole')->atLeast()->once()->withArgs([Mockery::any(), 'owner'])->andReturn(true);
$accountRepos->shouldReceive('getCashAccount')->atLeast()->once()->andReturn($cash);
Preferences::shouldReceive('get')->withArgs(['transaction_journal_optional_fields', []])->atLeast()->once()->andReturn($empty);

View File

@@ -53,9 +53,9 @@ class IndexControllerTest extends TestCase
public function testIndex(): void
{
$this->mockDefaultSession();
$group = $this->getRandomWithdrawalGroup();
$userRepos = $this->mock(UserRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$group = $this->getRandomWithdrawalGroup();
$userRepos = $this->mock(UserRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
// generic set for the info blocks:
$groupArray = [$this->getRandomWithdrawalAsArray()];
@@ -95,9 +95,9 @@ class IndexControllerTest extends TestCase
public function testIndexAll(): void
{
$this->mockDefaultSession();
$group = $this->getRandomWithdrawalGroup();
$userRepos = $this->mock(UserRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$group = $this->getRandomWithdrawalGroup();
$userRepos = $this->mock(UserRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
// role?
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);

View File

@@ -25,7 +25,6 @@ namespace Tests\Feature\Controllers\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
@@ -60,8 +59,6 @@ class LinkControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -80,7 +77,6 @@ class LinkControllerTest extends TestCase
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
$linkRepos->shouldReceive('get')->atLeast()->once()->andReturn(new Collection);
$this->be($this->user());
@@ -94,8 +90,8 @@ class LinkControllerTest extends TestCase
public function testDestroy(): void
{
$this->mockDefaultSession();
$link = $this->getRandomLink();
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$link = $this->getRandomLink();
$repository = $this->mock(LinkTypeRepositoryInterface::class);
Preferences::shouldReceive('mark')->once();
@@ -203,7 +199,7 @@ class LinkControllerTest extends TestCase
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$journalRepos = $this->mockDefaultSession();
$data = [
$data = [
'link_other' => $withdrawal->id,
'link_type' => '1_inward',
];
@@ -224,8 +220,8 @@ class LinkControllerTest extends TestCase
public function testSwitchLink(): void
{
$this->mockDefaultSession();
$link = $this->getRandomLink();
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$link = $this->getRandomLink();
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);

View File

@@ -172,13 +172,13 @@ class MassControllerTest extends TestCase
$this->session(['transactions.mass-edit.uri' => 'http://localhost']);
$data = [
'journals' => [$deposit->id],
'description' => [$deposit->id => 'Updated salary thing'],
'amount' => [$deposit->id => 1600],
'date' => [$deposit->id => '2014-07-24'],
'source_name' => [$deposit->id => 'Job'],
'destination_id' => [$deposit->id => 1],
'category' => [$deposit->id => 'Salary'],
'journals' => [$deposit->id],
'description' => [$deposit->id => 'Updated salary thing'],
'amount' => [$deposit->id => 1600],
'date' => [$deposit->id => '2014-07-24'],
'source_name' => [$deposit->id => 'Job'],
'destination_id' => [$deposit->id => 1],
'category' => [$deposit->id => 'Salary'],
];
$this->be($this->user());