From 100f8dd53357ae87b26dde457f04b6ea96d4c3ef Mon Sep 17 00:00:00 2001 From: wanghaojie <814425737@qq.com> Date: Sat, 22 Jun 2024 09:34:36 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E5=A4=8D=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Plugin/Jsb/ResponsePlugin.php | 1 - tests/Plugin/Jsb/ResponsePluginTest.php | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Plugin/Jsb/ResponsePlugin.php b/src/Plugin/Jsb/ResponsePlugin.php index 023ba9538..23f982e8a 100644 --- a/src/Plugin/Jsb/ResponsePlugin.php +++ b/src/Plugin/Jsb/ResponsePlugin.php @@ -44,7 +44,6 @@ protected function validateResponse(Rocket $rocket): void && ($destinationOrigin->getStatusCode() < 200 || $destinationOrigin->getStatusCode() >= 300)) { throw new InvalidResponseException(Exception::RESPONSE_CODE_WRONG, '江苏银行返回状态码异常,请检查参数是否错误', $rocket->getDestination()); } - if ($destination instanceof Collection && '000000' !== $destination->get('respCode')) { throw new InvalidResponseException(Exception::RESPONSE_BUSINESS_CODE_WRONG, sprintf('江苏银行返回错误: respCode:%s respMsg:%s', $destination->get('respCode'), $destination->get('respMsg')), $rocket->getDestination()); } diff --git a/tests/Plugin/Jsb/ResponsePluginTest.php b/tests/Plugin/Jsb/ResponsePluginTest.php index 29676efa1..a2bf2f16c 100644 --- a/tests/Plugin/Jsb/ResponsePluginTest.php +++ b/tests/Plugin/Jsb/ResponsePluginTest.php @@ -4,10 +4,13 @@ use GuzzleHttp\Psr7\Response; use Yansongda\Artful\Exception\InvalidResponseException; +use Yansongda\Artful\Plugin\ParserPlugin; use Yansongda\Artful\Rocket; use Yansongda\Pay\Exception\Exception; use Yansongda\Pay\Plugin\Jsb\ResponsePlugin; use Yansongda\Pay\Tests\TestCase; +use Yansongda\Supports\Arr; +use Yansongda\Supports\Collection; class ResponsePluginTest extends TestCase { @@ -24,7 +27,8 @@ public function testNormal() { $body = 'errCode=&field1=&field2=&field3=&orderNo=20240617144526400259379&orderStatus=1&outTradeNo=YC202406170003&partnerId=6a13eab71c4f4b0aa4757eda6fc59710&payUrl=http://weixintest.jsbchina.cn/epcs/qr/login.htm?qrCode=2018060611052793473720240617144526688568&respBizDate=20240617&respCode=000000&respMsg=交易成功&totalFee=0.01&validTime=2&signType=RSA&sign=jN3Ha6J9UUIe9M0L/XeexEdaRL9GB6nMV12wNC7LQvTS6V4nKHj4Qzw6M8cNsA9L0Tb3QFT83B0qO3FJnruDrcHKqBLZb4FkoKKN/WiDBuA2UZQjG4+CBejoGJWfpkWSsei9tXUk36TB27lc2ZlYXSEwuuDwM7M9yvlYysc3fjg='; - $rocket = (new Rocket())->setDestinationOrigin(new Response(200, [], $body)); + $rocket = (new Rocket())->setDestinationOrigin(new Response(200, [], $body)) + ->setDestination(new Collection(Arr::wrapQuery($body))); $result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; }); self::assertSame($rocket, $result); } @@ -35,7 +39,8 @@ public function testCodeWrong() self::expectExceptionCode(Exception::RESPONSE_BUSINESS_CODE_WRONG); $body = 'errCode=1&field1=&field2=&field3=&orderNo=20240617144526400259379&orderStatus=1&outTradeNo=YC202406170003&partnerId=6a13eab71c4f4b0aa4757eda6fc59710&payUrl=http://weixintest.jsbchina.cn/epcs/qr/login.htm?qrCode=2018060611052793473720240617144526688568&respBizDate=20240617&respCode=000001&respMsg=交易成功&totalFee=0.01&validTime=2&signType=RSA&sign=jN3Ha6J9UUIe9M0L/XeexEdaRL9GB6nMV12wNC7LQvTS6V4nKHj4Qzw6M8cNsA9L0Tb3QFT83B0qO3FJnruDrcHKqBLZb4FkoKKN/WiDBuA2UZQjG4+CBejoGJWfpkWSsei9tXUk36TB27lc2ZlYXSEwuuDwM7M9yvlYysc3fjg='; - $rocket = (new Rocket())->setDestinationOrigin(new Response(200, [], $body)); + $rocket = (new Rocket())->setDestinationOrigin(new Response(200, [], $body)) + ->setDestination(new Collection(Arr::wrapQuery($body))); $result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; }); self::assertSame($rocket, $result); @@ -48,7 +53,8 @@ public function testHttpWrong() self::expectExceptionMessage('江苏银行返回状态码异常,请检查参数是否错误'); $body = 'errCode=1&field1=&field2=&field3=&orderNo=20240617144526400259379&orderStatus=1&outTradeNo=YC202406170003&partnerId=6a13eab71c4f4b0aa4757eda6fc59710&payUrl=http://weixintest.jsbchina.cn/epcs/qr/login.htm?qrCode=2018060611052793473720240617144526688568&respBizDate=20240617&respCode=000000&respMsg=交易成功&totalFee=0.01&validTime=2&signType=RSA&sign=jN3Ha6J9UUIe9M0L/XeexEdaRL9GB6nMV12wNC7LQvTS6V4nKHj4Qzw6M8cNsA9L0Tb3QFT83B0qO3FJnruDrcHKqBLZb4FkoKKN/WiDBuA2UZQjG4+CBejoGJWfpkWSsei9tXUk36TB27lc2ZlYXSEwuuDwM7M9yvlYysc3fjg='; - $rocket = (new Rocket())->setDestinationOrigin(new Response(500, [], $body)); + $rocket = (new Rocket())->setDestinationOrigin(new Response(500, [], $body)) + ->setDestination(new Collection(Arr::wrapQuery($body))); $result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; }); self::assertSame($rocket, $result);