Skip to content

Firefly III: a personal finances manager

Fix test for coverage.

James Cole7d88d3555606
diff --git a/tests/Unit/Support/Import/Routine/Spectre/StageImportDataHandlerTest.php b/tests/Unit/Support/Import/Routine/Spectre/StageImportDataHandlerTest.php
index 4f6b157f32..a64cfcfb31 100644
--- a/tests/Unit/Support/Import/Routine/Spectre/StageImportDataHandlerTest.php
+++ b/tests/Unit/Support/Import/Routine/Spectre/StageImportDataHandlerTest.php
@@ -139,7 +139,7 @@ class StageImportDataHandlerTest extends TestCase
'date' => $today->format('Y-m-d'),
'tags' => ['mode', 'active'],
'user' => $job->user_id,
- 'notes' => "Imported from \"Fake Spectre Account\" \npayee: " . $op1." \n",
+ 'notes' => "Imported from \"Fake Spectre Account\" \npayee: " . $op1 . " \n",
'external_id' => '1',
// journal data:
'description' => $transactions[0]->getDescription(),
@@ -238,9 +238,11 @@ class StageImportDataHandlerTest extends TestCase
}
/**
+ * Also has empty local account.
+ *
* @covers \FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler
*/
- public function testRunWithDuplication(): void
+ public function testRunForeignCurrency(): void
{
// needs to be a full spectre account this time.
$spectreAccount = new SpectreAccount(
@@ -274,7 +276,8 @@ class StageImportDataHandlerTest extends TestCase
'category' => 'some-category',
'duplicated' => true,
'extra' => [
- 'payee' => $op1,
+ 'payee' => $op1,
+ 'original_amount' => -200.01,
],
'account_id' => 1234,
'created_at' => $today->toW3cString(),
@@ -293,8 +296,9 @@ class StageImportDataHandlerTest extends TestCase
'category' => 'some-other-category',
'duplicated' => false,
'extra' => [
- 'payee' => $op2,
- 'customer_category_name' => 'cat-name'
+ 'payee' => $op2,
+ 'customer_category_name' => 'cat-name',
+ 'original_currency_code' => 'USD',
],
'account_id' => 1234,
'created_at' => $today->toW3cString(),
@@ -318,6 +322,7 @@ class StageImportDataHandlerTest extends TestCase
'accounts' => [$spectreAccount->toArray()],
'account_mapping' => [
1234 => 322,
+ 5678 => 0,
],
];
$job->save();
@@ -333,9 +338,9 @@ class StageImportDataHandlerTest extends TestCase
0 => [
'type' => 'withdrawal',
'date' => $today->format('Y-m-d'),
- 'tags' => ['mode', 'active','possibly-duplicated'],
+ 'tags' => ['mode', 'active', 'possibly-duplicated'],
'user' => $job->user_id,
- 'notes' => "Imported from \"Fake Spectre Account\" \npayee: " . $op1." \n",
+ 'notes' => "Imported from \"Fake Spectre Account\" \npayee: " . $op1 . " \n",
'external_id' => '1',
// journal data:
'description' => $transactions[0]->getDescription(),
@@ -361,7 +366,7 @@ class StageImportDataHandlerTest extends TestCase
'destination_name' => null,
'foreign_currency_id' => null,
'foreign_currency_code' => null,
- 'foreign_amount' => null,
+ 'foreign_amount' => '-200.01',
'reconciled' => false,
'identifier' => 0,
],
@@ -370,7 +375,7 @@ class StageImportDataHandlerTest extends TestCase
1 => [
'type' => 'deposit',
'date' => $today->format('Y-m-d'),
- 'tags' => ['mode', 'active','cat-name'],
+ 'tags' => ['mode', 'active', 'cat-name'],
'user' => $job->user_id,
'notes' => "Imported from \"Fake Spectre Account\" \npayee: " . $op2 . " \n",
'external_id' => '2',
@@ -397,7 +402,7 @@ class StageImportDataHandlerTest extends TestCase
'destination_id' => $account->id,
'destination_name' => null,
'foreign_currency_id' => null,
- 'foreign_currency_code' => null,
+ 'foreign_currency_code' => 'USD',
'foreign_amount' => null,
'reconciled' => false,
'identifier' => 0,
@@ -433,11 +438,10 @@ class StageImportDataHandlerTest extends TestCase
}
}
-
/**
* @covers \FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler
*/
- public function testRunForeignCurrency(): void
+ public function testRunWithDuplication(): void
{
// needs to be a full spectre account this time.
$spectreAccount = new SpectreAccount(
@@ -472,7 +476,6 @@ class StageImportDataHandlerTest extends TestCase
'duplicated' => true,
'extra' => [
'payee' => $op1,
- 'original_amount' => -200.01
],
'account_id' => 1234,
'created_at' => $today->toW3cString(),
@@ -491,9 +494,8 @@ class StageImportDataHandlerTest extends TestCase
'category' => 'some-other-category',
'duplicated' => false,
'extra' => [
- 'payee' => $op2,
+ 'payee' => $op2,
'customer_category_name' => 'cat-name',
- 'original_currency_code' => 'USD',
],
'account_id' => 1234,
'created_at' => $today->toW3cString(),
@@ -532,9 +534,9 @@ class StageImportDataHandlerTest extends TestCase
0 => [
'type' => 'withdrawal',
'date' => $today->format('Y-m-d'),
- 'tags' => ['mode', 'active','possibly-duplicated'],
+ 'tags' => ['mode', 'active', 'possibly-duplicated'],
'user' => $job->user_id,
- 'notes' => "Imported from \"Fake Spectre Account\" \npayee: " . $op1." \n",
+ 'notes' => "Imported from \"Fake Spectre Account\" \npayee: " . $op1 . " \n",
'external_id' => '1',
// journal data:
'description' => $transactions[0]->getDescription(),
@@ -560,7 +562,7 @@ class StageImportDataHandlerTest extends TestCase
'destination_name' => null,
'foreign_currency_id' => null,
'foreign_currency_code' => null,
- 'foreign_amount' => '-200.01',
+ 'foreign_amount' => null,
'reconciled' => false,
'identifier' => 0,
],
@@ -569,7 +571,7 @@ class StageImportDataHandlerTest extends TestCase
1 => [
'type' => 'deposit',
'date' => $today->format('Y-m-d'),
- 'tags' => ['mode', 'active','cat-name'],
+ 'tags' => ['mode', 'active', 'cat-name'],
'user' => $job->user_id,
'notes' => "Imported from \"Fake Spectre Account\" \npayee: " . $op2 . " \n",
'external_id' => '2',
@@ -596,7 +598,7 @@ class StageImportDataHandlerTest extends TestCase
'destination_id' => $account->id,
'destination_name' => null,
'foreign_currency_id' => null,
- 'foreign_currency_code' => 'USD',
+ 'foreign_currency_code' => null,
'foreign_amount' => null,
'reconciled' => false,
'identifier' => 0,