43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\Oceanpayment\Test\Unit\Model\Callback;
|
|
|
|
use Esun\Oceanpayment\Model\Callback\Parser;
|
|
use Magento\Framework\Exception\LocalizedException;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ParserTest extends TestCase
|
|
{
|
|
public function testParsesOceanpaymentXmlNotification(): void
|
|
{
|
|
$xml = <<<'XML'
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<response>
|
|
<response_type>1</response_type>
|
|
<account>995149</account>
|
|
<terminal>99514901</terminal>
|
|
<order_number>100000001</order_number>
|
|
<order_currency>USD</order_currency>
|
|
<order_amount>1.00</order_amount>
|
|
<payment_id>PAY-123</payment_id>
|
|
<payment_status>1</payment_status>
|
|
<signValue>ABCDEF</signValue>
|
|
</response>
|
|
XML;
|
|
|
|
$result = (new Parser())->parse($xml, []);
|
|
|
|
self::assertSame('1', $result['response_type']);
|
|
self::assertSame('100000001', $result['order_number']);
|
|
self::assertSame('PAY-123', $result['payment_id']);
|
|
self::assertSame('', $result['payment_risk']);
|
|
}
|
|
|
|
public function testRejectsInvalidXml(): void
|
|
{
|
|
$this->expectException(LocalizedException::class);
|
|
(new Parser())->parse('<response><broken></response>', []);
|
|
}
|
|
}
|