From 91a4606f0e6c28b552274501f503f1b87db894b7 Mon Sep 17 00:00:00 2001 From: grummbeer Date: Sun, 10 Dec 2023 17:25:04 +0100 Subject: [PATCH] add test for getBalances --- tests/ContextXmlRendererTest.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/ContextXmlRendererTest.php b/tests/ContextXmlRendererTest.php index d967a37..ad65156 100644 --- a/tests/ContextXmlRendererTest.php +++ b/tests/ContextXmlRendererTest.php @@ -15,6 +15,7 @@ /** * @covers \AqBanking\ContextXmlRenderer * @uses \AqBanking\ContentXmlRenderer\MoneyElementRenderer + * @uses \AqBanking\Balance */ class ContextXmlRendererTest extends TestCase { @@ -78,9 +79,22 @@ public function testCanRenderTransactions() $this->assertEquals($expectedTransactions, $sut->getTransactions()); } - /** - * @throws Exception - */ + public function testCanRenderBalances() + { + $fixture = file_get_contents(__DIR__ . '/fixtures/test_context_file_transactions.xml'); + $domDocument = new \DOMDocument(); + $domDocument->loadXML($fixture); + + $sut = new ContextXmlRenderer($domDocument); + + $balances = $sut->getBalances(); + + $this->assertCount(3, $balances); + $this->assertInstanceOf(\DateTime::class, $balances[0]->getDate()); + $this->assertInstanceOf(Money::class, $balances[0]->getValue()); + $this->assertSame('temporary', $balances[0]->getType()); + } + public function testThrowsExceptionIfDataContainsReservedChar() { $fixture = file_get_contents(__DIR__ . '/fixtures/test_context_file_transactions_with_reserved_char.xml');