diff --git a/module/custom/test/custom.class.php b/module/custom/test/custom.class.php index 640d4704c3..1a7f5b0e8d 100644 --- a/module/custom/test/custom.class.php +++ b/module/custom/test/custom.class.php @@ -8,17 +8,17 @@ class customTest } /** + * 设置自定义语言项。 * Test set value of an item. * - * @param string $path - * @param string $value + * @param string $path zh-cn.story.soucreList.customer.1 + * @param string $value * @access public - * @return object|int + * @return object|array|bool */ - public function setItemTest($path, $value = '') + public function setItemTest(string $path, string $value = ''): object|array|bool { $objects = $this->objectModel->setItem($path, $value); - if(dao::isError()) return dao::getError(); $level = substr_count($path, '.'); @@ -28,8 +28,7 @@ class customTest if($level == 3) list($lang, $module, $section, $key) = explode('.', $path); if($level == 4) list($lang, $module, $section, $key, $system) = explode('.', $path); - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_LANG)->where('`lang`')->eq($lang)->andWhere('`module`')->eq($module)->andWhere('`key`')->eq($key)->fetch(); + $objects = $this->objectModel->dao->select('*')->from(TABLE_LANG)->where('`lang`')->eq($lang)->andWhere('`module`')->eq($module)->andWhere('`key`')->eq($key)->fetch(); } return $objects; diff --git a/module/custom/test/model/setitem.php b/module/custom/test/model/setitem.php index 6b41cd0fde..54815c5baa 100755 --- a/module/custom/test/model/setitem.php +++ b/module/custom/test/model/setitem.php @@ -1,35 +1,31 @@ #!/usr/bin/env php setItem(); +timeout=0 cid=1 -pid=1 - -测试path中.出现的个数为0,value正常存在,不能保存 >> 0 -测试path中.出现的个数为1,value正常存在,不能保存 >> 0 -测试path中.出现的个数为2,value正常存在,能保存 >> zh-cn,story,categoryList,功能 -测试path中.出现的个数为2,value为空,能保存 >> zh-cn,story,categoryList, -测试path中.出现的个数为3,value正常存在,能保存 >> zh-cn,story,feature,功能 -测试path中.出现的个数为3,value为空,能保存 >> zh-cn,story,feature, -测试path中.出现的个数为4,value正常存在,能保存 >> zh-cn,story,feature,功能 -测试path中.出现的个数为5,value为空,能保存 >> zh-cn,story,feature, */ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/custom.class.php'; + +zdTable('lang')->gen(0); +zdTable('user')->gen(5); +su('admin'); + $path = array('zh-cn', 'zh-cn.story', 'zh-cn.story.categoryList', 'zh-cn.story.categoryList.feature', 'zh-cn.story.categoryList.feature.1'); $value = array('功能', ''); -$custom = new customTest(); +$customTester = new customTest(); +r($customTester->setItemTest($path[0], $value[0])) && p() && e('0'); // 测试path中.出现的个数为0,value正常存在,不能保存 +r($customTester->setItemTest($path[1], $value[0])) && p() && e('0'); // 测试path中.出现的个数为1,value正常存在,不能保存 +r($customTester->setItemTest($path[2], $value[0])) && p('lang,module,key,value') && e('zh-cn,story,categoryList,功能'); // 测试path中.出现的个数为2,value正常存在,能保存 +r($customTester->setItemTest($path[2], $value[1])) && p('lang,module,key,value') && e('zh-cn,story,categoryList,~~'); // 测试path中.出现的个数为2,value为空,能保存 +r($customTester->setItemTest($path[3], $value[0])) && p('lang,module,key,value') && e('zh-cn,story,feature,功能'); // 测试path中.出现的个数为3,value正常存在,能保存 +r($customTester->setItemTest($path[3], $value[1])) && p('lang,module,key,value') && e('zh-cn,story,feature,~~'); // 测试path中.出现的个数为3,value为空,能保存 +r($customTester->setItemTest($path[4], $value[0])) && p('lang,module,key,value') && e('zh-cn,story,feature,功能'); // 测试path中.出现的个数为4,value正常存在,能保存 +r($customTester->setItemTest($path[4], $value[1])) && p('lang,module,key,value') && e('zh-cn,story,feature,N/A'); // 测试path中.出现的个数为5,value为空,能保存 -r($custom->setItemTest($path[0], $value[0])) && p() && e('0'); //测试path中.出现的个数为0,value正常存在,不能保存 -r($custom->setItemTest($path[1], $value[0])) && p() && e('0'); //测试path中.出现的个数为1,value正常存在,不能保存 -r($custom->setItemTest($path[2], $value[0])) && p('lang,module,key,value') && e('zh-cn,story,categoryList,功能'); //测试path中.出现的个数为2,value正常存在,能保存 -r($custom->setItemTest($path[2], $value[1])) && p('lang,module,key,value') && e('zh-cn,story,categoryList,'); //测试path中.出现的个数为2,value为空,能保存 -r($custom->setItemTest($path[3], $value[0])) && p('lang,module,key,value') && e('zh-cn,story,feature,功能'); //测试path中.出现的个数为3,value正常存在,能保存 -r($custom->setItemTest($path[3], $value[1])) && p('lang,module,key,value') && e('zh-cn,story,feature,'); //测试path中.出现的个数为3,value为空,能保存 -r($custom->setItemTest($path[4], $value[0])) && p('lang,module,key,value') && e('zh-cn,story,feature,功能'); //测试path中.出现的个数为4,value正常存在,能保存 -r($custom->setItemTest($path[4], $value[1])) && p('lang,module,key,value') && e('zh-cn,story,feature,'); //测试path中.出现的个数为5,value为空,能保存 +zdTable('lang')->gen(0);