* Add test case.

This commit is contained in:
caoyanyi
2023-02-24 15:50:59 +08:00
parent 9c652d0d35
commit f6779df33b
2 changed files with 61 additions and 0 deletions
+15
View File
@@ -90,6 +90,21 @@ class devTest
return empty($result) ? 0 : $result;
}
/**
* Test get customed lang method.
*
* @param string $type
* @param string $module
* @param string $method
* @access public
* @return int|array
*/
public function getCustomedLangTest($type = 'common', $module = '', $method = '')
{
$result = $this->objectModel->getCustomedLang($type, $module, $method);
return empty($result) ? 0 : $result;
}
/**
* Get nav lang.
*
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/dev.class.php';
su('admin');
$ztLang = zdTable('lang');
$ztLang->id->range('1-3');
$ztLang->lang->range('zh-cn');
$ztLang->module->range('common,myMenu,my');
$ztLang->section->range('``,menu,featureBar-todo');
$ztLang->key->range('productCommon,index,all');
$ztLang->value->range('1-3')->prefix('测试');
$ztLang->gen(3);
/**
title=测试 devModel::getCustomedLang();
cid=1
pid=1
错误的类型返回数据 >> 0
正确的类型返回数据 >> 测试1
正确的类型,错误的模块返回数据 >> 0
正确的类型,正确的模块返回数据 >> 测试2
正确的类型,正确的模块,错误的方法返回数据 >> 0
正确的类型,正确的模块,正确的方法返回数据 >> 测试3
*/
$failModule = 'module';
$realModule = 'my';
$failMethod = 'method';
$realMethod = 'todo';
$devTester = new devTest();
r($devTester->getCustomedLangTest('test')) && p() && e("0"); // 错误的类型返回数据
r($devTester->getCustomedLangTest('common')) && p('productCommon') && e("测试1"); // 正确的类型返回数据
r($devTester->getCustomedLangTest('second', $failModule)) && p() && e("0"); // 正确的类型,错误的模块返回数据
r($devTester->getCustomedLangTest('second', $realModule)) && p('menu_index') && e("测试2"); // 正确的类型,正确的模块返回数据
r($devTester->getCustomedLangTest('tag', $realModule, $failMethod)) && p() && e("0"); // 正确的类型,正确的模块,错误的方法返回数据
r($devTester->getCustomedLangTest('tag', $realModule, $realMethod)) && p('featureBar-todo_all') && e("测试3"); // 正确的类型,正确的模块,正确的方法返回数据