Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Tests/Unit/Action/GetSEPAAccountsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Fhp\Protocol\Message;
use Fhp\Protocol\UPD;
use Fhp\Segment\BaseSegment;
use Fhp\Segment\HIUPD\HIUPDv6;
use Fhp\Segment\SPA\HKSPAv2;

/**
Expand All @@ -24,7 +25,7 @@ class GetSEPAAccountsTest extends ActionTestCase
. 'i:0;a:5:{i:0;a:1:{i:0;i:3;}i:1;N;i:2;N;i:3;N;i:4;N;}i:1;N;'
. 'i:2;a:1:{i:0;O:23:"Fhp\\Segment\\SPA\\HKSPAv2":1:{i:0;s:10:"HKSPA:3:2\'";}}}';

public function testAnnotatesAccountsFromTheUpd()
public function testAnnotatesAccountsFromTheUpd(): void
{
$action = GetSEPAAccounts::create();
self::nextRequest($action, self::createBpd(self::hispas()), self::createUpd());
Expand All @@ -47,7 +48,7 @@ public function testAnnotatesAccountsFromTheUpd()
$this->assertSame(10, $savings->getAccountType());
}

public function testLeavesAccountsWithoutHiupdUnannotated()
public function testLeavesAccountsWithoutHiupdUnannotated(): void
{
$upd = new UPD();
$upd->hiupd = [];
Expand All @@ -65,7 +66,7 @@ public function testLeavesAccountsWithoutHiupdUnannotated()
}
}

public function testWorksWithoutUpd()
public function testWorksWithoutUpd(): void
{
$action = GetSEPAAccounts::create();
self::nextRequest($action, self::createBpd(self::hispas()));
Expand All @@ -80,7 +81,7 @@ public function testWorksWithoutUpd()
* the FinTs instance that completes it may come from persist(true), which contains no UPD. So the UPD captured in
* createRequest() has to survive that round trip for the accounts to be annotated afterwards.
*/
public function testUpdSurvivesSerialization()
public function testUpdSurvivesSerialization(): void
{
$action = GetSEPAAccounts::create();
$requestSegments = self::nextRequest($action, self::createBpd(self::hispas()), self::createUpd());
Expand All @@ -95,7 +96,7 @@ public function testUpdSurvivesSerialization()
$this->assertSame('Girokonto Komfort', $giro->getProductName());
}

