Skip to content

Commit

Permalink
Fix unit tests for investment transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
gitmathias committed Feb 3, 2020
1 parent 3a4f46c commit 8a15c39
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/OfxParser/Parsers/InvestmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function testParseInvestmentsXML()
self::assertTrue(count($account->statement->transactions) > 0);
}

$this->validateTransactions($account->statement->transactions);
$this->validateTransactions($account->statement->transactions, $expected);
}

public function testParseInvestmentsXMLOneLine()
Expand Down Expand Up @@ -125,7 +125,7 @@ public function testParseInvestmentsXMLOneLine()
self::assertTrue(count($account->statement->transactions) > 0);
}

$this->validateTransactions($account->statement->transactions);
$this->validateTransactions($account->statement->transactions, $expected);
}

public function testParseInvestmentsXMLMultipleAccounts()
Expand Down Expand Up @@ -170,7 +170,11 @@ public function testParseInvestmentsXMLMultipleAccounts()
}

foreach ($ofx->bankAccounts as $account) {
$this->validateTransactions($account->statement->transactions);
$myExpected = isset($expected[$account->accountNumber])
? $expected[$account->accountNumber]
: array();

$this->validateTransactions($account->statement->transactions, $myExpected);
}
}

Expand Down Expand Up @@ -202,10 +206,10 @@ public function testGoogleFinanceInvestments()
self::assertTrue(count($account->statement->transactions) > 0);
}

$this->validateTransactions($account->statement->transactions);
$this->validateTransactions($account->statement->transactions, $expected);
}

protected function validateTransactions($transactions)
protected function validateTransactions($transactions, $expected)
{
foreach ($transactions as $t) {
if (isset($expected[$t->uniqueId])) {
Expand Down

0 comments on commit 8a15c39

Please sign in to comment.