assertInstanceOf(ConfigInterface::class, $config); } } /** * 测试构造配置对象时会校验必填字段。 */ public function testConfigValidateRequiredFieldsOnConstruct(): void { $this->expectException(WechatException::class); $this->expectExceptionMessage('不能为空'); new WechatPlatformConfig('', 'secret'); } /** * 测试通过数组构造配置对象时会校验必填字段。 */ public function testConfigValidateRequiredFieldsFromArray(): void { $this->expectException(WechatException::class); $this->expectExceptionMessage('不能为空'); WechatPaymentConfig::fromArray(['appid' => 'wx_app']); } /** * 测试支付宝支付配置 fromArray 返回子类实例。 */ public function testAlipayPaymentFromArrayReturnsChildClass(): void { $config = AlipayPaymentConfig::fromArray([ 'appid' => 'ali_pay', 'private_key' => 'private-key', ]); $this->assertInstanceOf(AlipayPaymentConfig::class, $config); } }