* [task#127261 doing,4h,2h] Add new function
This commit is contained in:
@@ -46,10 +46,81 @@ class batchEditTester extends tester
|
||||
{
|
||||
$info = sprintf($this->lang->error->notempty, $this->lang->execution->name);
|
||||
if($text == $info) return $this->success('执行名称为空提示信息正确');
|
||||
return $this->failed('执行名称为空提示信息不正确');
|
||||
return $this->failed('执行名称为空提示信息错误');
|
||||
}
|
||||
$info = sprintf($this->lang->error->repeat, $this->lang->execution->name, $execution['name']);
|
||||
if($text == $info) return $this->success('执行名称重复提示信息正确');
|
||||
return $this->failed('执行名称重复提示信息不正确');
|
||||
return $this->failed('执行名称重复提示信息错误');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字符串中的日期。
|
||||
* Delete date in string.
|
||||
*
|
||||
* @param string $str
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function deleteDate($str)
|
||||
{
|
||||
preg_match_all('/(\d{4}-\d{2}-\d{2})/', $str, $matches);
|
||||
$date = $matches[0][0];
|
||||
$params = str_replace($date, '', $str);
|
||||
$params = trim($params);
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查日期字段。
|
||||
* Check begin and end date field.
|
||||
*
|
||||
* @param array $execution
|
||||
* @param string $type begin|end|other
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function checkDate($execution, $type)
|
||||
{
|
||||
$id = $this->inputFields($execution);
|
||||
$form = $this->loadPage();
|
||||
|
||||
$beginTipDom = "begin[{$id}]Tip";
|
||||
$endTipDom = "end[{$id}]Tip";
|
||||
|
||||
if($type == 'begin')
|
||||
{
|
||||
$beginText = $form->dom->$beginTipDom->getText();
|
||||
/* 检查计划开始日期为空报错 */
|
||||
if($execution['begin'] == '')
|
||||
{
|
||||
$beginInfo = sprintf($this->lang->error->notempty, $this->lang->execution->begin);
|
||||
if($beginText == $beginInfo) return $this->success('执行开始日期为空提示信息正确');
|
||||
return $this->failed('执行开始日期为空提示信息错误');
|
||||
}
|
||||
/* 检查计划开始日期小于项目开始日期报错 */
|
||||
$beginInfo = sprintf($this->lang->execution->errorLesserProject, '');
|
||||
if($beginInfo == $this->deleteDate($beginText)) return $this->success('执行开始日期小于项目开始日期提示信息正确');
|
||||
return $this->failed('执行开始日期小于项目开始日期提示信息错误');
|
||||
}
|
||||
if($type == 'end')
|
||||
{
|
||||
$endText = $form->dom->$endTipDom->getText();
|
||||
/* 检查计划结束日期为空报错 */
|
||||
if($execution['end'] == '')
|
||||
{
|
||||
$endInfo = sprintf($this->lang->error->notempty, $this->lang->execution->end);
|
||||
if($endText == $endInfo) return $this->success('执行结束日期为空提示信息正确');
|
||||
return $this->failed('执行结束日期为空提示信息错误');
|
||||
}
|
||||
/* 检查计划结束日期大于项目结束日期报错 */
|
||||
$endInfo = sprintf($this->lang->execution->errorGreaterProject, '');
|
||||
if($endInfo == $this->deleteDate($endText)) return $this->success('执行结束日期大于项目结束日期提示信息正确');
|
||||
return $this->failed('执行结束日期大于项目结束日期提示信息错误');
|
||||
}
|
||||
/* 检查计划开始日期大于计划结束日期报错 */
|
||||
$endText = $form->dom->$endTipDom->getText();
|
||||
$endInfo = sprintf($this->lang->execution->errorLesserPlan, $execution['end'], $execution['begin']);
|
||||
if($endInfo == $endText) return $this->success('执行结束日期小于执行开始日期提示信息正确');
|
||||
return $this->failed('执行结束日期小于执行开始日期提示信息错误');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user