Fixed tests to account for issue fixed by #1097

This commit is contained in:
James Cole
2018-01-06 07:33:30 +01:00
parent ed0e14aee5
commit 7fa937e80b
18 changed files with 66 additions and 53 deletions

View File

@@ -53,8 +53,9 @@ class AssetAccountIbans implements MapperInterface
$list[$accountId] = $account->name; $list[$accountId] = $account->name;
} }
} }
$list = array_merge($topList, $list); $list = $topList + $list;
$list = array_merge([0 => trans('import.map_do_not_map')], $list); asort($list);
$list = [0 => trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@@ -51,7 +51,8 @@ class AssetAccounts implements MapperInterface
} }
$list[$accountId] = $name; $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; return $list;
} }

View File

@@ -45,7 +45,8 @@ class Bills implements MapperInterface
$billId = intval($bill->id); $billId = intval($bill->id);
$list[$billId] = $bill->name . ' [' . $bill->match . ']'; $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; return $list;
} }

View File

@@ -45,7 +45,8 @@ class Budgets implements MapperInterface
$budgetId = intval($budget->id); $budgetId = intval($budget->id);
$list[$budgetId] = $budget->name; $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; return $list;
} }

View File

@@ -45,7 +45,8 @@ class Categories implements MapperInterface
$categoryId = intval($category->id); $categoryId = intval($category->id);
$list[$categoryId] = $category->name; $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; return $list;
} }

View File

@@ -59,8 +59,9 @@ class OpposingAccountIbans implements MapperInterface
$list[$accountId] = $account->name; $list[$accountId] = $account->name;
} }
} }
$list = array_merge($topList, $list); $list = $topList + $list;
$list = array_merge([0 => trans('import.map_do_not_map')], $list); asort($list);
$list = [0 => trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@@ -57,7 +57,8 @@ class OpposingAccounts implements MapperInterface
} }
$list[$accountId] = $name; $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; return $list;
} }

View File

@@ -45,7 +45,8 @@ class Tags implements MapperInterface
$tagId = intval($tag->id); $tagId = intval($tag->id);
$list[$tagId] = $tag->tag; $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; return $list;
} }

View File

@@ -42,8 +42,9 @@ class TransactionCurrencies implements MapperInterface
$currencyId = intval($currency->id); $currencyId = intval($currency->id);
$list[$currencyId] = $currency->name . ' (' . $currency->code . ')'; $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; return $list;
} }

View File

@@ -41,11 +41,11 @@ class AssetAccountIbansTest extends TestCase
public function testGetMapBasic() public function testGetMapBasic()
{ {
$one = new Account; $one = new Account;
$one->id = 1; $one->id = 17;
$one->name = 'Something'; $one->name = 'Something';
$one->iban = 'IBAN'; $one->iban = 'IBAN';
$two = new Account; $two = new Account;
$two->id = 2; $two->id = 53;
$two->name = 'Else'; $two->name = 'Else';
$collection = new Collection([$one, $two]); $collection = new Collection([$one, $two]);
@@ -58,8 +58,8 @@ class AssetAccountIbansTest extends TestCase
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => strval(trans('import.map_do_not_map')),
1 => 'IBAN (Something)', 53 => 'Else',
2 => 'Else', 17 => 'IBAN (Something)',
]; ];
$this->assertEquals($result, $mapping); $this->assertEquals($result, $mapping);
} }

View File

@@ -41,11 +41,11 @@ class AssetAccountsTest extends TestCase
public function testGetMapBasic() public function testGetMapBasic()
{ {
$one = new Account; $one = new Account;
$one->id = 1; $one->id = 23;
$one->name = 'Something'; $one->name = 'Something';
$one->iban = 'IBAN'; $one->iban = 'IBAN';
$two = new Account; $two = new Account;
$two->id = 2; $two->id = 19;
$two->name = 'Else'; $two->name = 'Else';
$collection = new Collection([$one, $two]); $collection = new Collection([$one, $two]);
@@ -57,9 +57,10 @@ class AssetAccountsTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => strval(trans('import.map_do_not_map')),
1 => 'Something (IBAN)', 19 => 'Else',
2 => 'Else', 23 => 'Something (IBAN)',
]; ];
$this->assertEquals($result, $mapping); $this->assertEquals($result, $mapping);
} }

View File

@@ -41,11 +41,11 @@ class BillsTest extends TestCase
public function testGetMapBasic() public function testGetMapBasic()
{ {
$one = new Bill(); $one = new Bill();
$one->id = 1; $one->id = 5;
$one->name = 'Something'; $one->name = 'Something';
$one->match = 'hi,bye'; $one->match = 'hi,bye';
$two = new Account; $two = new Account;
$two->id = 2; $two->id = 9;
$two->name = 'Else'; $two->name = 'Else';
$two->match = 'match'; $two->match = 'match';
$collection = new Collection([$one, $two]); $collection = new Collection([$one, $two]);
@@ -59,8 +59,8 @@ class BillsTest extends TestCase
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => strval(trans('import.map_do_not_map')),
1 => 'Something [hi,bye]', 9 => 'Else [match]',
2 => 'Else [match]', 5 => 'Something [hi,bye]',
]; ];
$this->assertEquals($result, $mapping); $this->assertEquals($result, $mapping);
} }

View File

