diff --git a/module/search/test/lib/tao.class.php b/module/search/test/lib/tao.class.php index ea9e657a14..0f8a9dc741 100644 --- a/module/search/test/lib/tao.class.php +++ b/module/search/test/lib/tao.class.php @@ -328,4 +328,19 @@ class searchTaoTest extends baseTest if(dao::isError()) return dao::getError(); return $result; } + + /** + * Test unify method. + * + * @param string $string + * @param string $to + * @access public + * @return string + */ + public function unifyTest(string $string, string $to = ','): string + { + $result = $this->invokeArgs('unify', [$string, $to]); + if(dao::isError()) return dao::getError(); + return $result; + } } diff --git a/module/search/test/tao/unify.php b/module/search/test/tao/unify.php new file mode 100755 index 0000000000..0a973279a8 --- /dev/null +++ b/module/search/test/tao/unify.php @@ -0,0 +1,37 @@ +#!/usr/bin/env php +unifyTest('hello_world、test-data')) && p() && e('hello,world,test,data'); // 测试将多种特殊符号统一替换为逗号 +r($searchTest->unifyTest('hello_world、test-data', ' ')) && p() && e('hello world test data'); // 测试将特殊符号替换为空格 +r($searchTest->unifyTest('hello___world', ',')) && p() && e('hello,world'); // 测试将多个连续符号合并为一个 +r($searchTest->unifyTest('_hello、world-test_', ',')) && p() && e('hello,world,test'); // 测试去除首尾的目标符号 +r($searchTest->unifyTest('你好、世界。测试')) && p() && e('你好,世界,测试'); // 测试包含中文标点的字符串替换 +r($searchTest->unifyTest('')) && p() && e('0'); // 测试空字符串输入 +r($searchTest->unifyTest('_、-。,', ',')) && p() && e('0'); // 测试仅包含特殊符号的字符串 \ No newline at end of file