Skip to content

Firefly III: a personal finances manager

Fixed tests to account for issue fixed by #1097

James Cole7fa937e80b8a
diff --git a/app/Import/Mapper/AssetAccountIbans.php b/app/Import/Mapper/AssetAccountIbans.php
index 634280ce32..cfbdf46437 100644
--- a/app/Import/Mapper/AssetAccountIbans.php
+++ b/app/Import/Mapper/AssetAccountIbans.php
@@ -53,8 +53,9 @@ class AssetAccountIbans implements MapperInterface
$list[$accountId] = $account->name;
}
}
- $list = array_merge($topList, $list);
- $list = array_merge([0 => trans('import.map_do_not_map')], $list);
+ $list = $topList + $list;
+ asort($list);
+ $list = [0 => trans('import.map_do_not_map')] + $list;
return $list;
}
diff --git a/app/Import/Mapper/AssetAccounts.php b/app/Import/Mapper/AssetAccounts.php
index 1a3e114e50..9344cfb522 100644
--- a/app/Import/Mapper/AssetAccounts.php
+++ b/app/Import/Mapper/AssetAccounts.php
@@ -51,7 +51,8 @@ class AssetAccounts implements MapperInterface
}
$list[$accountId] = $name;
}
- $list = array_merge([0 => trans('import.map_do_not_map')], $list);
+ asort($list);
+ $list = [0 => trans('import.map_do_not_map')] + $list;
return $list;
}
diff --git a/app/Import/Mapper/Bills.php b/app/Import/Mapper/Bills.php
index 6355fcc42e..bea7a2b3ff 100644
--- a/app/Import/Mapper/Bills.php
+++ b/app/Import/Mapper/Bills.php
@@ -45,7 +45,8 @@ class Bills implements MapperInterface
$billId = intval($bill->id);
$list[$billId] = $bill->name . ' [' . $bill->match . ']';
}
- $list = array_merge([0 => trans('import.map_do_not_map')], $list);
+ asort($list);
+ $list = [0 => trans('import.map_do_not_map')] + $list;
return $list;
}
diff --git a/app/Import/Mapper/Budgets.php b/app/Import/Mapper/Budgets.php
index 123233444a..119e844be3 100644
--- a/app/Import/Mapper/Budgets.php
+++ b/app/Import/Mapper/Budgets.php
@@ -45,7 +45,8 @@ class Budgets implements MapperInterface
$budgetId = intval($budget->id);
$list[$budgetId] = $budget->name;
}
- $list = array_merge([0 => trans('import.map_do_not_map')], $list);
+ asort($list);
+ $list = [0 => trans('import.map_do_not_map')] + $list;
return $list;
}
diff --git a/app/Import/Mapper/Categories.php b/app/Import/Mapper/Categories.php
index 4c34da3771..21963f8eaf 100644
--- a/app/Import/Mapper/Categories.php
+++ b/app/Import/Mapper/Categories.php
@@ -45,7 +45,8 @@ class Categories implements MapperInterface
$categoryId = intval($category->id);
$list[$categoryId] = $category->name;
}
- $list = array_merge([0 => trans('import.map_do_not_map')], $list);
+ asort($list);
+ $list = [0 => trans('import.map_do_not_map')] + $list;
return $list;
}
diff --git a/app/Import/Mapper/OpposingAccountIbans.php b/app/Import/Mapper/OpposingAccountIbans.php
index cb167e0f62..efddc090b4 100644
--- a/app/Import/Mapper/OpposingAccountIbans.php
+++ b/app/Import/Mapper/OpposingAccountIbans.php
@@ -59,8 +59,9 @@ class OpposingAccountIbans implements MapperInterface
$list[$accountId] = $account->name;
}
}
- $list = array_merge($topList, $list);
- $list = array_merge([0 => trans('import.map_do_not_map')], $list);
+ $list = $topList + $list;
+ asort($list);
+ $list = [0 => trans('import.map_do_not_map')] + $list;
return $list;
}
diff --git a/app/Import/Mapper/OpposingAccounts.php b/app/Import/Mapper/OpposingAccounts.php
index dcead219f5..e451ace5eb 100644
--- a/app/Import/Mapper/OpposingAccounts.php
+++ b/app/Import/Mapper/OpposingAccounts.php
@@ -57,7 +57,8 @@ class OpposingAccounts implements MapperInterface
}
$list[$accountId] = $name;
}
- $list = ["0" => trans('import.map_do_not_map')] + $list;
+ asort($list);
+ $list = [0 => trans('import.map_do_not_map')] + $list;
return $list;
}
diff --git a/app/Import/Mapper/Tags.php b/app/Import/Mapper/Tags.php
index f8be4a253e..68536a86b7 100644
--- a/app/Import/Mapper/Tags.php
+++ b/app/Import/Mapper/Tags.php
@@ -45,7 +45,8 @@ class Tags implements MapperInterface
$tagId = intval($tag->id);
$list[$tagId] = $tag->tag;
}
- $list = array_merge([0 => trans('import.map_do_not_map')], $list);
+ asort($list);
+ $list = [0 => trans('import.map_do_not_map')] + $list;
return $list;
}
diff --git a/app/Import/Mapper/TransactionCurrencies.php b/app/Import/Mapper/TransactionCurrencies.php
index 4dcbd44296..7e81f4a8c8 100644
--- a/app/Import/Mapper/TransactionCurrencies.php
+++ b/app/Import/Mapper/TransactionCurrencies.php
@@ -42,8 +42,9 @@ class TransactionCurrencies implements MapperInterface
$currencyId = intval($currency->id);
$list[$currencyId] = $currency->name . ' (' . $currency->code . ')';
}
+ asort($list);
- $list = array_merge([0 => trans('import.map_do_not_map')], $list);
+ $list = [0 => trans('import.map_do_not_map')] + $list;
return $list;
}
diff --git a/tests/Unit/Import/Mapper/AssetAccountIbansTest.php b/tests/Unit/Import/Mapper/AssetAccountIbansTest.php
index dab4138175..aea75c48ac 100644
--- a/tests/Unit/Import/Mapper/AssetAccountIbansTest.php
+++ b/tests/Unit/Import/Mapper/AssetAccountIbansTest.php
@@ -41,11 +41,11 @@ class AssetAccountIbansTest extends TestCase
public function testGetMapBasic()
{
$one = new Account;
- $one->id = 1;
+ $one->id = 17;
$one->name = 'Something';
$one->iban = 'IBAN';
$two = new Account;
- $two->id = 2;
+ $two->id = 53;
$two->name = 'Else';
$collection = new Collection([$one, $two]);
@@ -58,8 +58,8 @@ class AssetAccountIbansTest extends TestCase
// assert this is what the result looks like:
$result = [
0 => strval(trans('import.map_do_not_map')),
- 1 => 'IBAN (Something)',
- 2 => 'Else',
+ 53 => 'Else',
+ 17 => 'IBAN (Something)',
];
$this->assertEquals($result, $mapping);
}
diff --git a/tests/Unit/Import/Mapper/AssetAccountsTest.php b/tests/Unit/Import/Mapper/AssetAccountsTest.php
index 0b1cec1e39..f4ae748fd4 100644
--- a/tests/Unit/Import/Mapper/AssetAccountsTest.php
+++ b/tests/Unit/Import/Mapper/AssetAccountsTest.php
@@ -41,11 +41,11 @@ class AssetAccountsTest extends TestCase
public function testGetMapBasic()
{
$one = new Account;
- $one->id = 1;
+ $one->id = 23;
$one->name = 'Something';
$one->iban = 'IBAN';
$two = new Account;
- $two->id = 2;
+ $two->id = 19;
$two->name = 'Else';
$collection = new Collection([$one, $two]);
@@ -57,9 +57,10 @@ class AssetAccountsTest extends TestCase
$this->assertCount(3, $mapping);
// assert this is what the result looks like:
$result = [
- 0 => strval(trans('import.map_do_not_map')),
- 1 => 'Something (IBAN)',
- 2 => 'Else',
+ 0 => strval(trans('import.map_do_not_map')),
+ 19 => 'Else',
+ 23 => 'Something (IBAN)',
+
];
$this->assertEquals($result, $mapping);
}
diff --git a/tests/Unit/Import/Mapper/BillsTest.php b/tests/Unit/Import/Mapper/BillsTest.php
index 1593ff726d..3a8e506d24 100644
--- a/tests/Unit/Import/Mapper/BillsTest.php
+++ b/tests/Unit/Import/Mapper/BillsTest.php
@@ -41,11 +41,11 @@ class BillsTest extends TestCase
public function testGetMapBasic()
{
$one = new Bill();
- $one->id = 1;
+ $one->id = 5;
$one->name = 'Something';
$one->match = 'hi,bye';
$two = new Account;
- $two->id = 2;
+ $two->id = 9;
$two->name = 'Else';
$two->match = 'match';
$collection = new Collection([$one, $two]);
@@ -59,8 +59,8 @@ class BillsTest extends TestCase
// assert this is what the result looks like:
$result = [
0 => strval(trans('import.map_do_not_map')),
- 1 => 'Something [hi,bye]',
- 2 => 'Else [match]',
+ 9 => 'Else [match]',
+ 5 => 'Something [hi,bye]',
];
$this->assertEquals($result, $mapping);
}
diff --git a/tests/Unit/Import/Mapper/BudgetsTest.php b/tests/Unit/Import/Mapper/BudgetsTest.php
index 98c492840d..8be0780a33 100644
--- a/tests/Unit/Import/Mapper/BudgetsTest.php
+++ b/tests/Unit/Import/Mapper/BudgetsTest.php
@@ -40,10 +40,10 @@ class BudgetsTest extends TestCase
public function testGetMapBasic()
{
$one = new Budget;
- $one->id = 1;
+ $one->id = 8;
$one->name = 'Something';
$two = new Budget;
- $two->id = 2;
+ $two->id = 4;
$two->name = 'Else';
$collection = new Collection([$one, $two]);
@@ -56,8 +56,9 @@ class BudgetsTest extends TestCase
// assert this is what the result looks like:
$result = [
0 => strval(trans('import.map_do_not_map')),
- 1 => 'Something',
- 2 => 'Else',
+ 4 => 'Else',
+ 8 => 'Something',
+
];
$this->assertEquals($result, $mapping);
}
diff --git a/tests/Unit/Import/Mapper/CategoriesTest.php b/tests/Unit/Import/Mapper/CategoriesTest.php
index 19bae979f5..6dd9524810 100644
--- a/tests/Unit/Import/Mapper/CategoriesTest.php
+++ b/tests/Unit/Import/Mapper/CategoriesTest.php
@@ -40,10 +40,10 @@ class CategoriesTest extends TestCase
public function testGetMapBasic()
{
$one = new Category;
- $one->id = 1;
+ $one->id = 9;
$one->name = 'Something';
$two = new Category;
- $two->id = 2;
+ $two->id = 17;
$two->name = 'Else';
$collection = new Collection([$one, $two]);
@@ -55,9 +55,10 @@ class CategoriesTest extends TestCase
$this->assertCount(3, $mapping);
// assert this is what the result looks like:
$result = [
- 0 => strval(trans('import.map_do_not_map')),
- 1 => 'Something',
- 2 => 'Else',
+ 0 => strval(trans('import.map_do_not_map')),
+ 17 => 'Else',
+ 9 => 'Something',
+
];
$this->assertEquals($result, $mapping);
}
diff --git a/tests/Unit/Import/Mapper/OpposingAccountIbansTest.php b/tests/Unit/Import/Mapper/OpposingAccountIbansTest.php
index b54cda0f2a..89ac4aad11 100644
--- a/tests/Unit/Import/Mapper/OpposingAccountIbansTest.php
+++ b/tests/Unit/Import/Mapper/OpposingAccountIbansTest.php
@@ -41,11 +41,11 @@ class OpposingAccountIbansTest extends TestCase
public function testGetMapBasic()
{
$one = new Account;
- $one->id = 1;
+ $one->id = 21;
$one->name = 'Something';
$one->iban = 'IBAN';
$two = new Account;
- $two->id = 2;
+ $two->id = 17;
$two->name = 'Else';
$collection = new Collection([$one, $two]);
@@ -59,9 +59,9 @@ class OpposingAccountIbansTest extends TestCase
$this->assertCount(3, $mapping);
// assert this is what the result looks like:
$result = [
- 0 => strval(trans('import.map_do_not_map')),
- 1 => 'IBAN (Something)',
- 2 => 'Else',
+ 0 => strval(trans('import.map_do_not_map')),
+ 17 => 'Else',
+ 21 => 'IBAN (Something)',
];
$this->assertEquals($result, $mapping);
}
diff --git a/tests/Unit/Import/Mapper/OpposingAccountsTest.php b/tests/Unit/Import/Mapper/OpposingAccountsTest.php
index 170926ade5..6cd92bfdaf 100644
--- a/tests/Unit/Import/Mapper/OpposingAccountsTest.php
+++ b/tests/Unit/Import/Mapper/OpposingAccountsTest.php
@@ -41,11 +41,11 @@ class OpposingAccountsTest extends TestCase
public function testGetMapBasic()
{
$one = new Account;
- $one->id = 1;
+ $one->id = 13;
$one->name = 'Something';
$one->iban = 'IBAN';
$two = new Account;
- $two->id = 2;
+ $two->id = 9;
$two->name = 'Else';
$collection = new Collection([$one, $two]);
@@ -59,9 +59,9 @@ class OpposingAccountsTest extends TestCase
$this->assertCount(3, $mapping);
// assert this is what the result looks like:
$result = [
- 0 => strval(trans('import.map_do_not_map')),
- 1 => 'Something (IBAN)',
- 2 => 'Else',
+ 0 => strval(trans('import.map_do_not_map')),
+ 9 => 'Else',
+ 13 => 'Something (IBAN)',
];
$this->assertEquals($result, $mapping);
}
diff --git a/tests/Unit/Import/Mapper/TagsTest.php b/tests/Unit/Import/Mapper/TagsTest.php
index 2a98475a0e..dd8bd14fd3 100644
--- a/tests/Unit/Import/Mapper/TagsTest.php
+++ b/tests/Unit/Import/Mapper/TagsTest.php
@@ -40,10 +40,10 @@ class TagsTest extends TestCase
public function testGetMapBasic()
{
$one = new Tag;
- $one->id = 1;
+ $one->id = 12;
$one->tag = 'Something';
$two = new Tag;
- $two->id = 2;
+ $two->id = 14;
$two->tag = 'Else';
$collection = new Collection([$one, $two]);
@@ -55,9 +55,9 @@ class TagsTest extends TestCase
$this->assertCount(3, $mapping);
// assert this is what the result looks like:
$result = [
- 0 => strval(trans('import.map_do_not_map')),
- 1 => 'Something',
- 2 => 'Else',
+ 0 => strval(trans('import.map_do_not_map')),
+ 14 => 'Else',
+ 12 => 'Something',
];
$this->assertEquals($result, $mapping);
}
diff --git a/tests/Unit/Import/Mapper/TransactionCurrenciesTest.php b/tests/Unit/Import/Mapper/TransactionCurrenciesTest.php
index 295cb3c1de..235cd165d4 100644
--- a/tests/Unit/Import/Mapper/TransactionCurrenciesTest.php
+++ b/tests/Unit/Import/Mapper/TransactionCurrenciesTest.php
@@ -40,11 +40,11 @@ class TransactionCurrenciesTest extends TestCase
public function testGetMapBasic()
{
$one = new TransactionCurrency;
- $one->id = 1;
+ $one->id = 9;
$one->name = 'Something';
$one->code = 'ABC';
$two = new TransactionCurrency;
- $two->id = 2;
+ $two->id = 11;
$two->name = 'Else';
$two->code = 'DEF';
$collection = new Collection([$one, $two]);
@@ -57,9 +57,10 @@ class TransactionCurrenciesTest extends TestCase
$this->assertCount(3, $mapping);
// assert this is what the result looks like:
$result = [
- 0 => strval(trans('import.map_do_not_map')),
- 1 => 'Something (ABC)',
- 2 => 'Else (DEF)',
+ 0 => strval(trans('import.map_do_not_map')),
+ 11 => 'Else (DEF)',
+ 9 => 'Something (ABC)',
+
];
$this->assertEquals($result, $mapping);
}