42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\Oceanpayment\Test\Unit\Model\Gateway;
|
|
|
|
use Esun\Oceanpayment\Model\Gateway\ResponseParser;
|
|
use Magento\Framework\Exception\LocalizedException;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ResponseParserTest extends TestCase
|
|
{
|
|
public function testParsesHostedCheckoutCreationResponse(): void
|
|
{
|
|
$xml = <<<'XML'
|
|
<root>
|
|
<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>
|
|
<pay_url>https://test-secure.oceanpayment.com/pay/123</pay_url>
|
|
<pay_results>1</pay_results>
|
|
<pay_details>Success</pay_details>
|
|
<signValue>ABCDEF</signValue>
|
|
</root>
|
|
XML;
|
|
|
|
$result = (new ResponseParser())->parse($xml);
|
|
|
|
self::assertSame('PAY-123', $result['payment_id']);
|
|
self::assertSame('1', $result['pay_results']);
|
|
self::assertSame('https://test-secure.oceanpayment.com/pay/123', $result['pay_url']);
|
|
}
|
|
|
|
public function testRejectsNonXmlResponse(): void
|
|
{
|
|
$this->expectException(LocalizedException::class);
|
|
(new ResponseParser())->parse('bad gateway');
|
|
}
|
|
}
|