香洲二院小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

94 lines
2.5 KiB

<?php
use UnifyPayment\Cores\Struct\CloseOrder;
use UnifyPayment\Cores\Struct\ConfirmOrderForEx;
use UnifyPayment\Cores\Struct\QueryOrder;
use UnifyPayment\Cores\Struct\RefundOrder;
use UnifyPayment\Factory;
use UnifyPayment\Mock\CloseOrderHandler;
use UnifyPayment\Mock\ConfirmOrderForExHandler;
use UnifyPayment\Mock\QueryOrderHandler;
use UnifyPayment\Mock\RefundOrderHandler;
class CommonTest extends TestCase
{
public function testOrderQuery()
{
$order = new QueryOrder('FD2022080310000055123451223');
$mockHandler = new QueryOrderHandler(true);
$response = Factory::common($this->getConfig())->order->setMockHandler([$mockHandler])->query($order);
$this->assertArrayHasKey('response', $response);
$this->assertEquals([
'orderNo',
'payAccount',
'transNo',
'status',
'statusDesc',
'amount',
'tag',
'merchantId',
'merchantName',
'channelId',
'channelName'
], array_keys($response['response']));
}
public function testOrderClose()
{
$order = new CloseOrder('FD2022080310000055123451223');
$mockHandler = new CloseOrderHandler(true);
$response = Factory::common($this->getConfig())->order->setMockHandler([$mockHandler])->close($order);
$this->assertArrayHasKey('response', $response);
$this->assertEquals([
'orderNo',
'closeTime',
'merchantId',
'merchantName',
'channelId',
'channelName'
], array_keys($response['response']));
}
public function testOrderRefund()
{
$order = new RefundOrder('FD2022080310000055123451223', 'FD2022080310000055123451223_12345', 0.01, 'Test Refund');
$mockHandler = new RefundOrderHandler(true);
$response = Factory::common($this->getConfig())->order->setMockHandler([$mockHandler])->refund($order);
$this->assertArrayHasKey('response', $response);
$this->assertEquals([
'orderNo',
'refundNo',
'refundAmount',
'refundTime',
'merchantId',
'merchantName',
'channelId',
'channelName'
], array_keys($response['response']));
}
public function testOrderConfirmForEx()
{
$order = new ConfirmOrderForEx('FD2022080310000055123451223', 'ZSD0002974832', 'ow8NuxN_ALO2MzSvzj19hyxWjCVY', '4200067674202302063709953797');
$mockHandler = new ConfirmOrderForExHandler(true);
$response = Factory::common($this->getConfig())->order->setMockHandler([$mockHandler])->confirmForEx($order);
$this->assertArrayHasKey('response', $response);
$this->assertEquals([
'orderNo',
'hisSerialNo',
'confirmTime',
'merchantId',
'merchantName',
'channelId',
'channelName'
], array_keys($response['response']));
}
}