2018-01-02 22:22:35 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Yansongda\Pay\Tests;
|
|
|
|
|
|
|
|
use Yansongda\Pay\Contracts\GatewayApplicationInterface;
|
2019-08-31 11:49:37 +08:00
|
|
|
use Yansongda\Pay\Exceptions\InvalidGatewayException;
|
2019-09-01 13:40:59 +08:00
|
|
|
use Yansongda\Pay\Gateways\Alipay;
|
|
|
|
use Yansongda\Pay\Gateways\Wechat;
|
2018-01-02 22:22:35 +08:00
|
|
|
use Yansongda\Pay\Pay;
|
|
|
|
|
|
|
|
class PayTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testAlipayGateway()
|
|
|
|
{
|
|
|
|
$alipay = Pay::alipay(['foo' => 'bar']);
|
|
|
|
|
2019-09-01 13:40:59 +08:00
|
|
|
$this->assertInstanceOf(Alipay::class, $alipay);
|
2018-01-02 22:22:35 +08:00
|
|
|
$this->assertInstanceOf(GatewayApplicationInterface::class, $alipay);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWechatGateway()
|
|
|
|
{
|
|
|
|
$wechat = Pay::wechat(['foo' => 'bar']);
|
|
|
|
|
2019-09-01 13:40:59 +08:00
|
|
|
$this->assertInstanceOf(Wechat::class, $wechat);
|
2018-01-02 22:22:35 +08:00
|
|
|
$this->assertInstanceOf(GatewayApplicationInterface::class, $wechat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testFooGateway()
|
|
|
|
{
|
2019-08-31 11:49:37 +08:00
|
|
|
$this->expectException(InvalidGatewayException::class);
|
|
|
|
$this->expectExceptionMessage('INVALID_GATEWAY: Gateway [foo] Not Exists');
|
2018-01-02 22:22:35 +08:00
|
|
|
|
2018-01-04 11:00:59 +08:00
|
|
|
Pay::foo([]);
|
2018-01-02 22:22:35 +08:00
|
|
|
}
|
|
|
|
}
|