mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-20 11:33:59 +00:00
Code for #1671
This commit is contained in:
@@ -28,8 +28,8 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class AssetAccountIbansTest
|
||||
@@ -51,17 +51,25 @@ class AssetAccountIbansTest extends TestCase
|
||||
*/
|
||||
public function testGetMapBasic(): void
|
||||
{
|
||||
$one = new Account;
|
||||
$one->id = 17;
|
||||
$one->name = 'Something';
|
||||
$one->iban = 'IBAN';
|
||||
$two = new Account;
|
||||
$two->id = 53;
|
||||
$two->name = 'Else';
|
||||
$asset = AccountType::where('type', AccountType::ASSET)->first();
|
||||
$loan = AccountType::where('type', AccountType::LOAN)->first();
|
||||
$one = new Account;
|
||||
$one->id = 17;
|
||||
$one->name = 'Something';
|
||||
$one->iban = 'IBAN';
|
||||
$one->account_type_id = $asset->id;
|
||||
|
||||
$two = new Account;
|
||||
$two->id = 53;
|
||||
$two->name = 'Else';
|
||||
$two->account_type_id = $loan->id;
|
||||
|
||||
$collection = new Collection([$one, $two]);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn($collection)->once();
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs(
|
||||
[[AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE,]]
|
||||
)->andReturn($collection)->once();
|
||||
|
||||
$mapper = new AssetAccountIbans();
|
||||
$mapping = $mapper->getMap();
|
||||
@@ -69,7 +77,7 @@ class AssetAccountIbansTest extends TestCase
|
||||
// assert this is what the result looks like:
|
||||
$result = [
|
||||
0 => (string)trans('import.map_do_not_map'),
|
||||
53 => 'Else',
|
||||
53 => 'Else (liability)',
|
||||
17 => 'IBAN (Something)',
|
||||
];
|
||||
$this->assertEquals($result, $mapping);
|
||||
|
@@ -28,8 +28,8 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class AssetAccountsTest
|
||||
@@ -51,17 +51,26 @@ class AssetAccountsTest extends TestCase
|
||||
*/
|
||||
public function testGetMapBasic(): void
|
||||
{
|
||||
$one = new Account;
|
||||
$one->id = 23;
|
||||
$one->name = 'Something';
|
||||
$one->iban = 'IBAN';
|
||||
$two = new Account;
|
||||
$two->id = 19;
|
||||
$two->name = 'Else';
|
||||
$asset = AccountType::where('type', AccountType::ASSET)->first();
|
||||
$loan = AccountType::where('type', AccountType::LOAN)->first();
|
||||
|
||||
$one = new Account;
|
||||
$one->id = 23;
|
||||
$one->name = 'Something';
|
||||
$one->iban = 'IBAN';
|
||||
$one->account_type_id = $asset->id;
|
||||
|
||||
$two = new Account;
|
||||
$two->id = 19;
|
||||
$two->name = 'Else';
|
||||
$two->account_type_id = $loan->id;
|
||||
|
||||
$collection = new Collection([$one, $two]);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn($collection)->once();
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs(
|
||||
[[AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE,]]
|
||||
)->andReturn($collection)->once();
|
||||
|
||||
$mapper = new AssetAccounts();
|
||||
$mapping = $mapper->getMap();
|
||||
@@ -69,7 +78,7 @@ class AssetAccountsTest extends TestCase
|
||||
// assert this is what the result looks like:
|
||||
$result = [
|
||||
0 => (string)trans('import.map_do_not_map'),
|
||||
19 => 'Else',
|
||||
19 => 'Liability: Else',
|
||||
23 => 'Something (IBAN)',
|
||||
|
||||
];
|
||||
|
@@ -28,8 +28,8 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class OpposingAccountIbansTest
|
||||
@@ -51,18 +51,25 @@ class OpposingAccountIbansTest extends TestCase
|
||||
*/
|
||||
public function testGetMapBasic(): void
|
||||
{
|
||||
$one = new Account;
|
||||
$one->id = 21;
|
||||
$one->name = 'Something';
|
||||
$one->iban = 'IBAN';
|
||||
$two = new Account;
|
||||
$two->id = 17;
|
||||
$two->name = 'Else';
|
||||
$asset = AccountType::where('type', AccountType::ASSET)->first();
|
||||
$loan = AccountType::where('type', AccountType::LOAN)->first();
|
||||
$one = new Account;
|
||||
$one->id = 21;
|
||||
$one->name = 'Something';
|
||||
$one->iban = 'IBAN';
|
||||
$one->account_type_id = $asset->id;
|
||||
|
||||
$two = new Account;
|
||||
$two->id = 17;
|
||||
$two->name = 'Else';
|
||||
$two->account_type_id = $loan->id;
|
||||
|
||||
$collection = new Collection([$one, $two]);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs(
|
||||
[[AccountType::DEFAULT, AccountType::ASSET, AccountType::EXPENSE, AccountType::BENEFICIARY, AccountType::REVENUE,]]
|
||||
[[AccountType::DEFAULT, AccountType::ASSET, AccountType::EXPENSE, AccountType::BENEFICIARY, AccountType::REVENUE, AccountType::LOAN,
|
||||
AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE,]]
|
||||
)->andReturn($collection)->once();
|
||||
|
||||
$mapper = new OpposingAccountIbans();
|
||||
@@ -71,7 +78,7 @@ class OpposingAccountIbansTest extends TestCase
|
||||
// assert this is what the result looks like:
|
||||
$result = [
|
||||
0 => (string)trans('import.map_do_not_map'),
|
||||
17 => 'Else',
|
||||
17 => 'Else (liability)',
|
||||
21 => 'IBAN (Something)',
|
||||
];
|
||||
$this->assertEquals($result, $mapping);
|
||||
|
@@ -28,8 +28,8 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class OpposingAccountsTest
|
||||
@@ -51,18 +51,29 @@ class OpposingAccountsTest extends TestCase
|
||||
*/
|
||||
public function testGetMapBasic(): void
|
||||
{
|
||||
$one = new Account;
|
||||
$one->id = 13;
|
||||
$one->name = 'Something';
|
||||
$one->iban = 'IBAN';
|
||||
$two = new Account;
|
||||
$two->id = 9;
|
||||
$two->name = 'Else';
|
||||
$asset = AccountType::where('type', AccountType::ASSET)->first();
|
||||
$loan = AccountType::where('type', AccountType::LOAN)->first();
|
||||
|
||||
$one = new Account;
|
||||
$one->id = 13;
|
||||
$one->name = 'Something';
|
||||
$one->iban = 'IBAN';
|
||||
$one->account_type_id = $asset->id;
|
||||
$two = new Account;
|
||||
$two->id = 9;
|
||||
$two->name = 'Else';
|
||||
$two->account_type_id = $loan->id;
|
||||
|
||||
$collection = new Collection([$one, $two]);
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs(
|
||||
[[AccountType::DEFAULT, AccountType::ASSET, AccountType::EXPENSE, AccountType::BENEFICIARY, AccountType::REVENUE,]]
|
||||
[[
|
||||
AccountType::DEFAULT, AccountType::ASSET,
|
||||
AccountType::EXPENSE, AccountType::BENEFICIARY,
|
||||
AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT,
|
||||
AccountType::CREDITCARD, AccountType::MORTGAGE,
|
||||
]]
|
||||
)->andReturn($collection)->once();
|
||||
|
||||
$mapper = new OpposingAccounts();
|
||||
@@ -71,7 +82,7 @@ class OpposingAccountsTest extends TestCase
|
||||
// assert this is what the result looks like:
|
||||
$result = [
|
||||
0 => (string)trans('import.map_do_not_map'),
|
||||
9 => 'Else',
|
||||
9 => 'Liability: Else',
|
||||
13 => 'Something (IBAN)',
|
||||
];
|
||||
$this->assertEquals($result, $mapping);
|
||||
|
Reference in New Issue
Block a user