update to 2.3.1 version (build 388)

cleanup code and fix a bug
This commit is contained in:
2021-03-18 14:56:35 +08:00
parent 456b102c15
commit e77b9d4970
57 changed files with 179 additions and 508 deletions

View File

@@ -1,256 +0,0 @@
<?php
namespace ZMTest\Mock;
use Swoole\Http\Request;
use Swoole\WebSocket\Frame;
use Swoole\WebSocket\Server;
use ZM\API\ZMRobot;
use ZM\ConnectionManager\ConnectionObject;
use ZM\Context\ContextInterface;
use ZM\Http\Response;
class Context implements ContextInterface
{
/**
* Context constructor.
* @param $cid
*/
public function __construct($cid) { }
/**
* @return Server
*/
public function getServer() {
// TODO: Implement getServer() method.
}
/**
* @return Frame
*/
public function getFrame() {
// TODO: Implement getFrame() method.
}
/**
* @return mixed
*/
public function getData() {
// TODO: Implement getData() method.
}
/**
* @param $data
* @return mixed
*/
public function setData($data) {
// TODO: Implement setData() method.
}
/**
* @return ConnectionObject
*/
public function getConnection() {
// TODO: Implement getConnection() method.
}
/**
* @return int|null
*/
public function getFd() {
// TODO: Implement getFd() method.
}
/**
* @return int
*/
public function getCid() {
// TODO: Implement getCid() method.
}
/**
* @return Response
*/
public function getResponse() {
// TODO: Implement getResponse() method.
}
/**
* @return Request
*/
public function getRequest() {
// TODO: Implement getRequest() method.
}
/**
* @return ZMRobot
*/
public function getRobot() {
// TODO: Implement getRobot() method.
}
/**
* @return mixed
*/
public function getUserId() {
// TODO: Implement getUserId() method.
}
/**
* @return mixed
*/
public function getGroupId() {
// TODO: Implement getGroupId() method.
}
/**
* @return mixed
*/
public function getDiscussId() {
// TODO: Implement getDiscussId() method.
}
/**
* @return string
*/
public function getMessageType() {
// TODO: Implement getMessageType() method.
}
/**
* @return mixed
*/
public function getRobotId() {
// TODO: Implement getRobotId() method.
}
/**
* @return mixed
*/
public function getMessage() {
// TODO: Implement getMessage() method.
}
/**
* @param $msg
* @return mixed
*/
public function setMessage($msg) {
// TODO: Implement setMessage() method.
}
/**
* @param $id
* @return mixed
*/
public function setUserId($id) {
// TODO: Implement setUserId() method.
}
/**
* @param $id
* @return mixed
*/
public function setGroupId($id) {
// TODO: Implement setGroupId() method.
}
/**
* @param $id
* @return mixed
*/
public function setDiscussId($id) {
// TODO: Implement setDiscussId() method.
}
/**
* @param $type
* @return mixed
*/
public function setMessageType($type) {
// TODO: Implement setMessageType() method.
}
/**
* @return mixed
*/
public function getCQResponse() {
// TODO: Implement getCQResponse() method.
}
/**
* @param $msg
* @param bool $yield
* @return mixed
*/
public function reply($msg, $yield = false) {
echo $msg.PHP_EOL;
// TODO: Implement reply() method.
}
/**
* @param $msg
* @param bool $yield
* @return mixed
*/
public function finalReply($msg, $yield = false) {
// TODO: Implement finalReply() method.
}
/**
* @param string $prompt
* @param int $timeout
* @param string $timeout_prompt
* @return mixed
*/
public function waitMessage($prompt = "", $timeout = 600, $timeout_prompt = "") {
// TODO: Implement waitMessage() method.
}
/**
* @param $arg
* @param $mode
* @param $prompt_msg
* @return mixed
*/
public function getArgs(&$arg, $mode, $prompt_msg) {
$r = $arg;
array_shift($r);
return array_shift($r);
// TODO: Implement getArgs() method.
}
/**
* @param $key
* @param $value
* @return mixed
*/
public function setCache($key, $value) {
// TODO: Implement setCache() method.
}
/**
* @param $key
* @return mixed
*/
public function getCache($key) {
// TODO: Implement getCache() method.
}
/**
* @return mixed
*/
public function cloneFromParent() {
// TODO: Implement cloneFromParent() method.
}
/**
* @return mixed
*/
public function copy() {
// TODO: Implement copy() method.
}
}

