格式测试文件代码

This commit is contained in:
oldrind
2016-03-04 22:15:25 +08:00
parent 5bac45f59b
commit 3bb03dfee3
2 changed files with 17 additions and 14 deletions

View File

@@ -1682,7 +1682,7 @@ class Model
} else { } else {
$this->_join($join, $condition); // 兼容原来的join写法 $this->_join($join, $condition); // 兼容原来的join写法
} }
} elseif (in_array(strtoupper($condition), array('INNER', 'LEFT', 'RIGHT', 'ALL'))) { } elseif (in_array(strtoupper($condition), ['INNER', 'LEFT', 'RIGHT', 'ALL'])) {
$this->_join($join, $condition); // 兼容原来的join写法 $this->_join($join, $condition); // 兼容原来的join写法
} else { } else {
$prefix = $this->tablePrefix; $prefix = $this->tablePrefix;

View File

@@ -60,7 +60,9 @@ class modelTest extends \PHPUnit_Framework_TestCase
], ],
'user' => [ 'user' => [
['username', [&$this, 'checkName'], '用户名长度为5到15个字符', 'callback', 'username'], ['username', [&$this, 'checkName'], '用户名长度为5到15个字符', 'callback', 'username'],
['username', function ($value, $data) {return 'admin' == $value ? '此用户名已被使用' : true;}], ['username', function ($value, $data) {
return 'admin' == $value ? '此用户名已被使用' : true;
}],
'nickname' => ['require', '请填昵称'], 'nickname' => ['require', '请填昵称'],
'password' => ['[\w-]{6,15}', '密码长度为6到15个字符'], 'password' => ['[\w-]{6,15}', '密码长度为6到15个字符'],
'repassword' => ['password', '两次密码不一到致', 'confirm'], 'repassword' => ['password', '两次密码不一到致', 'confirm'],
@@ -382,7 +384,8 @@ EOF;
$data = [ $data = [
'1' => 'test', '1' => 'test',
'2' => 'test2', '2' => 'test2',
]; $this->assertEquals($data, $result); ];
$this->assertEquals($data, $result);
$time = $user_model->where(['status' => 1])->cache('user_create_time')->getField('create_time'); $time = $user_model->where(['status' => 1])->cache('user_create_time')->getField('create_time');
$ids = $user_model->where(['status' => 1])->cache('user_id')->getField('id', true); $ids = $user_model->where(['status' => 1])->cache('user_id')->getField('id', true);