+ [misc] Add unit tests for webhookTao::getDingdingSecret() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ class webhookTest
|
||||
{
|
||||
global $tester;
|
||||
$this->objectModel = $tester->loadModel('webhook');
|
||||
$this->objectTao = $tester->loadTao('webhook');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,4 +465,23 @@ class webhookTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getDingdingSecret method.
|
||||
*
|
||||
* @param object $webhook
|
||||
* @access public
|
||||
* @return object|false
|
||||
*/
|
||||
public function getDingdingSecretTest($webhook)
|
||||
{
|
||||
$reflection = new ReflectionClass($this->objectTao);
|
||||
$method = $reflection->getMethod('getDingdingSecret');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectTao, $webhook);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 webhookTao::getDingdingSecret();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行webhookTest模块的getDingdingSecretTest方法,参数是$normalWebhook 属性url @https://oapi.dingtalk.com/
|
||||
- 执行webhookTest模块的getDingdingSecretTest方法,参数是$missingAgentId 属性agentId @『钉钉AgentId』不能为空。
|
||||
- 执行webhookTest模块的getDingdingSecretTest方法,参数是$missingAppKey 属性appKey @『钉钉AppKey』不能为空。
|
||||
- 执行webhookTest模块的getDingdingSecretTest方法,参数是$missingAppSecret 属性appSecret @『钉钉AppSecret』不能为空。
|
||||
- 执行webhookTest模块的getDingdingSecretTest方法,参数是$emptyWebhook 属性agentId @『钉钉AgentId』不能为空。
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/webhook.unittest.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$webhookTest = new webhookTest();
|
||||
|
||||
// 创建完整的正常webhook对象
|
||||
$normalWebhook = new stdClass();
|
||||
$normalWebhook->agentId = '123456789';
|
||||
$normalWebhook->appKey = 'testappkey';
|
||||
$normalWebhook->appSecret = 'testappsecret';
|
||||
|
||||
r($webhookTest->getDingdingSecretTest($normalWebhook)) && p('url') && e('https://oapi.dingtalk.com/');
|
||||
|
||||
// 缺少agentId
|
||||
$missingAgentId = new stdClass();
|
||||
$missingAgentId->agentId = '';
|
||||
$missingAgentId->appKey = 'testappkey';
|
||||
$missingAgentId->appSecret = 'testappsecret';
|
||||
|
||||
r($webhookTest->getDingdingSecretTest($missingAgentId)) && p('agentId') && e('『钉钉AgentId』不能为空。');
|
||||
|
||||
// 缺少appKey
|
||||
$missingAppKey = new stdClass();
|
||||
$missingAppKey->agentId = '123456789';
|
||||
$missingAppKey->appKey = '';
|
||||
$missingAppKey->appSecret = 'testappsecret';
|
||||
|
||||
r($webhookTest->getDingdingSecretTest($missingAppKey)) && p('appKey') && e('『钉钉AppKey』不能为空。');
|
||||
|
||||
// 缺少appSecret
|
||||
$missingAppSecret = new stdClass();
|
||||
$missingAppSecret->agentId = '123456789';
|
||||
$missingAppSecret->appKey = 'testappkey';
|
||||
$missingAppSecret->appSecret = '';
|
||||
|
||||
r($webhookTest->getDingdingSecretTest($missingAppSecret)) && p('appSecret') && e('『钉钉AppSecret』不能为空。');
|
||||
|
||||
// 所有参数都为空
|
||||
$emptyWebhook = new stdClass();
|
||||
$emptyWebhook->agentId = '';
|
||||
$emptyWebhook->appKey = '';
|
||||
$emptyWebhook->appSecret = '';
|
||||
|
||||
r($webhookTest->getDingdingSecretTest($emptyWebhook)) && p('agentId') && e('『钉钉AgentId』不能为空。');
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
title: 钉钉Webhook密钥配置测试数据
|
||||
desc: getDingdingSecret方法的测试数据配置
|
||||
author: Claude Code
|
||||
version: 1.0
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: webhook ID
|
||||
range: 1-10
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: type
|
||||
note: webhook类型
|
||||
range: dingding
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: name
|
||||
note: webhook名称
|
||||
range: 'dingding_test{1-10}'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: url
|
||||
note: webhook URL
|
||||
range: 'https://test.dingding.com/api{1-10}'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: agentId
|
||||
note: 钉钉应用ID
|
||||
range: '123456{1-10}'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: appKey
|
||||
note: 钉钉应用Key
|
||||
range: 'dingapp{1-10}'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: appSecret
|
||||
note: 钉钉应用密钥
|
||||
range: 'secret{1-10}key'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: secret
|
||||
note: 处理后的密钥JSON
|
||||
range: '{}'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: contentType
|
||||
note: 内容类型
|
||||
range: 'application/json'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: sendType
|
||||
note: 发送类型
|
||||
range: 'sync'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: params
|
||||
note: 参数配置
|
||||
range: 'title,text,mobile'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: createdBy
|
||||
note: 创建者
|
||||
range: 'admin{3},user{7}'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: createdDate
|
||||
note: 创建时间
|
||||
range: '2023-01-01 00:00:00-2023-12-31 23:59:59'
|
||||
format: 'YYYY-MM-DD hh:mm:ss'
|
||||
- field: deleted
|
||||
note: 删除标记
|
||||
range: '0'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
Reference in New Issue
Block a user