View File

@@ -1,111 +0,0 @@
<?php
/** @noinspection PhpFullyQualifiedNameUsageInspection */
/** @noinspection PhpComposerExtensionStubsInspection */
global $config;
/** bind host */
$config['host'] = '0.0.0.0';
/** bind port */
$config['port'] = 20001;
/** 框架开到公网或外部的HTTP访问链接通过 DataProvider::getFrameworkLink() 获取 */
$config['http_reverse_link'] = "http://127.0.0.1:" . $config['port'];
/** 框架是否启动debug模式 */
$config['debug_mode'] = false;
/** 存放框架内文件数据的目录 */
$config['zm_data'] = realpath(__DIR__ . "/../") . '/zm_data/';
/** 存放崩溃和运行日志的目录 */
$config['crash_dir'] = $config['zm_data'] . 'crash/';
/** 对应swoole的server->set参数 */
$config['swoole'] = [
'log_file' => $config['crash_dir'] . 'swoole_error.log',
'worker_num' => 8,
'dispatch_mode' => 2,
'max_coroutine' => 30000,
//'task_worker_num' => 4,
//'task_enable_coroutine' => true
];
/** 轻量字符串缓存,默认开启 */
$config['light_cache'] = [
"status" => true,
"size" => 2048, //最多允许储存的条数需要2的倍数
"max_strlen" => 4096, //单行字符串最大长度需要2的倍数
"hash_conflict_proportion" => 0.6 //Hash冲突率越大越好但是需要的内存更多
];
/** MySQL数据库连接信息host留空则启动时不创建sql连接池 */
$config['sql_config'] = [
'sql_host' => '',
'sql_port' => 3306,
'sql_username' => 'name',
'sql_database' => 'db_name',
'sql_password' => '',
'sql_enable_cache' => true,
'sql_reset_cache' => '0300',
'sql_options' => [
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false
],
'sql_no_exception' => false,
'sql_default_fetch_mode' => PDO::FETCH_ASSOC // added in 1.5.6
];
/** CQHTTP连接约定的token */
$config["access_token"] = "";
/** HTTP服务器固定请求头的返回 */
$config['http_header'] = [
'X-Powered-By' => 'zhamao-framework',
'Content-Type' => 'text/html; charset=utf-8'
];
/** HTTP服务器在指定状态码下回复的页面默认 */
$config['http_default_code_page'] = [
'404' => '404.html'
];
/** zhamao-framework在框架启动时初始化的atomic们 */
$config['init_atomics'] = [
//'custom_atomic_name' => 0, //自定义添加的Atomic
];
/** 终端日志显示等级0-4 */
$config["info_level"] = 2;
/** 自动保存计时器的缓存保存时间(秒) */
$config['auto_save_interval'] = 900;
/** 上下文接口类 implemented from ContextInterface */
$config['context_class'] = \ZMTest\Mock\Context::class;
/** 静态文件访问 */
$config['static_file_server'] = [
'status' => false,
'document_root' => realpath(__DIR__ . "/../") . '/resources/html',
'document_index' => [
'index.html'
]
];
/** 注册 Swoole Server 事件注解的类列表 */
$config['server_event_handler_class'] = [
\ZM\Event\ServerEventHandler::class,
];
/** 注册自定义指令的类 */
$config['command_register_class'] = [
//\Custom\Command\CustomCommand::class
];
/** 服务器启用的外部第三方和内部插件 */
$config['modules'] = [
'onebot' => true, // QQ机器人事件解析器如果取消此项则默认为 true 开启状态,否则你手动填写 false 才会关闭
];
return $config;

View File

@@ -40,10 +40,7 @@ class EventDispatcherTest extends TestCase
$dispatcher->setRuleFunction(function ($v) { return $v->match == "你好"; });
//$dispatcher->setRuleFunction(fn ($v) => $v->match == "qwe");
ob_start();
try {
$dispatcher->dispatchEvents();
} catch (AnnotationException $e) {
}
$dispatcher->dispatchEvents();
$r = ob_get_clean();
echo $r;
$this->assertStringContainsString("你好啊", $r);