mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Update tests so repositories are not called. Saves on DB calls, speeds up tests.
This commit is contained in:
@@ -27,6 +27,7 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
|||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -57,6 +58,7 @@ class AttachmentControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
$repository->shouldReceive('destroy')->once()->andReturn(true);
|
$repository->shouldReceive('destroy')->once()->andReturn(true);
|
||||||
@@ -78,6 +80,8 @@ class AttachmentControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
$content = 'Attachment content ' . random_int(100, 1000);
|
$content = 'Attachment content ' . random_int(100, 1000);
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -104,6 +108,8 @@ class AttachmentControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
$content = 'Attachment content ' . random_int(100, 1000);
|
$content = 'Attachment content ' . random_int(100, 1000);
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -128,6 +134,8 @@ class AttachmentControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
@@ -165,6 +173,8 @@ class AttachmentControllerTest extends TestCase
|
|||||||
|
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -191,6 +201,8 @@ class AttachmentControllerTest extends TestCase
|
|||||||
|
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -218,6 +230,8 @@ class AttachmentControllerTest extends TestCase
|
|||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -253,6 +267,8 @@ class AttachmentControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock repositories
|
// mock repositories
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
/** @var Attachment $attachment */
|
/** @var Attachment $attachment */
|
||||||
$attachment = $this->user()->attachments()->first();
|
$attachment = $this->user()->attachments()->first();
|
||||||
@@ -286,6 +302,11 @@ class AttachmentControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpload(): void
|
public function testUpload(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$repository->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
|
|
||||||
/** @var Attachment $attachment */
|
/** @var Attachment $attachment */
|
||||||
$attachment = $this->user()->attachments()->first();
|
$attachment = $this->user()->attachments()->first();
|
||||||
$content = 'Hello there';
|
$content = 'Hello there';
|
||||||
|
@@ -25,8 +25,10 @@ namespace Tests\Api\V1\Controllers;
|
|||||||
|
|
||||||
use FireflyConfig;
|
use FireflyConfig;
|
||||||
use FireflyIII\Models\Configuration;
|
use FireflyIII\Models\Configuration;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,6 +54,9 @@ class ConfigurationControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIndex(): void
|
public function testIndex(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
$demoConfig = new Configuration;
|
$demoConfig = new Configuration;
|
||||||
$demoConfig->name = 'is_demo_site';
|
$demoConfig->name = 'is_demo_site';
|
||||||
$demoConfig->data = false;
|
$demoConfig->data = false;
|
||||||
@@ -96,6 +101,9 @@ class ConfigurationControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIndexNotOwner(): void
|
public function testIndexNotOwner(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
Passport::actingAs($this->emptyUser());
|
Passport::actingAs($this->emptyUser());
|
||||||
$response = $this->get('/api/v1/configuration');
|
$response = $this->get('/api/v1/configuration');
|
||||||
$response->assertStatus(500);
|
$response->assertStatus(500);
|
||||||
@@ -109,7 +117,9 @@ class ConfigurationControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdate(): void
|
public function testUpdate(): void
|
||||||
{
|
{
|
||||||
$data = [
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
$data = [
|
||||||
'name' => 'permission_update_check',
|
'name' => 'permission_update_check',
|
||||||
'value' => 1,
|
'value' => 1,
|
||||||
|
|
||||||
@@ -159,6 +169,9 @@ class ConfigurationControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdateBoolean(): void
|
public function testUpdateBoolean(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'single_user_mode',
|
'name' => 'single_user_mode',
|
||||||
'value' => 'true',
|
'value' => 'true',
|
||||||
@@ -209,6 +222,8 @@ class ConfigurationControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdateInvalid(): void
|
public function testUpdateInvalid(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'last_update_check',
|
'name' => 'last_update_check',
|
||||||
'value' => 'true',
|
'value' => 'true',
|
||||||
@@ -225,6 +240,9 @@ class ConfigurationControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdateNotOwner(): void
|
public function testUpdateNotOwner(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
Passport::actingAs($this->emptyUser());
|
Passport::actingAs($this->emptyUser());
|
||||||
$response = $this->post('/api/v1/configuration');
|
$response = $this->post('/api/v1/configuration');
|
||||||
$response->assertStatus(500);
|
$response->assertStatus(500);
|
||||||
|
@@ -87,6 +87,7 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$collection = TransactionCurrency::get();
|
$collection = TransactionCurrency::get();
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -125,6 +126,7 @@ class CurrencyControllerTest extends TestCase
|
|||||||
// create stuff
|
// create stuff
|
||||||
$currency = TransactionCurrency::first();
|
$currency = TransactionCurrency::first();
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -152,6 +154,7 @@ class CurrencyControllerTest extends TestCase
|
|||||||
|
|
||||||
$currency = TransactionCurrency::first();
|
$currency = TransactionCurrency::first();
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -182,8 +185,10 @@ class CurrencyControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testStoreWithDefault(): void
|
public function testStoreWithDefault(): void
|
||||||
{
|
{
|
||||||
$currency = TransactionCurrency::first();
|
$currency = TransactionCurrency::first();
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$preference = new Preference;
|
$preference = new Preference;
|
||||||
$preference->data = 'EUR';
|
$preference->data = 'EUR';
|
||||||
// mock calls:
|
// mock calls:
|
||||||
@@ -221,6 +226,7 @@ class CurrencyControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$currency = TransactionCurrency::first();
|
$currency = TransactionCurrency::first();
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -253,6 +259,7 @@ class CurrencyControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$currency = TransactionCurrency::first();
|
$currency = TransactionCurrency::first();
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$preference = new Preference;
|
$preference = new Preference;
|
||||||
$preference->data = 'EUR';
|
$preference->data = 'EUR';
|
||||||
|
|
||||||
|
@@ -29,12 +29,17 @@ use FireflyIII\Models\AccountType;
|
|||||||
use FireflyIII\Models\Recurrence;
|
use FireflyIII\Models\Recurrence;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Class RecurrenceControllerTest
|
||||||
|
*/
|
||||||
class RecurrenceControllerTest extends TestCase
|
class RecurrenceControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +59,9 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
public function testDelete(): void
|
public function testDelete(): void
|
||||||
{
|
{
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||||
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -77,7 +84,15 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$recurrences = $this->user()->recurrences()->get();
|
$recurrences = $this->user()->recurrences()->get();
|
||||||
|
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||||
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
|
$budgetRepos->shouldReceive('findNull')->atLeast()->once()->withAnyArgs()
|
||||||
|
->andReturn($this->user()->budgets()->first());
|
||||||
|
|
||||||
|
$piggyRepos->shouldReceive('findNull')->atLeast()->once()->withAnyArgs()
|
||||||
|
->andReturn($this->user()->piggyBanks()->first());
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser');
|
$repository->shouldReceive('setUser');
|
||||||
@@ -103,7 +118,12 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$recurrence = $this->user()->recurrences()->first();
|
$recurrence = $this->user()->recurrences()->first();
|
||||||
|
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||||
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
|
$budgetRepos->shouldReceive('findNull')->atLeast()->once()->withAnyArgs()
|
||||||
|
->andReturn($this->user()->budgets()->first());
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser');
|
$repository->shouldReceive('setUser');
|
||||||
@@ -134,6 +154,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -211,6 +232,8 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
@@ -287,7 +310,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
@@ -366,6 +389,8 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
$expenseAccount = $this->user()->accounts()->where('account_type_id', 4)->first();
|
$expenseAccount = $this->user()->accounts()->where('account_type_id', 4)->first();
|
||||||
@@ -447,6 +472,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
$expenseAccount = $this->user()->accounts()->where('account_type_id', 4)->first();
|
$expenseAccount = $this->user()->accounts()->where('account_type_id', 4)->first();
|
||||||
@@ -526,6 +552,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -617,6 +644,8 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
@@ -691,6 +720,8 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -764,6 +795,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -851,6 +883,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -924,6 +957,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -997,6 +1031,8 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -1070,6 +1106,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -1143,6 +1180,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -1216,6 +1254,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser');
|
$repository->shouldReceive('setUser');
|
||||||
@@ -1286,6 +1325,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser');
|
$repository->shouldReceive('setUser');
|
||||||
@@ -1359,6 +1399,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser');
|
$repository->shouldReceive('setUser');
|
||||||
@@ -1436,6 +1477,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -1501,6 +1543,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
@@ -1564,6 +1607,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
$otherAssetAccount = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $assetAccount->id)->first();
|
$otherAssetAccount = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $assetAccount->id)->first();
|
||||||
@@ -1644,6 +1688,7 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
$factory = $this->mock(CategoryFactory::class);
|
$factory = $this->mock(CategoryFactory::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||||
|
|
||||||
|
@@ -56,13 +56,13 @@ class UserControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDelete(): void
|
public function testDelete(): void
|
||||||
{
|
{
|
||||||
|
$userRepository = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
$userRepository->shouldReceive('destroy')->once();
|
||||||
// create a user first:
|
// create a user first:
|
||||||
$user = User::create(['email' => 'some@newu' . random_int(1, 10000) . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
|
||||||
|
|
||||||
// call API
|
// call API
|
||||||
$response = $this->delete('/api/v1/users/' . $user->id);
|
$response = $this->delete('/api/v1/users/' . $this->user()->id);
|
||||||
$response->assertStatus(204);
|
$response->assertStatus(204);
|
||||||
$this->assertDatabaseMissing('users', ['id' => $user->id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,6 +73,8 @@ class UserControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDeleteNoAdmin(): void
|
public function testDeleteNoAdmin(): void
|
||||||
{
|
{
|
||||||
|
$userRepository = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(false);
|
||||||
Passport::actingAs($this->emptyUser());
|
Passport::actingAs($this->emptyUser());
|
||||||
|
|
||||||
// create a user first:
|
// create a user first:
|
||||||
|
@@ -87,6 +87,7 @@ class ExportControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
@@ -55,6 +55,9 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testIndex(): void
|
public function testIndex(): void
|
||||||
{
|
{
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'A_pre_job_' . random_int(1, 10000);
|
$job->key = 'A_pre_job_' . random_int(1, 10000);
|
||||||
@@ -64,10 +67,6 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
$job->file_type = '';
|
$job->file_type = '';
|
||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
// mock stuff
|
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
|
||||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
@@ -90,6 +89,7 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testIndexBadState(): void
|
public function testIndexBadState(): void
|
||||||
{
|
{
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
@@ -116,6 +116,8 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testIndexComplete(): void
|
public function testIndexComplete(): void
|
||||||
{
|
{
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
@@ -126,12 +128,7 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
$job->file_type = '';
|
$job->file_type = '';
|
||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
// mock stuff
|
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
|
||||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
$repository->shouldReceive('setStatus')->once()->withArgs([Mockery::any(), 'has_prereq']);
|
$repository->shouldReceive('setStatus')->once()->withArgs([Mockery::any(), 'has_prereq']);
|
||||||
$prereq->shouldReceive('setUser')->times(2);
|
$prereq->shouldReceive('setUser')->times(2);
|
||||||
$prereq->shouldReceive('isComplete')->times(2)->andReturn(true);
|
$prereq->shouldReceive('isComplete')->times(2)->andReturn(true);
|
||||||
@@ -151,6 +148,8 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testPost(): void
|
public function testPost(): void
|
||||||
{
|
{
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
@@ -161,13 +160,7 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
$job->file_type = '';
|
$job->file_type = '';
|
||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
// mock stuff
|
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
|
||||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
|
|
||||||
$prereq->shouldReceive('setUser')->times(2);
|
$prereq->shouldReceive('setUser')->times(2);
|
||||||
$prereq->shouldReceive('storePrerequisites')->once()->andReturn(new MessageBag);
|
$prereq->shouldReceive('storePrerequisites')->once()->andReturn(new MessageBag);
|
||||||
$repository->shouldReceive('setStatus')->once()->withArgs([Mockery::any(), 'has_prereq']);
|
$repository->shouldReceive('setStatus')->once()->withArgs([Mockery::any(), 'has_prereq']);
|
||||||
@@ -187,6 +180,8 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testPostBadState(): void
|
public function testPostBadState(): void
|
||||||
{
|
{
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
@@ -198,11 +193,6 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
// mock stuff
|
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
|
||||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
|
||||||
|
|
||||||
$prereq->shouldReceive('setUser')->times(1);
|
$prereq->shouldReceive('setUser')->times(1);
|
||||||
$prereq->shouldReceive('isComplete')->times(1)->andReturn(false);
|
$prereq->shouldReceive('isComplete')->times(1)->andReturn(false);
|
||||||
|
|
||||||
@@ -221,8 +211,6 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testPostNoJob(): void
|
public function testPostNoJob(): void
|
||||||
{
|
{
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
// mock stuff
|
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
@@ -248,6 +236,8 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testPostWithMessages(): void
|
public function testPostWithMessages(): void
|
||||||
{
|
{
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
@@ -260,11 +250,6 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
|
|
||||||
$messages = new MessageBag;
|
$messages = new MessageBag;
|
||||||
$messages->add('some', 'message');
|
$messages->add('some', 'message');
|
||||||
|
|
||||||
// mock stuff
|
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
|
||||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
$prereq->shouldReceive('setUser')->times(1);
|
$prereq->shouldReceive('setUser')->times(1);
|
||||||
|
@@ -158,6 +158,8 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEventsStartAfterEnd(): void
|
public function testEventsStartAfterEnd(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||||
|
|
||||||
$parameters = [
|
$parameters = [
|
||||||
'start' => '2018-01-01',
|
'start' => '2018-01-01',
|
||||||
'end' => '2018-01-31',
|
'end' => '2018-01-31',
|
||||||
@@ -336,6 +338,8 @@ class RecurrenceControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testSuggest(): void
|
public function testSuggest(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
|
||||||
$parameters = [
|
$parameters = [
|
||||||
|
@@ -33,6 +33,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
@@ -68,6 +69,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
@@ -91,6 +93,9 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
@@ -111,24 +116,20 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
public function testCreate(): void
|
public function testCreate(): void
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
|
|
||||||
|
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
// new account list thing.
|
// new account list thing.
|
||||||
$currency = TransactionCurrency::first();
|
$currency = TransactionCurrency::first();
|
||||||
$account = factory(Account::class)->make();
|
$account = factory(Account::class)->make();
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
|
||||||
$currencyRepos->shouldReceive('findNull')->andReturn($currency);
|
$currencyRepos->shouldReceive('findNull')->andReturn($currency);
|
||||||
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
|
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
|
||||||
Amount::shouldReceive('balance')->andReturn('0');
|
Amount::shouldReceive('balance')->andReturn('0');
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
|
|
||||||
@@ -147,7 +148,9 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -166,6 +169,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
@@ -187,10 +191,11 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$account = factory(Account::class)->make();
|
$account = factory(Account::class)->make();
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
// mock stuff for new account list thing.
|
// mock stuff for new account list thing.
|
||||||
@@ -224,7 +229,9 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
$accountRepos->shouldReceive('setUser');
|
$accountRepos->shouldReceive('setUser');
|
||||||
$currencyRepos->shouldReceive('setUser');
|
$currencyRepos->shouldReceive('setUser');
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
@@ -266,6 +273,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
@@ -294,6 +302,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
@@ -319,6 +328,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
@@ -345,6 +355,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
@@ -369,6 +380,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
@@ -389,10 +401,11 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -412,6 +425,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$repository->shouldReceive('setOrder')->once()->withArgs([Mockery::any(), 3])->andReturn(false);
|
$repository->shouldReceive('setOrder')->once()->withArgs([Mockery::any(), 3])->andReturn(false);
|
||||||
|
|
||||||
@@ -433,11 +447,12 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('setUser');
|
$accountRepos->shouldReceive('setUser');
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
$currencyRepos->shouldReceive('setUser');
|
$currencyRepos->shouldReceive('setUser');
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn($first);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn($first);
|
||||||
@@ -463,6 +478,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('store')->andReturn(new PiggyBank);
|
$repository->shouldReceive('store')->andReturn(new PiggyBank);
|
||||||
@@ -492,6 +508,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('update')->andReturn(new PiggyBank);
|
$repository->shouldReceive('update')->andReturn(new PiggyBank);
|
||||||
|
@@ -24,8 +24,10 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Feature\Controllers\Recurring;
|
namespace Tests\Feature\Controllers\Recurring;
|
||||||
|
|
||||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,8 +51,10 @@ class DeleteControllerTest extends TestCase
|
|||||||
public function testDelete(): void
|
public function testDelete(): void
|
||||||
{
|
{
|
||||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||||
$recurringRepos->shouldReceive('getTransactions')->andReturn(new Collection())->once();
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
$recurringRepos->shouldReceive('getTransactions')->andReturn(new Collection())->once();
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('recurring.delete', [1]));
|
$response = $this->get(route('recurring.delete', [1]));
|
||||||
@@ -64,6 +68,8 @@ class DeleteControllerTest extends TestCase
|
|||||||
public function testDestroy(): void
|
public function testDestroy(): void
|
||||||
{
|
{
|
||||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$recurringRepos->shouldReceive('destroy')->once();
|
$recurringRepos->shouldReceive('destroy')->once();
|
||||||
|
|
||||||
|
|
||||||
|
@@ -24,11 +24,15 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Feature\Controllers\Recurring;
|
namespace Tests\Feature\Controllers\Recurring;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,6 +57,11 @@ class EditControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$accountRepos =$this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
$recurringRepos->shouldReceive('setUser');
|
$recurringRepos->shouldReceive('setUser');
|
||||||
$recurringRepos->shouldReceive('getNoteText')->andReturn('Note!');
|
$recurringRepos->shouldReceive('getNoteText')->andReturn('Note!');
|
||||||
@@ -80,6 +89,9 @@ class EditControllerTest extends TestCase
|
|||||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$accountRepos =$this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
$recurringRepos->shouldReceive('update')->once();
|
$recurringRepos->shouldReceive('update')->once();
|
||||||
|
|
||||||
|
@@ -27,8 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,11 +61,11 @@ class IndexControllerTest extends TestCase
|
|||||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('moveDown');
|
$repository->shouldReceive('moveDown');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('rules.down', [1]));
|
$response = $this->get(route('rules.down', [1]));
|
||||||
$response->assertStatus(302);
|
$response->assertStatus(302);
|
||||||
@@ -80,6 +82,9 @@ class IndexControllerTest extends TestCase
|
|||||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$ruleGroupRepos->shouldReceive('count')->andReturn(0);
|
$ruleGroupRepos->shouldReceive('count')->andReturn(0);
|
||||||
$ruleGroupRepos->shouldReceive('store');
|
$ruleGroupRepos->shouldReceive('store');
|
||||||
@@ -103,6 +108,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
@@ -123,6 +129,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$data = ['triggers' => [1, 2, 3]];
|
$data = ['triggers' => [1, 2, 3]];
|
||||||
@@ -143,6 +150,8 @@ class IndexControllerTest extends TestCase
|
|||||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('moveUp');
|
$repository->shouldReceive('moveUp');
|
||||||
|
@@ -26,9 +26,9 @@ namespace Tests\Unit\Import\JobConfiguration;
|
|||||||
use FireflyIII\Import\JobConfiguration\FakeJobConfiguration;
|
use FireflyIII\Import\JobConfiguration\FakeJobConfiguration;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FakeJobConfigurationTest
|
* Class FakeJobConfigurationTest
|
||||||
@@ -52,6 +52,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCC(): void
|
public function testCC(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'A_unit_' . random_int(1, 10000);
|
$job->key = 'A_unit_' . random_int(1, 10000);
|
||||||
@@ -62,6 +65,8 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
$job->configuration = [];
|
$job->configuration = [];
|
||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// should be false:
|
// should be false:
|
||||||
$configurator = new FakeJobConfiguration;
|
$configurator = new FakeJobConfiguration;
|
||||||
$configurator->setImportJob($job);
|
$configurator->setImportJob($job);
|
||||||
@@ -75,6 +80,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCCAlbumFalse(): void
|
public function testCCAlbumFalse(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'B_unit_' . random_int(1, 10000);
|
$job->key = 'B_unit_' . random_int(1, 10000);
|
||||||
@@ -98,6 +106,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCCApplyRules(): void
|
public function testCCApplyRules(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'C_unit_' . random_int(1, 10000);
|
$job->key = 'C_unit_' . random_int(1, 10000);
|
||||||
@@ -123,6 +134,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCCBadAlbum(): void
|
public function testCCBadAlbum(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'D_unit_' . random_int(1, 10000);
|
$job->key = 'D_unit_' . random_int(1, 10000);
|
||||||
@@ -151,6 +165,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCCBadInfo(): void
|
public function testCCBadInfo(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'E_unit_' . random_int(1, 10000);
|
$job->key = 'E_unit_' . random_int(1, 10000);
|
||||||
@@ -178,6 +195,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCCGoodAlbum(): void
|
public function testCCGoodAlbum(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'f_unit_' . random_int(1, 10000);
|
$job->key = 'f_unit_' . random_int(1, 10000);
|
||||||
@@ -206,6 +226,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCCGoodNewInfo(): void
|
public function testCCGoodNewInfo(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'g_unit_' . random_int(1, 10000);
|
$job->key = 'g_unit_' . random_int(1, 10000);
|
||||||
@@ -513,6 +536,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextViewAlbum(): void
|
public function testGetNextViewAlbum(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'p_unit_' . random_int(1, 10000);
|
$job->key = 'p_unit_' . random_int(1, 10000);
|
||||||
@@ -537,6 +563,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextViewArtist(): void
|
public function testGetNextViewArtist(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'p_unit_' . random_int(1, 10000);
|
$job->key = 'p_unit_' . random_int(1, 10000);
|
||||||
@@ -561,6 +590,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextViewRules(): void
|
public function testGetNextViewRules(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'p_unit_' . random_int(1, 10000);
|
$job->key = 'p_unit_' . random_int(1, 10000);
|
||||||
@@ -585,6 +617,9 @@ class FakeJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextViewSong(): void
|
public function testGetNextViewSong(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'p_unit_' . random_int(1, 10000);
|
$job->key = 'p_unit_' . random_int(1, 10000);
|
||||||
|
@@ -27,6 +27,7 @@ namespace Tests\Unit\Import\JobConfiguration;
|
|||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Import\JobConfiguration\FileJobConfiguration;
|
use FireflyIII\Import\JobConfiguration\FileJobConfiguration;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler;
|
||||||
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler;
|
||||||
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler;
|
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler;
|
||||||
@@ -57,6 +58,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCCFalse(): void
|
public function testCCFalse(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'File_A_unit_' . random_int(1, 10000);
|
$job->key = 'File_A_unit_' . random_int(1, 10000);
|
||||||
@@ -80,6 +83,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCCTrue(): void
|
public function testCCTrue(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'File_B_unit_' . random_int(1, 10000);
|
$job->key = 'File_B_unit_' . random_int(1, 10000);
|
||||||
@@ -103,6 +108,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigureJob(): void
|
public function testConfigureJob(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'I-Cfile_' . random_int(1, 10000);
|
$job->key = 'I-Cfile_' . random_int(1, 10000);
|
||||||
@@ -138,6 +145,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextDataCU(): void
|
public function testGetNextDataCU(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'G-Dfile_' . random_int(1, 10000);
|
$job->key = 'G-Dfile_' . random_int(1, 10000);
|
||||||
@@ -171,6 +180,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextDataMap(): void
|
public function testGetNextDataMap(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'H-Efile_' . random_int(1, 10000);
|
$job->key = 'H-Efile_' . random_int(1, 10000);
|
||||||
@@ -204,6 +215,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextDataNew(): void
|
public function testGetNextDataNew(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'F-fFile_' . random_int(1, 10000);
|
$job->key = 'F-fFile_' . random_int(1, 10000);
|
||||||
@@ -237,6 +250,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextDataRoles(): void
|
public function testGetNextDataRoles(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'H-fiGle_' . random_int(1, 10000);
|
$job->key = 'H-fiGle_' . random_int(1, 10000);
|
||||||
@@ -270,6 +285,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextViewCU(): void
|
public function testGetNextViewCU(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'DfiHle_' . random_int(1, 10000);
|
$job->key = 'DfiHle_' . random_int(1, 10000);
|
||||||
@@ -298,6 +315,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextViewMap(): void
|
public function testGetNextViewMap(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'FfilIe_' . random_int(1, 10000);
|
$job->key = 'FfilIe_' . random_int(1, 10000);
|
||||||
@@ -326,6 +345,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextViewNew(): void
|
public function testGetNextViewNew(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'CfJile_' . random_int(1, 10000);
|
$job->key = 'CfJile_' . random_int(1, 10000);
|
||||||
@@ -354,6 +375,8 @@ class FileJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextViewRoles(): void
|
public function testGetNextViewRoles(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once()->atLeast();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'EfiKle_' . random_int(1, 10000);
|
$job->key = 'EfiKle_' . random_int(1, 10000);
|
||||||
|
@@ -26,6 +26,7 @@ namespace Tests\Unit\Import\JobConfiguration;
|
|||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Import\JobConfiguration\SpectreJobConfiguration;
|
use FireflyIII\Import\JobConfiguration\SpectreJobConfiguration;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\AuthenticatedHandler;
|
use FireflyIII\Support\Import\JobConfiguration\Spectre\AuthenticatedHandler;
|
||||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseAccountsHandler;
|
use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseAccountsHandler;
|
||||||
use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseLoginHandler;
|
use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseLoginHandler;
|
||||||
@@ -55,6 +56,8 @@ class SpectreJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigurationComplete(): void
|
public function testConfigurationComplete(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'spectre_jc_A' . random_int(1, 10000);
|
$job->key = 'spectre_jc_A' . random_int(1, 10000);
|
||||||
@@ -84,6 +87,8 @@ class SpectreJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigureJob(): void
|
public function testConfigureJob(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'spectre_jc_B' . random_int(1, 10000);
|
$job->key = 'spectre_jc_B' . random_int(1, 10000);
|
||||||
@@ -116,6 +121,8 @@ class SpectreJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextData(): void
|
public function testGetNextData(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'spectre_jc_C' . random_int(1, 10000);
|
$job->key = 'spectre_jc_C' . random_int(1, 10000);
|
||||||
@@ -146,6 +153,8 @@ class SpectreJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextView(): void
|
public function testGetNextView(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'spectre_jc_D' . random_int(1, 10000);
|
$job->key = 'spectre_jc_D' . random_int(1, 10000);
|
||||||
@@ -175,6 +184,8 @@ class SpectreJobConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextViewAccount(): void
|
public function testGetNextViewAccount(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'spectre_jc_E' . random_int(1, 10000);
|
$job->key = 'spectre_jc_E' . random_int(1, 10000);
|
||||||
|
@@ -38,10 +38,12 @@ use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Log;
|
|
||||||
/**
|
/**
|
||||||
* Class ImportArrayStorageTest
|
* Class ImportArrayStorageTest
|
||||||
*/
|
*/
|
||||||
@@ -57,7 +59,6 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Very basic storage routine. Doesn't call store()
|
* Very basic storage routine. Doesn't call store()
|
||||||
*
|
*
|
||||||
@@ -65,6 +66,10 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasic(): void
|
public function testBasic(): void
|
||||||
{
|
{
|
||||||
|
// mock stuff
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
// make fake job
|
// make fake job
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user()->associate($this->user());
|
$job->user()->associate($this->user());
|
||||||
@@ -77,9 +82,6 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
$job->transactions = [];
|
$job->transactions = [];
|
||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
// mock stuff
|
|
||||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
@@ -94,6 +96,9 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasicStoreDoubleTransferWithRules(): void
|
public function testBasicStoreDoubleTransferWithRules(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('findNull')->once()->andReturn($this->user());
|
||||||
|
|
||||||
// get a transfer:
|
// get a transfer:
|
||||||
/** @var TransactionJournal $transfer */
|
/** @var TransactionJournal $transfer */
|
||||||
$transfer = $this->user()->transactionJournals()
|
$transfer = $this->user()->transactionJournals()
|
||||||
@@ -183,6 +188,9 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasicStoreIsDouble(): void
|
public function testBasicStoreIsDouble(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('findNull')->once()->andReturn($this->user());
|
||||||
|
|
||||||
// make fake job
|
// make fake job
|
||||||
$transactions = [$this->singleWithdrawal(), $this->singleWithdrawal()];
|
$transactions = [$this->singleWithdrawal(), $this->singleWithdrawal()];
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
@@ -245,6 +253,9 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasicStoreNothing(): void
|
public function testBasicStoreNothing(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('findNull')->once()->andReturn($this->user());
|
||||||
|
|
||||||
// make fake job
|
// make fake job
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user()->associate($this->user());
|
$job->user()->associate($this->user());
|
||||||
@@ -284,6 +295,9 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasicStoreNothingWithRules(): void
|
public function testBasicStoreNothingWithRules(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('findNull')->once()->andReturn($this->user());
|
||||||
|
|
||||||
// make fake job
|
// make fake job
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user()->associate($this->user());
|
$job->user()->associate($this->user());
|
||||||
@@ -326,6 +340,9 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasicStoreSingleWithNoRules(): void
|
public function testBasicStoreSingleWithNoRules(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('findNull')->once()->andReturn($this->user());
|
||||||
|
|
||||||
// make fake job
|
// make fake job
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user()->associate($this->user());
|
$job->user()->associate($this->user());
|
||||||
@@ -377,6 +394,9 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasicStoreSingleWithRules(): void
|
public function testBasicStoreSingleWithRules(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('findNull')->once()->andReturn($this->user());
|
||||||
|
|
||||||
// make fake job
|
// make fake job
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user()->associate($this->user());
|
$job->user()->associate($this->user());
|
||||||
@@ -433,6 +453,9 @@ class ImportArrayStorageTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBasicStoreTransferWithRules(): void
|
public function testBasicStoreTransferWithRules(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('findNull')->once()->andReturn($this->user());
|
||||||
|
|
||||||
// make fake job
|
// make fake job
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user()->associate($this->user());
|
$job->user()->associate($this->user());
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\Middleware;
|
namespace Tests\Unit\Middleware;
|
||||||
|
|
||||||
use FireflyIII\Http\Middleware\IsAdmin;
|
use FireflyIII\Http\Middleware\IsAdmin;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
|
use Mockery;
|
||||||
use Route;
|
use Route;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -54,6 +56,8 @@ class IsAdminTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMiddleware(): void
|
public function testMiddleware(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
$response = $this->get('/_test/is-admin');
|
$response = $this->get('/_test/is-admin');
|
||||||
$this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
|
$this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
|
||||||
@@ -65,6 +69,8 @@ class IsAdminTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMiddlewareAjax(): void
|
public function testMiddlewareAjax(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$server = ['HTTP_X-Requested-With' => 'XMLHttpRequest'];
|
$server = ['HTTP_X-Requested-With' => 'XMLHttpRequest'];
|
||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
$response = $this->get('/_test/is-admin', $server);
|
$response = $this->get('/_test/is-admin', $server);
|
||||||
@@ -76,6 +82,9 @@ class IsAdminTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMiddlewareNotOwner(): void
|
public function testMiddlewareNotOwner(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
$this->be($this->emptyUser());
|
$this->be($this->emptyUser());
|
||||||
$response = $this->get('/_test/is-admin');
|
$response = $this->get('/_test/is-admin');
|
||||||
@@ -88,6 +97,9 @@ class IsAdminTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMiddlewareOwner(): void
|
public function testMiddlewareOwner(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
$response = $this->get('/_test/is-admin');
|
$response = $this->get('/_test/is-admin');
|
||||||
|
@@ -35,9 +35,9 @@ use FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use League\Csv\Exception;
|
use League\Csv\Exception;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ConfigureMappingHandlerTest
|
* Class ConfigureMappingHandlerTest
|
||||||
@@ -59,6 +59,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testApplySpecifics(): void
|
public function testApplySpecifics(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$importRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'mapG' . random_int(1, 10000);
|
$job->key = 'mapG' . random_int(1, 10000);
|
||||||
@@ -94,6 +96,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigureJob(): void
|
public function testConfigureJob(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
// create fake input for class method:
|
// create fake input for class method:
|
||||||
$input = [
|
$input = [
|
||||||
'mapping' => [
|
'mapping' => [
|
||||||
@@ -158,6 +161,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDoColumnConfig(): void
|
public function testDoColumnConfig(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$importRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'mapE' . random_int(1, 10000);
|
$job->key = 'mapE' . random_int(1, 10000);
|
||||||
@@ -221,7 +226,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDoMapOfColumn(): void
|
public function testDoMapOfColumn(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$importRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'mapC' . random_int(1, 10000);
|
$job->key = 'mapC' . random_int(1, 10000);
|
||||||
@@ -251,6 +257,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextData(): void
|
public function testGetNextData(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'mapH' . random_int(1, 10000);
|
$job->key = 'mapH' . random_int(1, 10000);
|
||||||
@@ -332,6 +339,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetPreProcessorName(): void
|
public function testGetPreProcessorName(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$importRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'mapD' . random_int(1, 10000);
|
$job->key = 'mapD' . random_int(1, 10000);
|
||||||
@@ -360,6 +369,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetReader(): void
|
public function testGetReader(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'mapF' . random_int(1, 10000);
|
$job->key = 'mapF' . random_int(1, 10000);
|
||||||
@@ -408,6 +418,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetValuesForMapping(): void
|
public function testGetValuesForMapping(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$importRepos->shouldReceive('setUser')->once();
|
||||||
// create a reader to use in method.
|
// create a reader to use in method.
|
||||||
// 5 columns, of which #4 (index 3) is budget-id
|
// 5 columns, of which #4 (index 3) is budget-id
|
||||||
// 5 columns, of which #5 (index 4) is tags-space
|
// 5 columns, of which #5 (index 4) is tags-space
|
||||||
@@ -475,7 +487,8 @@ class ConfigureMappingHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testSanitizeColumnName(): void
|
public function testSanitizeColumnName(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$importRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'mapB' . random_int(1, 10000);
|
$job->key = 'mapB' . random_int(1, 10000);
|
||||||
|
@@ -57,6 +57,9 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigurationCompleteBasic(): void
|
public function testConfigurationCompleteBasic(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
'column-count' => 5,
|
'column-count' => 5,
|
||||||
'column-roles' => [
|
'column-roles' => [
|
||||||
@@ -77,6 +80,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigurationCompleteForeign(): void
|
public function testConfigurationCompleteForeign(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
'column-count' => 5,
|
'column-count' => 5,
|
||||||
'column-roles' => [
|
'column-roles' => [
|
||||||
@@ -101,6 +106,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigurationCompleteNoAmount(): void
|
public function testConfigurationCompleteNoAmount(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
$config = [
|
$config = [
|
||||||
'column-count' => 5,
|
'column-count' => 5,
|
||||||
'column-roles' => [
|
'column-roles' => [
|
||||||
@@ -125,6 +131,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConfigureJob(): void
|
public function testConfigureJob(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'role-B' . random_int(1, 10000);
|
$job->key = 'role-B' . random_int(1, 10000);
|
||||||
@@ -178,7 +185,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetExampleFromLine(): void
|
public function testGetExampleFromLine(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
$lines = [
|
$lines = [
|
||||||
['one', 'two', '', 'three'],
|
['one', 'two', '', 'three'],
|
||||||
['four', 'five', '', 'six'],
|
['four', 'five', '', 'six'],
|
||||||
@@ -201,6 +208,11 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetExamplesFromFile(): void
|
public function testGetExamplesFromFile(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$importRepos->shouldReceive('setUser')->once();
|
||||||
|
$importRepos->shouldReceive('setConfiguration')->once()
|
||||||
|
->withAnyArgs();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'role-x' . random_int(1, 10000);
|
$job->key = 'role-x' . random_int(1, 10000);
|
||||||
@@ -239,6 +251,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetHeadersHas(): void
|
public function testGetHeadersHas(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
//$importRepos->shouldReceive('setUser')->once();
|
||||||
// create a reader to use in method.
|
// create a reader to use in method.
|
||||||
// 5 columns, of which #4 (index 3) is budget-id
|
// 5 columns, of which #4 (index 3) is budget-id
|
||||||
// 5 columns, of which #5 (index 4) is tags-space
|
// 5 columns, of which #5 (index 4) is tags-space
|
||||||
@@ -260,6 +274,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetHeadersNone(): void
|
public function testGetHeadersNone(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
// create a reader to use in method.
|
// create a reader to use in method.
|
||||||
// 5 columns, of which #4 (index 3) is budget-id
|
// 5 columns, of which #4 (index 3) is budget-id
|
||||||
// 5 columns, of which #5 (index 4) is tags-space
|
// 5 columns, of which #5 (index 4) is tags-space
|
||||||
@@ -278,6 +294,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetNextData(): void
|
public function testGetNextData(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'role-x' . random_int(1, 10000);
|
$job->key = 'role-x' . random_int(1, 10000);
|
||||||
@@ -348,6 +365,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetReader(): void
|
public function testGetReader(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'role-x' . random_int(1, 10000);
|
$job->key = 'role-x' . random_int(1, 10000);
|
||||||
@@ -396,6 +414,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIgnoreUnmappableColumns(): void
|
public function testIgnoreUnmappableColumns(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
'column-count' => 5,
|
'column-count' => 5,
|
||||||
'column-roles' => [
|
'column-roles' => [
|
||||||
@@ -439,6 +459,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIsMappingNecessaryNo(): void
|
public function testIsMappingNecessaryNo(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
'column-do-mapping' => [false, false, false],
|
'column-do-mapping' => [false, false, false],
|
||||||
];
|
];
|
||||||
@@ -452,6 +474,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIsMappingNecessaryYes(): void
|
public function testIsMappingNecessaryYes(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
'column-do-mapping' => [false, true, false, false],
|
'column-do-mapping' => [false, true, false, false],
|
||||||
];
|
];
|
||||||
@@ -465,6 +489,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMakeExamplesUnique(): void
|
public function testMakeExamplesUnique(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$lines = [
|
$lines = [
|
||||||
['one', 'two', '', 'three'],
|
['one', 'two', '', 'three'],
|
||||||
['four', 'five', '', 'six'],
|
['four', 'five', '', 'six'],
|
||||||
@@ -491,6 +517,8 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testProcessSpecifics(): void
|
public function testProcessSpecifics(): void
|
||||||
{
|
{
|
||||||
|
$importRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$line = [];
|
$line = [];
|
||||||
$config = [
|
$config = [
|
||||||
'specifics' => [
|
'specifics' => [
|
||||||
@@ -512,6 +540,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testSaveColumCount(): void
|
public function testSaveColumCount(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'role-A' . random_int(1, 10000);
|
$job->key = 'role-A' . random_int(1, 10000);
|
||||||
|
@@ -59,6 +59,7 @@ class ChooseLoginHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCCFalse(): void
|
public function testCCFalse(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'slh-A' . random_int(1, 10000);
|
$job->key = 'slh-A' . random_int(1, 10000);
|
||||||
@@ -205,6 +206,8 @@ class ChooseLoginHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetNextData(): void
|
public function testGetNextData(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$repository->shouldReceive('setUser')->once();
|
||||||
// fake login:
|
// fake login:
|
||||||
$holder = new Holder([]);
|
$holder = new Holder([]);
|
||||||
$attempt = new Attempt(
|
$attempt = new Attempt(
|
||||||
|
@@ -27,15 +27,16 @@ namespace Tests\Unit\Support\Import\Routine\File;
|
|||||||
use Amount;
|
use Amount;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\Placeholder\ImportTransaction;
|
use FireflyIII\Support\Import\Placeholder\ImportTransaction;
|
||||||
use FireflyIII\Support\Import\Routine\File\AssetAccountMapper;
|
use FireflyIII\Support\Import\Routine\File\AssetAccountMapper;
|
||||||
use FireflyIII\Support\Import\Routine\File\CurrencyMapper;
|
use FireflyIII\Support\Import\Routine\File\CurrencyMapper;
|
||||||
use FireflyIII\Support\Import\Routine\File\ImportableConverter;
|
use FireflyIII\Support\Import\Routine\File\ImportableConverter;
|
||||||
use FireflyIII\Support\Import\Routine\File\OpposingAccountMapper;
|
use FireflyIII\Support\Import\Routine\File\OpposingAccountMapper;
|
||||||
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* todo test foreign currency
|
* todo test foreign currency
|
||||||
@@ -81,6 +82,9 @@ class ImportableConverterTest extends TestCase
|
|||||||
$assetMapper = $this->mock(AssetAccountMapper::class);
|
$assetMapper = $this->mock(AssetAccountMapper::class);
|
||||||
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
||||||
$currencyMapper = $this->mock(CurrencyMapper::class);
|
$currencyMapper = $this->mock(CurrencyMapper::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
$accountRepos->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
// get default currency
|
// get default currency
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
@@ -138,6 +142,10 @@ class ImportableConverterTest extends TestCase
|
|||||||
$assetMapper = $this->mock(AssetAccountMapper::class);
|
$assetMapper = $this->mock(AssetAccountMapper::class);
|
||||||
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
||||||
$currencyMapper = $this->mock(CurrencyMapper::class);
|
$currencyMapper = $this->mock(CurrencyMapper::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->shouldReceive('setUser')->once();
|
||||||
|
$accountRepos->shouldReceive('getMetaValue')
|
||||||
|
->withArgs([Mockery::any(), 'currency_id'])->atLeast()->once()->andReturn('1');
|
||||||
|
|
||||||
// get default currency
|
// get default currency
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
@@ -159,7 +167,7 @@ class ImportableConverterTest extends TestCase
|
|||||||
|
|
||||||
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn(null);
|
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['name' => null, 'code' => null, 'symbol' => null]])->andReturn(null);
|
||||||
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['code' => null]])->andReturn(null);
|
$currencyMapper->shouldReceive('map')->once()->withArgs([null, ['code' => null]])->andReturn(null);
|
||||||
$currencyMapper->shouldReceive('map')->times(1)->withArgs([$euro->id, []])->andReturn($euro);
|
$currencyMapper->shouldReceive('map')->times(2)->withArgs([$euro->id, []])->andReturn($euro);
|
||||||
|
|
||||||
|
|
||||||
$converter = new ImportableConverter;
|
$converter = new ImportableConverter;
|
||||||
@@ -199,6 +207,8 @@ class ImportableConverterTest extends TestCase
|
|||||||
$assetMapper = $this->mock(AssetAccountMapper::class);
|
$assetMapper = $this->mock(AssetAccountMapper::class);
|
||||||
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
||||||
$currencyMapper = $this->mock(CurrencyMapper::class);
|
$currencyMapper = $this->mock(CurrencyMapper::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
// get default currency
|
// get default currency
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
@@ -261,6 +271,8 @@ class ImportableConverterTest extends TestCase
|
|||||||
$assetMapper = $this->mock(AssetAccountMapper::class);
|
$assetMapper = $this->mock(AssetAccountMapper::class);
|
||||||
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
||||||
$currencyMapper = $this->mock(CurrencyMapper::class);
|
$currencyMapper = $this->mock(CurrencyMapper::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
// get default currency
|
// get default currency
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
@@ -318,6 +330,8 @@ class ImportableConverterTest extends TestCase
|
|||||||
$assetMapper = $this->mock(AssetAccountMapper::class);
|
$assetMapper = $this->mock(AssetAccountMapper::class);
|
||||||
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
||||||
$currencyMapper = $this->mock(CurrencyMapper::class);
|
$currencyMapper = $this->mock(CurrencyMapper::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
// get default currency
|
// get default currency
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
@@ -389,6 +403,8 @@ class ImportableConverterTest extends TestCase
|
|||||||
$assetMapper = $this->mock(AssetAccountMapper::class);
|
$assetMapper = $this->mock(AssetAccountMapper::class);
|
||||||
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
||||||
$currencyMapper = $this->mock(CurrencyMapper::class);
|
$currencyMapper = $this->mock(CurrencyMapper::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
// get default currency
|
// get default currency
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
@@ -454,6 +470,8 @@ class ImportableConverterTest extends TestCase
|
|||||||
$assetMapper = $this->mock(AssetAccountMapper::class);
|
$assetMapper = $this->mock(AssetAccountMapper::class);
|
||||||
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
||||||
$currencyMapper = $this->mock(CurrencyMapper::class);
|
$currencyMapper = $this->mock(CurrencyMapper::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
// get default currency
|
// get default currency
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
@@ -502,7 +520,10 @@ class ImportableConverterTest extends TestCase
|
|||||||
$assetMapper = $this->mock(AssetAccountMapper::class);
|
$assetMapper = $this->mock(AssetAccountMapper::class);
|
||||||
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
||||||
$currencyMapper = $this->mock(CurrencyMapper::class);
|
$currencyMapper = $this->mock(CurrencyMapper::class);
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($euro)->once();
|
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($euro)->once();
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
$assetMapper->shouldReceive('setUser')->once();
|
$assetMapper->shouldReceive('setUser')->once();
|
||||||
@@ -532,7 +553,10 @@ class ImportableConverterTest extends TestCase
|
|||||||
$assetMapper = $this->mock(AssetAccountMapper::class);
|
$assetMapper = $this->mock(AssetAccountMapper::class);
|
||||||
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
$opposingMapper = $this->mock(OpposingAccountMapper::class);
|
||||||
$currencyMapper = $this->mock(CurrencyMapper::class);
|
$currencyMapper = $this->mock(CurrencyMapper::class);
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
|
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($euro)->once();
|
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($euro)->once();
|
||||||
$repository->shouldReceive('setUser')->once();
|
$repository->shouldReceive('setUser')->once();
|
||||||
$assetMapper->shouldReceive('setUser')->once();
|
$assetMapper->shouldReceive('setUser')->once();
|
||||||
|
@@ -26,6 +26,7 @@ namespace Tests\Unit\Support\Import\Routine\File;
|
|||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use FireflyIII\Support\Import\Routine\File\MappingConverger;
|
use FireflyIII\Support\Import\Routine\File\MappingConverger;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -48,7 +49,8 @@ class MappingConvergerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testConverge(): void
|
public function testConverge(): void
|
||||||
{
|
{
|
||||||
|
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
// configuration
|
// configuration
|
||||||
$config = [
|
$config = [
|
||||||
'column-roles' => [
|
'column-roles' => [
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\TransactionRules\Triggers;
|
namespace Tests\Unit\TransactionRules\Triggers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\Triggers\FromAccountStarts;
|
use FireflyIII\TransactionRules\Triggers\FromAccountStarts;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@@ -49,7 +50,7 @@ class FromAccountStartsTest extends TestCase
|
|||||||
public function testTriggered(): void
|
public function testTriggered(): void
|
||||||
{
|
{
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
||||||
$account = $this->user()->accounts()->inRandomOrder()->first();
|
$account = $this->user()->accounts()->inRandomOrder()->first();
|
||||||
@@ -67,6 +68,7 @@ class FromAccountStartsTest extends TestCase
|
|||||||
public function testTriggeredLonger(): void
|
public function testTriggeredLonger(): void
|
||||||
{
|
{
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
||||||
@@ -85,6 +87,7 @@ class FromAccountStartsTest extends TestCase
|
|||||||
public function testTriggeredNot(): void
|
public function testTriggeredNot(): void
|
||||||
{
|
{
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
||||||
@@ -103,6 +106,8 @@ class FromAccountStartsTest extends TestCase
|
|||||||
public function testWillMatchEverythingEmpty(): void
|
public function testWillMatchEverythingEmpty(): void
|
||||||
{
|
{
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
$value = '';
|
$value = '';
|
||||||
$result = FromAccountStarts::willMatchEverything($value);
|
$result = FromAccountStarts::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
@@ -114,6 +119,8 @@ class FromAccountStartsTest extends TestCase
|
|||||||
public function testWillMatchEverythingNotNull(): void
|
public function testWillMatchEverythingNotNull(): void
|
||||||
{
|
{
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
$value = 'x';
|
$value = 'x';
|
||||||
$result = FromAccountStarts::willMatchEverything($value);
|
$result = FromAccountStarts::willMatchEverything($value);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
@@ -125,6 +132,8 @@ class FromAccountStartsTest extends TestCase
|
|||||||
public function testWillMatchEverythingNull(): void
|
public function testWillMatchEverythingNull(): void
|
||||||
{
|
{
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
$value = null;
|
$value = null;
|
||||||
$result = FromAccountStarts::willMatchEverything($value);
|
$result = FromAccountStarts::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
Reference in New Issue
Block a user