forked from apoloz/alfa-bank-sdk
refactor(core): enhance SDK structure and documentation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
36
tests/Feature/Webhooks/WebhookTest.php
Normal file
36
tests/Feature/Webhooks/WebhookTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Apoloz\AlfaBank\Webhooks\WebhookFactory;
|
||||
use Apoloz\AlfaBank\Data\Webhooks\Payloads\BaasWebhookData;
|
||||
use Apoloz\AlfaBank\Data\Webhooks\Payloads\SbpWebhookData;
|
||||
|
||||
test('can detect baas webhook', function () {
|
||||
$payload = [
|
||||
[
|
||||
'object' => 'ul_transaction_default',
|
||||
'actionType' => 'create',
|
||||
'eventTime' => '2022-01-12T00:00:00',
|
||||
'data' => []
|
||||
]
|
||||
];
|
||||
|
||||
expect(WebhookFactory::isBaas($payload))->toBeTrue();
|
||||
|
||||
$webhook = WebhookFactory::create($payload);
|
||||
expect($webhook)->toBeInstanceOf(BaasWebhookData::class)
|
||||
->and($webhook->object)->toBe('ul_transaction_default');
|
||||
});
|
||||
|
||||
test('can detect sbp webhook', function () {
|
||||
$payload = [
|
||||
'command' => 'qrc/notification',
|
||||
'status' => 'ACWP',
|
||||
'qrcId' => 'test-id'
|
||||
];
|
||||
|
||||
expect(WebhookFactory::isSbp($payload))->toBeTrue();
|
||||
|
||||
$webhook = WebhookFactory::create($payload);
|
||||
expect($webhook)->toBeInstanceOf(SbpWebhookData::class)
|
||||
->and($webhook->command)->toBe('qrc/notification');
|
||||
});
|
||||
Reference in New Issue
Block a user