From d7e4ae93147f6358c6284e3499483ec697bbec1f Mon Sep 17 00:00:00 2001 From: yansongda Date: Wed, 21 Jul 2021 22:23:36 +0800 Subject: [PATCH] update --- src/Functions.php | 4 ++-- tests/FunctionTest.php | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Functions.php b/src/Functions.php index 3fac10e..dc25e9e 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -83,7 +83,7 @@ if (!function_exists('verify_alipay_sign')) { { $public = get_alipay_config($params)->get('alipay_public_cert_path'); - if (is_null($public)) { + if (empty($public)) { throw new InvalidConfigException(InvalidConfigException::ALIPAY_CONFIG_ERROR, 'Missing Alipay Config -- [alipay_public_cert_path]'); } @@ -175,7 +175,7 @@ if (!function_exists('get_wechat_sign')) { { $privateKey = get_wechat_config($params)->get('mch_secret_cert'); - if (is_null($privateKey)) { + if (empty($privateKey)) { throw new InvalidConfigException(InvalidConfigException::WECHAT_CONFIG_ERROR, 'Missing Wechat Config -- [mch_secret_cert]'); } diff --git a/tests/FunctionTest.php b/tests/FunctionTest.php index c1b534f..cf0cc83 100644 --- a/tests/FunctionTest.php +++ b/tests/FunctionTest.php @@ -91,7 +91,7 @@ class FunctionTest extends TestCase $config1 = [ 'alipay' => [ 'default' => [ - // 'alipay_public_cert_path' => __DIR__.'/Cert/alipayCertPublicKey_RSA2.crt' + 'alipay_public_cert_path' => '' ], ] ]; @@ -174,6 +174,20 @@ class FunctionTest extends TestCase 'KzIgMgiop3nQJNdBVR2Xah/JUwVBLDFFajyXPiSN8b8YAYEA4FuWfaCgFJ52+WFed+PhOYWx/ZPih4RaEuuSdYB8eZwYUx7RZGMQZk0bKCctAjjPuf4pJN+f/WsXKjPIy3diqF5x7gyxwSCaKWP4/KjsHNqgQpiC8q1uC5xmElzuhzSwj88LIoLtkAuSmtUVvdAt0Nz41ECHZgHWSGR32TfBo902r8afdaVKkFde8IoqcEJJcp6sMxdDO5l9R5KEWxrJ1SjsXVrb0IPH8Nj7e6hfhq7pucxojPpzsC+ZWAYvufZkAQx3kTiFmY87T+QhkP9FesOfWvkIRL4E6MP6ug==', get_wechat_sign($params, $contents) ); + + // test config error + $config1 = [ + 'wechat' => [ + 'default' => [ + 'mch_secret_cert' => '' + ], + ] + ]; + Pay::config(array_merge($config1, ['_force' => true])); + + self::expectException(InvalidConfigException::class); + self::expectExceptionCode(InvalidConfigException::WECHAT_CONFIG_ERROR); + get_wechat_sign([], '', ''); } public function testVerifyWechatSign()