@@ -40,10 +40,10 @@ class BudgetsTest extends TestCase
public function testGetMapBasic() public function testGetMapBasic()
{ {
$one = new Budget; $one = new Budget;
$one->id = 1; $one->id = 8;
$one->name = 'Something'; $one->name = 'Something';
$two = new Budget; $two = new Budget;
$two->id = 2; $two->id = 4;
$two->name = 'Else'; $two->name = 'Else';
$collection = new Collection([$one, $two]); $collection = new Collection([$one, $two]);
@@ -56,8 +56,9 @@ class BudgetsTest extends TestCase
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => strval(trans('import.map_do_not_map')),
1 => 'Something', 4 => 'Else',
2 => 'Else', 8 => 'Something',
]; ];
$this->assertEquals($result, $mapping); $this->assertEquals($result, $mapping);
} }

View File

@@ -40,10 +40,10 @@ class CategoriesTest extends TestCase
public function testGetMapBasic() public function testGetMapBasic()
{ {
$one = new Category; $one = new Category;
$one->id = 1; $one->id = 9;
$one->name = 'Something'; $one->name = 'Something';
$two = new Category; $two = new Category;
$two->id = 2; $two->id = 17;
$two->name = 'Else'; $two->name = 'Else';
$collection = new Collection([$one, $two]); $collection = new Collection([$one, $two]);
@@ -55,9 +55,10 @@ class CategoriesTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => strval(trans('import.map_do_not_map')),
1 => 'Something', 17 => 'Else',
2 => 'Else', 9 => 'Something',
]; ];
$this->assertEquals($result, $mapping); $this->assertEquals($result, $mapping);
} }

View File

@@ -41,11 +41,11 @@ class OpposingAccountIbansTest extends TestCase
public function testGetMapBasic() public function testGetMapBasic()
{ {
$one = new Account; $one = new Account;
$one->id = 1; $one->id = 21;
$one->name = 'Something'; $one->name = 'Something';
$one->iban = 'IBAN'; $one->iban = 'IBAN';
$two = new Account; $two = new Account;
$two->id = 2; $two->id = 17;
$two->name = 'Else'; $two->name = 'Else';
$collection = new Collection([$one, $two]); $collection = new Collection([$one, $two]);
@@ -59,9 +59,9 @@ class OpposingAccountIbansTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => strval(trans('import.map_do_not_map')),
1 => 'IBAN (Something)', 17 => 'Else',
2 => 'Else', 21 => 'IBAN (Something)',
]; ];
$this->assertEquals($result, $mapping); $this->assertEquals($result, $mapping);
} }

View File

@@ -41,11 +41,11 @@ class OpposingAccountsTest extends TestCase
public function testGetMapBasic() public function testGetMapBasic()
{ {
$one = new Account; $one = new Account;
$one->id = 1; $one->id = 13;
$one->name = 'Something'; $one->name = 'Something';
$one->iban = 'IBAN'; $one->iban = 'IBAN';
$two = new Account; $two = new Account;
$two->id = 2; $two->id = 9;
$two->name = 'Else'; $two->name = 'Else';
$collection = new Collection([$one, $two]); $collection = new Collection([$one, $two]);
@@ -59,9 +59,9 @@ class OpposingAccountsTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => strval(trans('import.map_do_not_map')),
1 => 'Something (IBAN)', 9 => 'Else',
2 => 'Else', 13 => 'Something (IBAN)',
]; ];
$this->assertEquals($result, $mapping); $this->assertEquals($result, $mapping);
} }

View File

@@ -40,10 +40,10 @@ class TagsTest extends TestCase
public function testGetMapBasic() public function testGetMapBasic()
{ {
$one = new Tag; $one = new Tag;
$one->id = 1; $one->id = 12;
$one->tag = 'Something'; $one->tag = 'Something';
$two = new Tag; $two = new Tag;
$two->id = 2; $two->id = 14;
$two->tag = 'Else'; $two->tag = 'Else';
$collection = new Collection([$one, $two]); $collection = new Collection([$one, $two]);
@@ -55,9 +55,9 @@ class TagsTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => strval(trans('import.map_do_not_map')),
1 => 'Something', 14 => 'Else',
2 => 'Else', 12 => 'Something',
]; ];
$this->assertEquals($result, $mapping); $this->assertEquals($result, $mapping);
} }

View File

@@ -40,11 +40,11 @@ class TransactionCurrenciesTest extends TestCase
public function testGetMapBasic() public function testGetMapBasic()
{ {
$one = new TransactionCurrency; $one = new TransactionCurrency;
$one->id = 1; $one->id = 9;
$one->name = 'Something'; $one->name = 'Something';
$one->code = 'ABC'; $one->code = 'ABC';
$two = new TransactionCurrency; $two = new TransactionCurrency;
$two->id = 2; $two->id = 11;
$two->name = 'Else'; $two->name = 'Else';
$two->code = 'DEF'; $two->code = 'DEF';
$collection = new Collection([$one, $two]); $collection = new Collection([$one, $two]);
@@ -57,9 +57,10 @@ class TransactionCurrenciesTest extends TestCase
$this->assertCount(3, $mapping); $this->assertCount(3, $mapping);
// assert this is what the result looks like: // assert this is what the result looks like:
$result = [ $result = [
0 => strval(trans('import.map_do_not_map')), 0 => strval(trans('import.map_do_not_map')),
1 => 'Something (ABC)', 11 => 'Else (DEF)',
2 => 'Else (DEF)', 9 => 'Something (ABC)',
]; ];
$this->assertEquals($result, $mapping); $this->assertEquals($result, $mapping);
} }