AopJsGatewayTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Omnipay\Alipay\Tests;
  3. use Omnipay\Alipay\AopJsGateway;
  4. use Omnipay\Alipay\Responses\AopTradeCreateResponse;
  5. class AopJsGatewayTest extends AbstractGatewayTestCase
  6. {
  7. /**
  8. * @var AopJsGateway $gateway
  9. */
  10. protected $gateway;
  11. protected $options;
  12. public function setUp()
  13. {
  14. parent::setUp();
  15. $this->gateway = new AopJsGateway($this->getHttpClient(), $this->getHttpRequest());
  16. $this->gateway->setAppId($this->appId);
  17. $this->gateway->setPrivateKey(ALIPAY_AOP_PRIVATE_KEY);
  18. }
  19. public function testPurchase()
  20. {
  21. $this->setMockHttpResponse('AopJs_Purchase_Failure.txt');
  22. /**
  23. * @var AopTradeCreateResponse $response
  24. */
  25. $response = $this->gateway->purchase(
  26. [
  27. 'biz_content' => [
  28. 'subject' => 'test',
  29. 'out_trade_no' => date('YmdHis') . mt_rand(1000, 9999),
  30. 'total_amount' => '0.01',
  31. 'product_code' => '0.01',
  32. ]
  33. ]
  34. )->send();
  35. $this->assertFalse($response->isSuccessful());
  36. $this->assertArrayHasKey('code', $response->getAlipayResponse());
  37. }
  38. }