* Modify installModel::grantPriv, and modify its unit test.
This commit is contained in:
@@ -346,7 +346,8 @@ class install extends control
|
||||
$this->loadModel('common');
|
||||
if($this->config->db->driver == 'dm') $this->install->execDMSQL();
|
||||
|
||||
$this->install->grantPriv();
|
||||
$data = form::data()->get();
|
||||
$this->install->grantPriv($data);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$this->install->updateLang();
|
||||
|
||||
@@ -195,12 +195,17 @@ class installModel extends model
|
||||
* 创建公司并设置管理员。
|
||||
* Create a comapny, set admin.
|
||||
*
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function grantPriv(): bool
|
||||
public function grantPriv(object $data): bool
|
||||
{
|
||||
$data = form::data()->get();
|
||||
/* Check required. */
|
||||
if(empty($data->company)) dao::$errors['company'][] = sprintf($this->lang->error->notempty, $this->lang->install->company);
|
||||
if(empty($data->account)) dao::$errors['account'][] = sprintf($this->lang->error->notempty, $this->lang->install->account);
|
||||
if(empty($data->password)) dao::$errors['password'][] = sprintf($this->lang->error->notempty, $this->lang->install->password);
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$this->loadModel('user');
|
||||
$this->app->loadConfig('admin');
|
||||
|
||||
@@ -7,9 +7,9 @@ timeout=0
|
||||
cid=1
|
||||
|
||||
- 没有提交信息时候的报错信息。
|
||||
- 第company条的0属性 @公司名称不能为空
|
||||
- 第account条的0属性 @管理员帐号不能为空
|
||||
- 第password条的0属性 @管理员密码不能为空
|
||||
- 第company条的0属性 @『公司名称』不能为空。
|
||||
- 第account条的0属性 @『管理员帐号』不能为空。
|
||||
- 第password条的0属性 @『管理员密码』不能为空。
|
||||
- 密码少于六位时的错误信息。第password条的0属性 @密码应该符合规则,长度至少为六位。
|
||||
- 密码比较简单时的错误信息。第password条的0属性 @密码必须6位及以上,且包含大小写字母、数字。
|
||||
- 正确添加时是否有错误信息。 @0
|
||||
@@ -22,19 +22,23 @@ su('admin');
|
||||
global $tester, $config;
|
||||
$tester->loadModel('install');
|
||||
|
||||
$tester->install->grantPriv();
|
||||
r(dao::getError()) && p('company:0;account:0;password:0') && e('公司名称不能为空,管理员帐号不能为空,管理员密码不能为空'); // 没有提交信息时候的报错信息。
|
||||
$data = new stdclass();
|
||||
$data->company = '';
|
||||
$data->account = '';
|
||||
$data->password = '';
|
||||
$tester->install->grantPriv($data);
|
||||
r(dao::getError()) && p('company:0;account:0;password:0') && e('『公司名称』不能为空。,『管理员帐号』不能为空。,『管理员密码』不能为空。'); // 没有提交信息时候的报错信息。
|
||||
|
||||
$_POST['company'] = '我的公司';
|
||||
$_POST['account'] = 'admin';
|
||||
$_POST['password'] = '1';
|
||||
$tester->install->grantPriv();
|
||||
$data->company = '我的公司';
|
||||
$data->account = 'admin';
|
||||
$data->password = '1';
|
||||
$tester->install->grantPriv($data);
|
||||
r(dao::getError()) && p('password:0') && e('密码应该符合规则,长度至少为六位。'); // 密码少于六位时的错误信息。
|
||||
|
||||
$_POST['password'] = '123haha';
|
||||
$tester->install->grantPriv();
|
||||
$data->password = '123haha';
|
||||
$tester->install->grantPriv($data);
|
||||
r(dao::getError()) && p('password:0') && e('密码必须6位及以上,且包含大小写字母、数字。'); // 密码比较简单时的错误信息。
|
||||
|
||||
$_POST['password'] = 'Admin123';
|
||||
$tester->install->grantPriv();
|
||||
$data->password = 'Admin123';
|
||||
$tester->install->grantPriv($data);
|
||||
r(dao::getError()) && p() && e(0); // 正确添加时是否有错误信息。
|
||||
|
||||
Reference in New Issue
Block a user