PayTest.php 975 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Yansongda\Pay\Tests;
  3. use Yansongda\Pay\Contracts\GatewayApplicationInterface;
  4. use Yansongda\Pay\Exceptions\InvalidGatewayException;
  5. use Yansongda\Pay\Gateways\Alipay;
  6. use Yansongda\Pay\Gateways\Wechat;
  7. use Yansongda\Pay\Pay;
  8. class PayTest extends TestCase
  9. {
  10. public function testAlipayGateway()
  11. {
  12. $alipay = Pay::alipay(['foo' => 'bar']);
  13. $this->assertInstanceOf(Alipay::class, $alipay);
  14. $this->assertInstanceOf(GatewayApplicationInterface::class, $alipay);
  15. }
  16. public function testWechatGateway()
  17. {
  18. $wechat = Pay::wechat(['foo' => 'bar']);
  19. $this->assertInstanceOf(Wechat::class, $wechat);
  20. $this->assertInstanceOf(GatewayApplicationInterface::class, $wechat);
  21. }
  22. public function testFooGateway()
  23. {
  24. $this->expectException(InvalidGatewayException::class);
  25. $this->expectExceptionMessage('INVALID_GATEWAY: Gateway [foo] Not Exists');
  26. Pay::foo([]);
  27. }
  28. }