HelperTest.php 1.0 KB

1234567891011121314151617181920212223242526
  1. <?php
  2. use Omnipay\Tests\TestCase;
  3. class HelperTest extends TestCase
  4. {
  5. /** @test */
  6. public function it_should_return_an_array_if_xml_is_ok()
  7. {
  8. $xml = '<xml><return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> <appid><![CDATA[wx57b9bd4dd4b01ef5]]></appid> <mch_id><![CDATA[1499803642]]></mch_id> <nonce_str><![CDATA[k5ntjxBlcq0KnkJQ]]></nonce_str> <sign><![CDATA[8C03594BEB37A08BE70422F9FCC05168]]></sign> <result_code><![CDATA[SUCCESS]]></result_code> <prepay_id><![CDATA[wx05153421914401e72549e4843149659371]]></prepay_id> <trade_type><![CDATA[NATIVE]]></trade_type> <code_url><![CDATA[weixin://wxpay/bizpayurl?pr=QXuSXeo]]></code_url> </xml>';
  9. $array = \Omnipay\WechatPay\Helper::xml2array($xml);
  10. $this->assertArrayHasKey('return_code', $array);
  11. }
  12. /** @test */
  13. public function it_should_return_an_empty_array_if_xml_is_empty()
  14. {
  15. $array = \Omnipay\WechatPay\Helper::xml2array('');
  16. $this->assertEquals([], $array);
  17. }
  18. }