public function testUnserializesActionsSerializedWithoutUpd()
public function testUnserializesActionsSerializedWithoutUpd(): void
{
/** @var GetSEPAAccounts $restored */
$restored = unserialize(self::SERIALIZED_BY_DD2A7F2);
Expand Down Expand Up @@ -130,10 +131,10 @@ private static function createUpd(): UPD
{
$upd = new UPD();
$upd->hiupd = [
BaseSegment::parse(
HIUPDv6::parse(
"HIUPD:7:6:4+5407324931::280:50010517+DE44500105175407324931+9999999999+1+EUR+Mustermann+Max+Girokonto Komfort++HKSAK:1+HKKAZ:1+HKSPA:1'"
),
BaseSegment::parse(
HIUPDv6::parse(
"HIUPD:8:6:4+0123456789::280:50010517++9999999999+10+EUR+Mustermann++Sparkonto++HKSAK:1+HKKAZ:1+HKSPA:1'"
),
];
Expand Down
2 changes: 2 additions & 0 deletions Tests/Unit/CAMT/CAMTStructuredFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ protected function setUp(): void

/**
* @dataProvider UstrdProvider
* @param array<string, string> $expectedStructuredTags
*/
public function testExtractStructuredFieldsFromText(string $text, array $expectedStructuredTags): void
{
Expand All @@ -27,6 +28,7 @@ public function testExtractStructuredFieldsFromText(string $text, array $expecte
self::assertSame($expectedStructuredTags, $fields);
}

/** @return list<array{string, array<string, string>}> */
public static function UstrdProvider(): array
{
return [
Expand Down
28 changes: 17 additions & 11 deletions Tests/Unit/Segment/HIUPDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ class HIUPDTest extends \PHPUnit\Framework\TestCase
"HIUPD:17:4:4+1234568::280:10020030+12345+DEM+Ernst Müller++Sparkonto 2000++HKPRO:1+HKSAK:0+HKISA:1+HKSSP:0+HKUEB:2:Z:1000,:DEM:7+HKKAN:1+HKKAZ:1+HKSAL:2'",
];

/** The examples in ISO-8859-1, as a bank would send them. */
private static function hbci22Example(int $index): string
{
return mb_convert_encoding(self::HBCI22_EXAMPLES[$index], 'ISO-8859-1', 'UTF-8');
}

public function testParseHBCI22Example1()
{
$parsed = HIUPDv4::parse(mb_convert_encoding(static::HBCI22_EXAMPLES[0], 'ISO-8859-1', 'UTF-8'));
$parsed = HIUPDv4::parse(self::hbci22Example(0));
$this->assertSame(16, $parsed->segmentkopf->segmentnummer);
$this->assertSame(4, $parsed->segmentkopf->segmentversion);
$this->assertSame('1234567', $parsed->kontoverbindung->kontonummer);
Expand All @@ -46,20 +52,20 @@ public function testParseHBCI22Example1()

public function testValidateHBCI22Example1()
{
$parsed = HIUPDv4::parse(mb_convert_encoding(static::HBCI22_EXAMPLES[0], 'ISO-8859-1', 'UTF-8'));
$parsed = HIUPDv4::parse(self::hbci22Example(0));
$parsed->validate(); // Should not throw.
$this->assertTrue(true);
}

public function testSerializeHBCI22Example1()
{
$parsed = HIUPDv4::parse(mb_convert_encoding(static::HBCI22_EXAMPLES[0], 'ISO-8859-1', 'UTF-8'));
$this->assertEquals(mb_convert_encoding(static::HBCI22_EXAMPLES[0], 'ISO-8859-1', 'UTF-8'), $parsed->serialize());
$parsed = HIUPDv4::parse(self::hbci22Example(0));
$this->assertEquals(self::hbci22Example(0), $parsed->serialize());
}

public function testParseHBCI22Example2()
{
$parsed = HIUPDv4::parse(mb_convert_encoding(static::HBCI22_EXAMPLES[1], 'ISO-8859-1', 'UTF-8'));
$parsed = HIUPDv4::parse(self::hbci22Example(1));
$this->assertSame('1234568', $parsed->kontoverbindung->kontonummer);
$this->assertSame('Sparkonto 2000', $parsed->kontoproduktbezeichnung);
$this->assertNull($parsed->kontolimit);
Expand All @@ -75,24 +81,24 @@ public function testParseHBCI22Example2()

public function testValidateHBCI22Example2()
{
$parsed = HIUPDv4::parse(mb_convert_encoding(static::HBCI22_EXAMPLES[1], 'ISO-8859-1', 'UTF-8'));
$parsed = HIUPDv4::parse(self::hbci22Example(1));
$parsed->validate(); // Should not throw.
$this->assertTrue(true);
}

public function testSerializeHBCI22Example2()
{
$parsed = HIUPDv4::parse(mb_convert_encoding(static::HBCI22_EXAMPLES[1], 'ISO-8859-1', 'UTF-8'));
$this->assertEquals(mb_convert_encoding(static::HBCI22_EXAMPLES[1], 'ISO-8859-1', 'UTF-8'), $parsed->serialize());
$parsed = HIUPDv4::parse(self::hbci22Example(1));
$this->assertEquals(self::hbci22Example(1), $parsed->serialize());
}

public function testAccountHolderNameWithoutSecondNameField()
public function testAccountHolderNameWithoutSecondNameField(): void
{
$parsed = HIUPDv4::parse(mb_convert_encoding(static::HBCI22_EXAMPLES[0], 'ISO-8859-1', 'UTF-8'));
$parsed = HIUPDv4::parse(self::hbci22Example(0));
$this->assertSame('Ernst Müller', $parsed->getAccountHolderName());
}

public function testAccountHolderNameJoinsBothNameFields()
public function testAccountHolderNameJoinsBothNameFields(): void
{
$parsed = HIUPDv6::parse(
"HIUPD:10:6:4+1234567890::280:60050101+DE02600501011234567890+9999999999+1+EUR+Mustermann+Max+Giro++HKSAK:1'"
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Segment/HKWPDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class HKWPDTest extends TestCase
{
public function testParametersOfVersion6()
public function testParametersOfVersion6(): void
{
/** @var HIWPDSv6 $hiwpds */
$hiwpds = Parser::parseSegment("HIWPDS:60:6:3+1+1+0+N:N:N'", HIWPDSv6::class);
Expand All @@ -24,7 +24,7 @@ public function testParametersOfVersion6()
$this->assertFalse($hiwpds->getParameter()->getKursqualitaetWaehlbar());
}

public function testRequestOfVersion6()
public function testRequestOfVersion6(): void
{
$hkwpd = HKWPDv6::create(KtvV3::create('502022353', null, Kik::create('12030000')));
$hkwpd->setSegmentNumber(3);
Expand Down
18 changes: 0 additions & 18 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -996,12 +996,6 @@ parameters:
count: 6
path: Tests/Unit/Segment/HIUPDTest.php

-
message: '#^Parameter \#1 \$rawSegment of static method Fhp\\Segment\\BaseSegment\:\:parse\(\) expects string, array\|string given\.$#'
identifier: argument.type
count: 6
path: Tests/Unit/Segment/HIUPDTest.php

-
message: '#^Parameter \#2 \$haystack of method PHPUnit\\Framework\\Assert\:\:assertCount\(\) expects Countable\|iterable, array\<Fhp\\Segment\\HIUPD\\ErlaubteGeschaeftsvorfaelleV1\>\|null given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -1746,18 +1740,6 @@ parameters:
count: 2
path: src/CAMT/CAMT.php

-
message: '#^Cannot access offset 0 on array\<SimpleXMLElement\>\|false\|null\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/CAMT/CAMT.php

-
message: '#^Expression on left side of \?\? is not nullable\.$#'
identifier: nullCoalesce.expr
count: 1
path: src/CAMT/CAMT.php

-
message: '#^Method Fhp\\CAMT\\CAMT\:\:extractStructuredFieldsFromText\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down
2 changes: 2 additions & 0 deletions src/Action/GetSEPAAccounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function serialize(): string
return serialize($this->__serialize());
}

/** @return array<mixed> */
public function __serialize(): array
{
return [
Expand All @@ -78,6 +79,7 @@ public function unserialize($serialized)
self::__unserialize(unserialize($serialized));
}

/** @param array<mixed> $serialized */
public function __unserialize(array $serialized): void
{
// Actions serialized before the UPD travelled along consist of the PaginateableAction state only.
Expand Down
2 changes: 1 addition & 1 deletion src/Segment/WPD/HKWPDv6.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function create(\Fhp\Segment\Common\KtvV3 $ktv): HKWPDv6
return $result;
}

public function setPaginationToken(string $paginationToken)
public function setPaginationToken(string $paginationToken): void
{
$this->aufsetzpunkt = $paginationToken;
}
Expand Down
Loading