Skip to content

Commit 24a3a3d

Browse files
committed
Serialize BaseAction::pollingInfo and vopConfirmationRequest
1 parent 0e853a5 commit 24a3a3d

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

lib/Fhp/BaseAction.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public function __serialize(): array
9797
$this->requestSegmentNumbers,
9898
$this->tanRequest,
9999
$this->needTanForSegment,
100+
$this->pollingInfo,
101+
$this->vopConfirmationRequest,
100102
];
101103
}
102104

@@ -117,7 +119,9 @@ public function __unserialize(array $serialized): void
117119
$this->requestSegmentNumbers,
118120
$this->tanRequest,
119121
$this->needTanForSegment,
120-
) = $serialized;
122+
$this->pollingInfo,
123+
$this->vopConfirmationRequest,
124+
) = array_pad($serialized, 5, null);
121125
}
122126

123127
/**
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Fhp;
4+
5+
use Tests\Fhp\Integration\Atruvia\SendTransferVoPTest;
6+
7+
class BaseActionVopSerializationTest extends SendTransferVoPTest
8+
{
9+
/**
10+
* @throws \Throwable
11+
*/
12+
public function testSerializesPollingInfo()
13+
{
14+
// We piggy-back on the Atruvia integration test to provide an action that has some reasonable data inside and
15+
// has already been executed so that polling is now required.
16+
$this->initDialog();
17+
$originalAction = $this->createAction();
18+
$this->expectMessage(static::SEND_TRANSFER_REQUEST, mb_convert_encoding(static::SEND_TRANSFER_RESPONSE_POLLING_NEEDED, 'ISO-8859-1', 'UTF-8'));
19+
$this->fints->execute($originalAction);
20+
21+
// Sanity-check that the polling is now expected.
22+
$this->assertNotNull($originalAction->getPollingInfo());
23+
24+
// Do a serialization roundtrip.
25+
$serializedAction = serialize($originalAction);
26+
$unserializedAction = unserialize($serializedAction);
27+
28+
// Verify that the polling info is still the same.
29+
$this->assertEquals($originalAction->getPollingInfo(), $unserializedAction->getPollingInfo());
30+
}
31+
32+
/**
33+
* @throws \Throwable
34+
*/
35+
public function testSerializesVopConfirmationRequest()
36+
{
37+
// We piggy-back on the Atruvia integration test to provide an action that has some reasonable data inside and
38+
// has already been executed so that polling is now required.
39+
$this->initDialog();
40+
$originalAction = $this->createAction();
41+
$this->expectMessage(static::SEND_TRANSFER_REQUEST, mb_convert_encoding(static::SEND_TRANSFER_RESPONSE_POLLING_NEEDED, 'ISO-8859-1', 'UTF-8'));
42+
$response = static::buildVopReportResponse(static::VOP_REPORT_PARTIAL_MATCH_RESPONSE, static::VOP_REPORT_PARTIAL_MATCH_XML_PAYLOAD);
43+
$this->expectMessage(static::POLL_VOP_REQUEST, $response);
44+
$this->fints->execute($originalAction);
45+
$this->assertTrue($originalAction->needsPollingWait());
46+
$this->fints->pollAction($originalAction);
47+
48+
// Sanity-check that the VOP confirmation is now expected.
49+
$this->assertNotNull($originalAction->getVopConfirmationRequest());
50+
51+
// Do a serialization roundtrip.
52+
$serializedAction = serialize($originalAction);
53+
$unserializedAction = unserialize($serializedAction);
54+
55+
// Verify that the polling info is still the same.
56+
$this->assertEquals($originalAction->getVopConfirmationRequest(), $unserializedAction->getVopConfirmationRequest());
57+
}
58+
}

lib/Tests/Fhp/Integration/Atruvia/SendTransferVoPTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class SendTransferVoPTest extends AtruviaIntegrationTestBase
4949
public function testVopWithResultMatchButConfirmationRequired(): void
5050
{
5151
$this->initDialog();
52-
$action = SendSEPATransfer::create($this->getTestAccount(), self::XML_PAYLOAD);
52+
$action = $this->createAction();
5353

5454
// We send the transfer and the bank asks to wait while VOP is happening.
5555
$this->expectMessage(static::SEND_TRANSFER_REQUEST, mb_convert_encoding(static::SEND_TRANSFER_RESPONSE_POLLING_NEEDED, 'ISO-8859-1', 'UTF-8'));
@@ -104,7 +104,7 @@ public function testVopWithResultMatchButConfirmationRequired(): void
104104
public function testVopWithResultPartialMatch(): void
105105
{
106106
$this->initDialog();
107-
$action = SendSEPATransfer::create($this->getTestAccount(), self::XML_PAYLOAD);
107+
$action = $this->createAction();
108108

109109
// We send the transfer and the bank asks to wait while VOP is happening.
110110
$this->expectMessage(static::SEND_TRANSFER_REQUEST, mb_convert_encoding(static::SEND_TRANSFER_RESPONSE_POLLING_NEEDED, 'ISO-8859-1', 'UTF-8'));

0 commit comments

Comments
 (0)