diff --git a/.travis.yml b/.travis.yml
index cc58593925..49e596ae6a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,7 @@
sudo: required
language: bash
env:
- - VERSION=4.7.17.5
+ - VERSION=4.8.0
dist: xenial
diff --git a/phpunit.coverage.specific.xml b/phpunit.coverage.specific.xml
index f956f821d8..25014c1015 100644
--- a/phpunit.coverage.specific.xml
+++ b/phpunit.coverage.specific.xml
@@ -50,6 +50,7 @@
./tests/Unit/Services
./tests/Unit/Support
./tests/Unit/TransactionRules
+ ./tests/Unit/Transformers
diff --git a/phpunit.coverage.xml b/phpunit.coverage.xml
index f2cbdc495f..887bb12f54 100644
--- a/phpunit.coverage.xml
+++ b/phpunit.coverage.xml
@@ -50,6 +50,7 @@
./tests/Unit/Services
./tests/Unit/Support
./tests/Unit/TransactionRules
+ ./tests/Unit/Transformers
./tests/Feature
diff --git a/phpunit.xml b/phpunit.xml
index e5c11e216a..c86ba80894 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -38,6 +38,7 @@
+
+ ./tests/Unit/Transformers
./tests/Feature
diff --git a/tests/Feature/Controllers/Chart/AccountControllerTest.php b/tests/Feature/Controllers/Chart/AccountControllerTest.php
index 68a09b58af..24e319aaf8 100644
--- a/tests/Feature/Controllers/Chart/AccountControllerTest.php
+++ b/tests/Feature/Controllers/Chart/AccountControllerTest.php
@@ -435,7 +435,7 @@ class AccountControllerTest extends TestCase
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
- $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1), null);
+ $currencyRepos->shouldReceive('findNull')->andReturn($this->getEuro(), null);
$generator->shouldReceive('multiSet')->andReturn([]);
Steam::shouldReceive('balanceInRange')->andReturn(['2012-01-01' => '0']);
@@ -482,7 +482,7 @@ class AccountControllerTest extends TestCase
Steam::shouldReceive('balancesPerCurrencyByAccounts')->twice()->andReturn($start, $end);
// currency should be looking for the currency ID's:
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->once()->andReturn(TransactionCurrency::find(1));
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->once()->andReturn($this->getEuro());
$currencyRepos->shouldReceive('findNull')->withArgs([2])->once()->andReturn(TransactionCurrency::find(2));
$generator->shouldReceive('multiSet')->andReturn([])->once();
diff --git a/tests/Feature/Controllers/Chart/BillControllerTest.php b/tests/Feature/Controllers/Chart/BillControllerTest.php
index 0c48fb61da..a92373c3cb 100644
--- a/tests/Feature/Controllers/Chart/BillControllerTest.php
+++ b/tests/Feature/Controllers/Chart/BillControllerTest.php
@@ -66,7 +66,7 @@ class BillControllerTest extends TestCase
2 => '100',
];
- $currencyRepos->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1))->withArgs([1]);
+ $currencyRepos->shouldReceive('findNull')->once()->andReturn($this->getEuro())->withArgs([1]);
$currencyRepos->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(2))->withArgs([2]);
$repository->shouldReceive('getBillsPaidInRangePerCurrency')->once()->andReturn($amounts);
diff --git a/tests/Feature/Controllers/Chart/CategoryControllerTest.php b/tests/Feature/Controllers/Chart/CategoryControllerTest.php
index ff4ff7e9a1..cdca2234ac 100644
--- a/tests/Feature/Controllers/Chart/CategoryControllerTest.php
+++ b/tests/Feature/Controllers/Chart/CategoryControllerTest.php
@@ -164,7 +164,7 @@ class CategoryControllerTest extends TestCase
$repository->shouldReceive('spentInPeriodPerCurrency')->times(2)->andReturn($spentData);
$repository->shouldReceive('spentInPeriodPcWoCategory')->once()->andReturn($spentNoCategory);
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->once()->andReturn(TransactionCurrency::find(1));
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->once()->andReturn($this->getEuro());
$generator->shouldReceive('multiSet')->andReturn([]);
$this->be($this->user());
diff --git a/tests/Feature/Controllers/Json/BoxControllerTest.php b/tests/Feature/Controllers/Json/BoxControllerTest.php
index fa95af00a4..a4b6ba31b9 100644
--- a/tests/Feature/Controllers/Json/BoxControllerTest.php
+++ b/tests/Feature/Controllers/Json/BoxControllerTest.php
@@ -191,7 +191,7 @@ class BoxControllerTest extends TestCase
$this->mockDefaultSession();
$result = [
[
- 'currency' => TransactionCurrency::find(1),
+ 'currency' => $this->getEuro(),
'balance' => '3',
],
];
@@ -205,7 +205,7 @@ class BoxControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
- $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
+ $currencyRepos->shouldReceive('findNull')->andReturn($this->getEuro());
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1');
@@ -224,7 +224,7 @@ class BoxControllerTest extends TestCase
$this->mockDefaultSession();
$result = [
[
- 'currency' => TransactionCurrency::find(1),
+ 'currency' => $this->getEuro(),
'balance' => '3',
],
];
@@ -237,7 +237,7 @@ class BoxControllerTest extends TestCase
$netWorthHelper->shouldReceive('getNetWorthByCurrency')->once()->andReturn($result);
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
- $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
+ $currencyRepos->shouldReceive('findNull')->andReturn($this->getEuro());
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1');
@@ -261,7 +261,7 @@ class BoxControllerTest extends TestCase
$this->mockDefaultSession();
$result = [
[
- 'currency' => TransactionCurrency::find(1),
+ 'currency' => $this->getEuro(),
'balance' => '3',
],
];
@@ -274,7 +274,7 @@ class BoxControllerTest extends TestCase
$netWorthHelper->shouldReceive('getNetWorthByCurrency')->once()->andReturn($result);
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
- $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
+ $currencyRepos->shouldReceive('findNull')->andReturn($this->getEuro());
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1');
@@ -297,7 +297,7 @@ class BoxControllerTest extends TestCase
$this->mockDefaultSession();
$result = [
[
- 'currency' => TransactionCurrency::find(1),
+ 'currency' => $this->getEuro(),
'balance' => '3',
],
];
@@ -328,7 +328,7 @@ class BoxControllerTest extends TestCase
$this->mockDefaultSession();
$result = [
[
- 'currency' => TransactionCurrency::find(1),
+ 'currency' => $this->getEuro(),
'balance' => '3',
],
];
@@ -341,7 +341,7 @@ class BoxControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
- $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
+ $currencyRepos->shouldReceive('findNull')->andReturn($this->getEuro());
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('0');
@@ -360,7 +360,7 @@ class BoxControllerTest extends TestCase
$this->mockDefaultSession();
$result = [
[
- 'currency' => TransactionCurrency::find(1),
+ 'currency' => $this->getEuro(),
'balance' => '3',
],
];
@@ -375,7 +375,7 @@ class BoxControllerTest extends TestCase
$netWorthHelper->shouldReceive('getNetWorthByCurrency')->once()->andReturn($result);
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$account]));
- $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
+ $currencyRepos->shouldReceive('findNull')->andReturn($this->getEuro());
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1');
diff --git a/tests/Feature/Controllers/PiggyBankControllerTest.php b/tests/Feature/Controllers/PiggyBankControllerTest.php
index 2b88d32b08..2b9b8bf066 100644
--- a/tests/Feature/Controllers/PiggyBankControllerTest.php
+++ b/tests/Feature/Controllers/PiggyBankControllerTest.php
@@ -74,7 +74,7 @@ class PiggyBankControllerTest extends TestCase
$piggyBank = $this->getRandomPiggyBank();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn($this->getEuro())->atLeast()->once();
$piggyRepos->shouldReceive('getCurrentAmount')->andReturn('0');
@@ -102,7 +102,7 @@ class PiggyBankControllerTest extends TestCase
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$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($this->getEuro())->atLeast()->once();
$piggyRepos->shouldReceive('getCurrentAmount')->andReturn('0');
@@ -292,7 +292,7 @@ class PiggyBankControllerTest extends TestCase
$piggyBank = $this->getRandomPiggyBank();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn($this->getEuro())->atLeast()->once();
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
Preferences::shouldReceive('mark')->atLeast()->once();
@@ -322,7 +322,7 @@ class PiggyBankControllerTest extends TestCase
$piggyBank = $this->getRandomPiggyBank();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn($this->getEuro())->atLeast()->once();
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
@@ -349,7 +349,7 @@ class PiggyBankControllerTest extends TestCase
$piggyBank = $this->getRandomPiggyBank();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn($this->getEuro())->atLeast()->once();
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
Preferences::shouldReceive('mark')->atLeast()->once();
@@ -377,7 +377,7 @@ class PiggyBankControllerTest extends TestCase
$piggyBank = $this->getRandomPiggyBank();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn($this->getEuro())->atLeast()->once();
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
$repository->shouldReceive('canRemoveAmount')->once()->andReturn(false);
@@ -404,7 +404,7 @@ class PiggyBankControllerTest extends TestCase
$repetition = PiggyBankRepetition::first();
$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($this->getEuro())->atLeast()->once();
$piggyRepos->shouldReceive('getRepetition')->once()->andReturn($repetition);
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
@@ -428,7 +428,7 @@ class PiggyBankControllerTest extends TestCase
$piggyBank = $this->getRandomPiggyBank();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn($this->getEuro())->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('x');
diff --git a/tests/Feature/Controllers/Recurring/EditControllerTest.php b/tests/Feature/Controllers/Recurring/EditControllerTest.php
index 0df8300abf..1a145570aa 100644
--- a/tests/Feature/Controllers/Recurring/EditControllerTest.php
+++ b/tests/Feature/Controllers/Recurring/EditControllerTest.php
@@ -106,7 +106,7 @@ class EditControllerTest extends TestCase
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection)->once();
- //\Amount::shouldReceive('getDefaultCurrency')->andReturn(TransactionCurrency::find(1));
+ //\Amount::shouldReceive('getDefaultCurrency')->andReturn($this->getEuro());
$this->be($this->user());
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 82c362c887..7558819bea 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -596,7 +596,7 @@ abstract class TestCase extends BaseTestCase
*/
protected function getEuro(): TransactionCurrency
{
- return TransactionCurrency::find(1);
+ return TransactionCurrency::where('code', 'EUR')->first();
}
/**
diff --git a/tests/Unit/Factory/RecurrenceFactoryTest.php b/tests/Unit/Factory/RecurrenceFactoryTest.php
index e1c92bcb00..3998a655f2 100644
--- a/tests/Unit/Factory/RecurrenceFactoryTest.php
+++ b/tests/Unit/Factory/RecurrenceFactoryTest.php
@@ -415,7 +415,7 @@ class RecurrenceFactoryTest extends TestCase
$validator = $this->mock(AccountValidator::class);
// mock calls:
- Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
+ Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($this->getEuro())->once();
$piggyFactory->shouldReceive('setUser')->once();
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
@@ -521,7 +521,7 @@ class RecurrenceFactoryTest extends TestCase
$validator = $this->mock(AccountValidator::class);
// mock calls:
- Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
+ Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($this->getEuro())->once();
$piggyFactory->shouldReceive('setUser')->once();
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn(null);
@@ -625,7 +625,7 @@ class RecurrenceFactoryTest extends TestCase
$validator = $this->mock(AccountValidator::class);
// mock calls:
- Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
+ Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($this->getEuro())->once();
$piggyFactory->shouldReceive('setUser')->once();
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
@@ -730,7 +730,7 @@ class RecurrenceFactoryTest extends TestCase
$accountFactory = $this->mock(AccountFactory::class);
// mock calls:
- Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
+ Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($this->getEuro())->once();
$piggyFactory->shouldReceive('setUser')->once();
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
diff --git a/tests/Unit/Helpers/Report/NetWorthTest.php b/tests/Unit/Helpers/Report/NetWorthTest.php
index 11bb06099f..38a8b70165 100644
--- a/tests/Unit/Helpers/Report/NetWorthTest.php
+++ b/tests/Unit/Helpers/Report/NetWorthTest.php
@@ -69,7 +69,7 @@ class NetWorthTest extends TestCase
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
// mock calls to facades
- Amount::shouldReceive('getDefaultCurrencyByUser')->once()->andReturn(TransactionCurrency::find(1));
+ Amount::shouldReceive('getDefaultCurrencyByUser')->once()->andReturn($this->getEuro());
Steam::shouldReceive('balancesByAccounts')->once()->withAnyArgs()->andReturn($balanceInfo);
// mock other calls:
@@ -77,7 +77,7 @@ class NetWorthTest extends TestCase
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->times(2)->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_role'])->times(2)->andReturn('defaultAsset');
$currencyRepos->shouldReceive('setUser')->once();
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->times(1);
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn($this->getEuro())->times(1);
$helper = new NetWorth();
@@ -106,7 +106,7 @@ class NetWorthTest extends TestCase
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
// mock calls to facades
- Amount::shouldReceive('getDefaultCurrencyByUser')->once()->andReturn(TransactionCurrency::find(1));
+ Amount::shouldReceive('getDefaultCurrencyByUser')->once()->andReturn($this->getEuro());
Steam::shouldReceive('balancesByAccounts')->once()->withAnyArgs()->andReturn($balanceInfo);
// mock other calls:
@@ -114,7 +114,7 @@ class NetWorthTest extends TestCase
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->times(2)->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_role'])->times(2)->andReturn('defaultAsset', 'ccAsset');
$currencyRepos->shouldReceive('setUser')->once();
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->times(1);
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn($this->getEuro())->times(1);
$helper = new NetWorth();
diff --git a/tests/Unit/Transformers/AccountTransformerTest.php b/tests/Unit/Transformers/AccountTransformerTest.php
index 4f9eb6f776..afa89868a9 100644
--- a/tests/Unit/Transformers/AccountTransformerTest.php
+++ b/tests/Unit/Transformers/AccountTransformerTest.php
@@ -56,7 +56,7 @@ class AccountTransformerTest extends TestCase
{
// mock stuff and get object:
$account = $this->getRandomAsset();
- $euro = TransactionCurrency::find(1);
+ $euro = $this->getEuro();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$parameters = new ParameterBag;
@@ -72,9 +72,9 @@ class AccountTransformerTest extends TestCase
$accountRepos->shouldReceive('getNoteText')->andReturn('I am a note')->atLeast()->once();
// get all kinds of meta values:
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('defaultAsset')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_role'])->andReturn('defaultAsset')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1')->atLeast()->once();
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountNumber'])->andReturn('12345')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_number'])->andReturn('12345')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'BIC'])->andReturn('NL5X')->atLeast()->once();
// opening balance:
@@ -127,7 +127,7 @@ class AccountTransformerTest extends TestCase
{
// mock stuff and get object:
$account = $this->getRandomAsset();
- $euro = TransactionCurrency::find(1);
+ $euro = $this->getEuro();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$transformer = app(AccountTransformer::class);
@@ -140,9 +140,9 @@ class AccountTransformerTest extends TestCase
$accountRepos->shouldReceive('getNoteText')->andReturn('I am a note')->atLeast()->once();
// get all kinds of meta values:
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('defaultAsset')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_role'])->andReturn('defaultAsset')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1')->atLeast()->once();
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountNumber'])->andReturn('12345')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_number'])->andReturn('12345')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'BIC'])->andReturn('NL5X')->atLeast()->once();
// opening balance:
@@ -195,7 +195,7 @@ class AccountTransformerTest extends TestCase
{
// mock stuff and get object:
$account = $this->getRandomAsset();
- $euro = TransactionCurrency::find(1);
+ $euro = $this->getEuro();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$transformer = app(AccountTransformer::class);
@@ -208,14 +208,14 @@ class AccountTransformerTest extends TestCase
$accountRepos->shouldReceive('getNoteText')->andReturn('I am a note')->atLeast()->once();
// get all kinds of meta values:
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_role'])->andReturn('ccAsset')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1')->atLeast()->once();
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountNumber'])->andReturn('12345')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_number'])->andReturn('12345')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'BIC'])->andReturn('NL5X')->atLeast()->once();
// credit card fields:
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'ccType'])->andReturn('monthlyFull')->atLeast()->once();
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'ccMonthlyPaymentDate'])->andReturn('2018-01-01')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'cc_type'])->andReturn('monthlyFull')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'cc_monthly_payment_date'])->andReturn('2018-01-01')->atLeast()->once();
// opening balance:
@@ -270,7 +270,7 @@ class AccountTransformerTest extends TestCase
{
// mock stuff and get object:
$account = $this->getRandomAsset();
- $euro = TransactionCurrency::find(1);
+ $euro = $this->getEuro();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$transformer = app(AccountTransformer::class);
@@ -283,9 +283,9 @@ class AccountTransformerTest extends TestCase
$accountRepos->shouldReceive('getNoteText')->andReturn('I am a note')->atLeast()->once();
// get all kinds of meta values:
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_role'])->andReturn('')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1')->atLeast()->once();
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountNumber'])->andReturn('12345')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_number'])->andReturn('12345')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'BIC'])->andReturn('NL5X')->atLeast()->once();
// data for liability
@@ -344,7 +344,7 @@ class AccountTransformerTest extends TestCase
{
// mock stuff and get object:
$account = $this->getRandomExpense();
- $euro = TransactionCurrency::find(1);
+ $euro = $this->getEuro();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$transformer = app(AccountTransformer::class);
@@ -357,9 +357,9 @@ class AccountTransformerTest extends TestCase
$accountRepos->shouldReceive('getNoteText')->andReturn('I am a note')->atLeast()->once();
// get all kinds of meta values:
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('defaultAsset')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_role'])->andReturn('defaultAsset')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1')->atLeast()->once();
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountNumber'])->andReturn('12345')->atLeast()->once();
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'account_number'])->andReturn('12345')->atLeast()->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'BIC'])->andReturn('NL5X')->atLeast()->once();
// steam is also called for the account balance:
diff --git a/tests/Unit/Transformers/AvailableBudgetTransformerTest.php b/tests/Unit/Transformers/AvailableBudgetTransformerTest.php
index a27d73eb2e..baf9752ac0 100644
--- a/tests/Unit/Transformers/AvailableBudgetTransformerTest.php
+++ b/tests/Unit/Transformers/AvailableBudgetTransformerTest.php
@@ -23,8 +23,11 @@ declare(strict_types=1);
namespace Tests\Unit\Transformers;
+use Carbon\Carbon;
use FireflyIII\Models\AvailableBudget;
+use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Transformers\AvailableBudgetTransformer;
+use Illuminate\Support\Collection;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
use Tests\TestCase;
@@ -50,6 +53,9 @@ class AvailableBudgetTransformerTest extends TestCase
*/
public function testBasic(): void
{
+ $repository = $this->mock(BudgetRepositoryInterface::class);
+ $repository->shouldReceive('setUser')->atLeast()->once();
+
/** @var AvailableBudget $availableBudget */
$availableBudget = AvailableBudget::first();
$currency = $availableBudget->transactionCurrency;
@@ -63,7 +69,55 @@ class AvailableBudgetTransformerTest extends TestCase
$this->assertEquals($currency->id, $result['currency_id']);
$this->assertEquals($availableBudget->start_date->format('Y-m-d'), $result['start']);
$this->assertEquals(round($availableBudget->amount, 2), $result['amount']);
+ }
+ /**
+ * Test basic transformer
+ *
+ * @covers \FireflyIII\Transformers\AvailableBudgetTransformer
+ */
+ public function testBasicDates(): void
+ {
+ $euro = $this->getEuro();
+ $data= [
+ [
+ 'currency_id' => $euro->id,
+ 'currency_code' => $euro->code,
+ 'currency_symbol' => $euro->symbol,
+ 'currency_decimal_places' => $euro->decimal_places,
+ 'amount' => '12.45',
+ ]
+ ];
+
+
+ $budget = $this->getRandomBudget();
+ $repository = $this->mock(BudgetRepositoryInterface::class);
+ $repository->shouldReceive('setUser')->atLeast()->once();
+ $repository->shouldReceive('getActiveBudgets')->atLeast()->once()->andReturn(new Collection([$budget]));
+ $repository->shouldReceive('spentInPeriodMc')->atLeast()->once()->andReturn($data);
+ $repository->shouldReceive('spentInPeriodWoBudgetMc')->atLeast()->once()->andReturn($data);
+
+ // spentInPeriodWoBudgetMc
+
+ $start = new Carbon;
+ $end = new Carbon;
+ $parameterBag = new ParameterBag;
+ $parameterBag->set('start', $start);
+ $parameterBag->set('end', $end);
+
+ /** @var AvailableBudget $availableBudget */
+ $availableBudget = AvailableBudget::first();
+ $currency = $availableBudget->transactionCurrency;
+ // make transformer
+ $transformer = app(AvailableBudgetTransformer::class);
+ $transformer->setParameters($parameterBag);
+ $result = $transformer->transform($availableBudget);
+
+ // test results
+ $this->assertEquals($availableBudget->id, $result['id']);
+ $this->assertEquals($currency->id, $result['currency_id']);
+ $this->assertEquals($availableBudget->start_date->format('Y-m-d'), $result['start']);
+ $this->assertEquals(round($availableBudget->amount, 2), $result['amount']);
}
}
diff --git a/tests/Unit/Transformers/CategoryTransformerTest.php b/tests/Unit/Transformers/CategoryTransformerTest.php
index cad2e9988d..9a02261987 100644
--- a/tests/Unit/Transformers/CategoryTransformerTest.php
+++ b/tests/Unit/Transformers/CategoryTransformerTest.php
@@ -87,16 +87,16 @@ class CategoryTransformerTest extends TestCase
// mock some objects for the spent/earned lists.
$expense = new Transaction;
$expense->transaction_currency_code = 'EUR';
- $expense->transactionCurrency = TransactionCurrency::find(1);
+ $expense->transactionCurrency = $this->getEuro();
$expense->transaction_amount = '-100';
$income = new Transaction;
$income->transaction_currency_code = 'EUR';
- $income->transactionCurrency = TransactionCurrency::find(1);
+ $income->transactionCurrency = $this->getEuro();
$income->transaction_amount = '100';
- $incomeCollection = new Collection([$income]);
- $expenseCollection = new Collection([$expense]);
+ $incomeCollection = [$income];
+ $expenseCollection = [$expense];
$repository->shouldReceive('spentInPeriodCollection')->atLeast()->once()->andReturn($expenseCollection);
$repository->shouldReceive('earnedInPeriodCollection')->atLeast()->once()->andReturn($incomeCollection);
diff --git a/tests/Unit/Transformers/PiggyBankEventTransformerTest.php b/tests/Unit/Transformers/PiggyBankEventTransformerTest.php
index 6cbe252399..f533ce0c45 100644
--- a/tests/Unit/Transformers/PiggyBankEventTransformerTest.php
+++ b/tests/Unit/Transformers/PiggyBankEventTransformerTest.php
@@ -56,9 +56,6 @@ class PiggyBankEventTransformerTest extends TestCase
*/
public function testBasic(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
// repositories
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
@@ -70,7 +67,7 @@ class PiggyBankEventTransformerTest extends TestCase
// mock calls:
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->atLeast()->once()->andReturn(1);
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->atLeast()->once()->andReturn(TransactionCurrency::find(1));
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->atLeast()->once()->andReturn($this->getEuro());
$piggyRepos->shouldReceive('getTransactionWithEvent')->atLeast()->once()->andReturn(123);
$event = PiggyBankEvent::first();
@@ -91,9 +88,6 @@ class PiggyBankEventTransformerTest extends TestCase
*/
public function testNoCurrency(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
// repositories
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
@@ -108,7 +102,7 @@ class PiggyBankEventTransformerTest extends TestCase
$currencyRepos->shouldReceive('findNull')->withArgs([1])->atLeast()->once()->andReturn(null);
$piggyRepos->shouldReceive('getTransactionWithEvent')->atLeast()->once()->andReturn(123);
- Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->atLeast()->once();
+ Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($this->getEuro())->atLeast()->once();
$event = PiggyBankEvent::first();
$transformer = app(PiggyBankEventTransformer::class);
diff --git a/tests/Unit/Transformers/PiggyBankTransformerTest.php b/tests/Unit/Transformers/PiggyBankTransformerTest.php
index dac184e1ac..d66130a286 100644
--- a/tests/Unit/Transformers/PiggyBankTransformerTest.php
+++ b/tests/Unit/Transformers/PiggyBankTransformerTest.php
@@ -68,7 +68,7 @@ class PiggyBankTransformerTest extends TestCase
// return a currency
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->atLeast()->once()->andReturn('1');
- $currencyRepos->shouldReceive('findNull')->withArgs([1])->atLeast()->once()->andReturn(TransactionCurrency::find(1));
+ $currencyRepos->shouldReceive('findNull')->withArgs([1])->atLeast()->once()->andReturn($this->getEuro());
// get a note
$piggyRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('I am a note.');
@@ -109,7 +109,7 @@ class PiggyBankTransformerTest extends TestCase
// return a currency
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->atLeast()->once()->andReturn('1');
$currencyRepos->shouldReceive('findNull')->withArgs([1])->atLeast()->once()->andReturn(null);
- Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn(TransactionCurrency::find(1));
+ Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($this->getEuro());
// get a note
$piggyRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('I am a note.');
diff --git a/tests/Unit/Transformers/RecurrenceTransformerTest.php b/tests/Unit/Transformers/RecurrenceTransformerTest.php
index 5d86eccc76..efe64b7774 100644
--- a/tests/Unit/Transformers/RecurrenceTransformerTest.php
+++ b/tests/Unit/Transformers/RecurrenceTransformerTest.php
@@ -60,9 +60,6 @@ class RecurrenceTransformerTest extends TestCase
*/
public function testBasic(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
$recurrenceRepos = $this->mock(RecurringRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
diff --git a/tests/Unit/Transformers/TransactionLinkTransformerTest.php b/tests/Unit/Transformers/TransactionLinkTransformerTest.php
index 8f96d96b2e..1ce10aae4b 100644
--- a/tests/Unit/Transformers/TransactionLinkTransformerTest.php
+++ b/tests/Unit/Transformers/TransactionLinkTransformerTest.php
@@ -42,9 +42,6 @@ class TransactionLinkTransformerTest extends TestCase
*/
public function testBasic(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
$repository = $this->mock(JournalRepositoryInterface::class);
$repository->shouldReceive('getLinkNoteText')->atLeast()->once()->andReturn('abc');
diff --git a/tests/Unit/Transformers/TransactionTransformerTest.php b/tests/Unit/Transformers/TransactionTransformerTest.php
deleted file mode 100644
index 15459b6a98..0000000000
--- a/tests/Unit/Transformers/TransactionTransformerTest.php
+++ /dev/null
@@ -1,339 +0,0 @@
-.
- */
-
-declare(strict_types=1);
-
-namespace Tests\Unit\Transformers;
-
-
-use Carbon\Carbon;
-use FireflyIII\Models\Transaction;
-use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
-use FireflyIII\Transformers\TransactionTransformer;
-use Mockery;
-use Symfony\Component\HttpFoundation\ParameterBag;
-use Tests\TestCase;
-
-/**
- * Class TransactionTransformerTest
- */
-class TransactionTransformerTest extends TestCase
-{
-
- /**
- * Test basic transaction transformer.
- *
- * @covers \FireflyIII\Transformers\TransactionTransformer
- */
- public function testBasic(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
- $repository = $this->mock(JournalRepositoryInterface::class);
- $transformer = app(TransactionTransformer::class);
- $transformer->setParameters(new ParameterBag());
-
- $repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('getNoteText')->once()->andReturn('Notes');
-
- // all meta fields:
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-cc'])->andReturn('a')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ct-op'])->andReturn('b')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ct-ud'])->andReturn('c')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-db'])->andReturn('d')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-country'])->andReturn('e')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ep'])->andReturn('f')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ci'])->andReturn('g')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-batch-id'])->andReturn('h')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'internal_reference'])->andReturn('h')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'bunq_payment_id'])->andReturn('12345')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'importHashV2'])->andReturn('abcdef')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'recurrence_id'])->andReturn('5')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'external_id'])->andReturn('1')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'original-source'])->andReturn('test')->atLeast()->once();
-
- // all meta dates.
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'interest_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'book_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'process_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'due_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'payment_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'invoice_date'])->andReturn('2018-01-01')->atLeast()->once();
-
- // get tags
- $repository->shouldReceive('getTags')->once()->andReturn(['a', 'b']);
-
- // create fake transaction object:
- $transaction = new Transaction;
- $journal = TransactionJournal::find(1);
-
- // fill transaction with details
- $transaction->transactionJournal = $journal;
- $transaction->created_at = new Carbon;
- $transaction->updated_at = new Carbon;
- $transaction->description = '';
- $transaction->transaction_description = '';
- $transaction->date = new Carbon;
- $transaction->identifier = 0;
- $transaction->journal_id = 1;
- $transaction->reconciled = false;
- $transaction->transaction_amount = '123.456';
- $transaction->transaction_currency_id = 1;
- $transaction->transaction_currency_code = 'EUR';
- $transaction->transaction_currency_symbol = 'x';
- $transaction->transaction_currency_dp = 2;
- $transaction->bill_id = 1;
- $transaction->bill_name = 'Bill';
- $transaction->transaction_type_type = 'Withdrawal';
- $transaction->transaction_budget_id = 1;
- $transaction->transaction_budget_name = 'X';
- $transaction->transaction_category_id = 2;
- $transaction->transaction_category_name = 'xab';
-
- // account info (for a withdrawal):
- $transaction->account_id = 1;
- $transaction->account_name = 'Some source';
- $transaction->account_iban = 'IBAN';
- $transaction->account_type = 'Asset account';
- $transaction->opposing_account_id = 3;
- $transaction->opposing_account_name = 'Some destination';
- $transaction->opposing_account_iban = 'IBAN2';
- $transaction->opposing_account_type = 'Expense';
-
-
- // next test: foreign currency info.
-
-
- $transformer = app(TransactionTransformer::class);
- $transformer->setParameters(new ParameterBag);
- $result = $transformer->transform($transaction);
- $this->assertEquals('Some source', $result['source_name']);
-
- }
-
- /**
- * Test deposit. Budget should be null, despite the link.
- *
- * @covers \FireflyIII\Transformers\TransactionTransformer
- */
- public function testDeposit(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
- $repository = $this->mock(JournalRepositoryInterface::class);
- $transformer = app(TransactionTransformer::class);
- $transformer->setParameters(new ParameterBag());
-
- $repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('getNoteText')->once()->andReturn('Notes');
-
- // all meta fields:
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-cc'])->andReturn('a')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ct-op'])->andReturn('b')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ct-ud'])->andReturn('c')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-db'])->andReturn('d')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-country'])->andReturn('e')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ep'])->andReturn('f')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ci'])->andReturn('g')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-batch-id'])->andReturn('h')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'internal_reference'])->andReturn('h')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'bunq_payment_id'])->andReturn('12345')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'importHashV2'])->andReturn('abcdef')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'recurrence_id'])->andReturn('5')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'external_id'])->andReturn('1')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'original-source'])->andReturn('test')->atLeast()->once();
-
- // all meta dates.
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'interest_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'book_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'process_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'due_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'payment_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'invoice_date'])->andReturn('2018-01-01')->atLeast()->once();
-
- // get tags
- $repository->shouldReceive('getTags')->once()->andReturn(['a', 'b']);
-
- // create fake transaction object:
- $transaction = new Transaction;
- $journal = TransactionJournal::find(1);
-
- // fill transaction with details
- $transaction->transactionJournal = $journal;
- $transaction->created_at = new Carbon;
- $transaction->updated_at = new Carbon;
- $transaction->description = 'Some description';
- $transaction->transaction_description = 'Some expanded description';
- $transaction->date = new Carbon;
- $transaction->identifier = 0;
- $transaction->journal_id = 1;
- $transaction->reconciled = false;
- $transaction->transaction_amount = '123.456';
- $transaction->transaction_currency_id = 1;
- $transaction->transaction_currency_code = 'EUR';
- $transaction->transaction_currency_symbol = 'x';
- $transaction->transaction_currency_dp = 2;
- $transaction->bill_id = 1;
- $transaction->bill_name = 'Bill';
- $transaction->transaction_type_type = 'Deposit';
- $transaction->transaction_budget_id = 1;
- $transaction->transaction_budget_name = 'X';
- $transaction->transaction_category_id = 2;
- $transaction->transaction_category_name = 'xab';
-
- // foreign amount info:
- $transaction->transaction_foreign_amount = '456.789';
- $transaction->foreign_currency_dp = 2;
- $transaction->foreign_currency_code = 'USD';
- $transaction->foreign_currency_symbol = 'x';
-
- // account info (for a withdrawal):
- $transaction->account_id = 1;
- $transaction->account_name = 'Some source';
- $transaction->account_iban = 'IBAN';
- $transaction->account_type = 'Asset account';
- $transaction->opposing_account_id = 3;
- $transaction->opposing_account_name = 'Some destination';
- $transaction->opposing_account_iban = 'IBAN2';
- $transaction->opposing_account_type = 'Expense';
-
-
- // next test: foreign currency info.
-
-
- $transformer = app(TransactionTransformer::class);
- $transformer->setParameters(new ParameterBag);
- $result = $transformer->transform($transaction);
- $this->assertEquals('Some destination', $result['source_name']);
- $this->assertEquals(456.79, $result['foreign_amount']);
- $this->assertEquals('Some expanded description', $result['transaction_description']);
- $this->assertEquals('Some description', $result['journal_description']);
- $this->assertEquals('Some expanded description (Some description)', $result['description']);
- $this->assertNull($result['budget_id']);
- $this->assertNull($result['budget_name']);
- }
-
- /**
- * Test transformer with foreign amount info.
- *
- * @covers \FireflyIII\Transformers\TransactionTransformer
- */
- public function testForeign(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
- $repository = $this->mock(JournalRepositoryInterface::class);
- $transformer = app(TransactionTransformer::class);
- $transformer->setParameters(new ParameterBag());
-
- $repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('getNoteText')->once()->andReturn('Notes');
-
- // all meta fields:
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-cc'])->andReturn('a')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ct-op'])->andReturn('b')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ct-ud'])->andReturn('c')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-db'])->andReturn('d')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-country'])->andReturn('e')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ep'])->andReturn('f')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-ci'])->andReturn('g')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'sepa-batch-id'])->andReturn('h')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'internal_reference'])->andReturn('h')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'bunq_payment_id'])->andReturn('12345')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'importHashV2'])->andReturn('abcdef')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'recurrence_id'])->andReturn('5')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'external_id'])->andReturn('1')->atLeast()->once();
- $repository->shouldReceive('getMetaField')->withArgs([Mockery::any(), 'original-source'])->andReturn('test')->atLeast()->once();
-
- // all meta dates.
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'interest_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'book_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'process_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'due_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'payment_date'])->andReturn('2018-01-01')->atLeast()->once();
- $repository->shouldReceive('getMetaDateString')->withArgs([Mockery::any(), 'invoice_date'])->andReturn('2018-01-01')->atLeast()->once();
-
- // get tags
- $repository->shouldReceive('getTags')->once()->andReturn(['a', 'b']);
-
- // create fake transaction object:
- $transaction = new Transaction;
- $journal = TransactionJournal::find(1);
-
- // fill transaction with details
- $transaction->transactionJournal = $journal;
- $transaction->created_at = new Carbon;
- $transaction->updated_at = new Carbon;
- $transaction->description = 'Some description';
- $transaction->transaction_description = 'Some expanded description';
- $transaction->date = new Carbon;
- $transaction->identifier = 0;
- $transaction->journal_id = 1;
- $transaction->reconciled = false;
- $transaction->transaction_amount = '123.456';
- $transaction->transaction_currency_id = 1;
- $transaction->transaction_currency_code = 'EUR';
- $transaction->transaction_currency_symbol = 'x';
- $transaction->transaction_currency_dp = 2;
- $transaction->bill_id = 1;
- $transaction->bill_name = 'Bill';
- $transaction->transaction_type_type = 'Withdrawal';
- $transaction->transaction_budget_id = 1;
- $transaction->transaction_budget_name = 'X';
- $transaction->transaction_category_id = 2;
- $transaction->transaction_category_name = 'xab';
-
- // foreign amount info:
- $transaction->transaction_foreign_amount = '456.789';
- $transaction->foreign_currency_dp = 2;
- $transaction->foreign_currency_code = 'USD';
- $transaction->foreign_currency_symbol = 'x';
-
- // account info (for a withdrawal):
- $transaction->account_id = 1;
- $transaction->account_name = 'Some source';
- $transaction->account_iban = 'IBAN';
- $transaction->account_type = 'Asset account';
- $transaction->opposing_account_id = 3;
- $transaction->opposing_account_name = 'Some destination';
- $transaction->opposing_account_iban = 'IBAN2';
- $transaction->opposing_account_type = 'Expense';
-
-
- // next test: foreign currency info.
-
-
- $transformer = app(TransactionTransformer::class);
- $transformer->setParameters(new ParameterBag);
- $result = $transformer->transform($transaction);
- $this->assertEquals('Some source', $result['source_name']);
- $this->assertEquals(456.79, $result['foreign_amount']);
- $this->assertEquals('Some expanded description', $result['transaction_description']);
- $this->assertEquals('Some description', $result['journal_description']);
- $this->assertEquals('Some expanded description (Some description)', $result['description']);
- }
-
-
-}