diff --git a/module/execution/test/lib/editexecution.ui.class.php b/module/execution/test/lib/editexecution.ui.class.php index d24baf67fe..16aeb8e239 100644 --- a/module/execution/test/lib/editexecution.ui.class.php +++ b/module/execution/test/lib/editexecution.ui.class.php @@ -11,19 +11,96 @@ class editExecutionTester extends tester */ public function editFields($execution) { - $form = $this->initForm('execution', 'view', array('execution' => '2'), 'appIframe-execution'); + $form = $this->initForm('execution', 'view', array('execution' => $execution['id']), 'appIframe-execution'); $form->wait(1); $form->dom->edit->click(); - if(isset($execution['project'])) $form->dom->project->picker($execution['project']); $form = $this->loadPage(); $form->wait(1); - if(isset($execution['name'])) $form->dom->name->setValue($execution['name']); - if(isset($execution['begin'])) $form->dom->begin->datePicker($execution['begin']); - if(isset($execution['end'])) $form->dom->end->datePicker($execution['end']); + if(isset($execution['name'])) $form->dom->name->setValue($execution['name']); + if(isset($execution['begin'])) $form->dom->begin->datePicker($execution['begin']); + if(isset($execution['end'])) $form->dom->end->datePicker($execution['end']); if(isset($execution['products'])) $form->dom->products->picker($execution['products']); $form->dom->submit->click(); $form->wait(1); - return $form; + } + + /** + * 执行名称已存在时获取提示信息。 + * Get error info of repeat name. + * + * @param string $type sprint|stage|kanban + * @access public + * @return bool + */ + public function checkRepeatInfo($type = 'sprint') + { + $form = $this->loadPage(); + $form->wait(1); + if(!is_object($form->dom->nameTip)) return $this->failed('执行名称重复没有提示信息'); + $text = $form->dom->nameTip->getText(); + if($type == 'kanban') + { + $info = sprintf($this->lang->error->repeat, $form->dom->nameLabel->getText(), $form->dom->name->getValue()); + } + else + { + $info = sprintf($this->lang->error->repeat, $form->dom->nameLabel->getText(), $form->dom->name->getValue()); + } + if($text != $info) return $this->failed('编辑执行表单页提示信息不正确'); + return $this->success('编辑执行表单页提示信息正确'); + } + + /** + * 计划起止日期错误时获取提示信息。 + * Get error info of begin and end date. + * + * @param string $dateType begin|end + * @access public + * @return bool + */ + public function checkDateInfo($dateType = 'end') + { + $form = $this->loadPage(); + $form->wait(1); + + if($dateType == 'begin') + { + if(!is_object($form->dom->beginTip)) return $thid->failed('开始日期错误没有提示信息'); + $text = $form->dom->beginTip->getText(); + $info = sprintf($this->lang->execution->errorCommonBegin, ''); + } + else + { + if(!is_object($form->dom->endTip)) return $thid->failed('完成日期错误没有提示信息'); + $text = $form->dom->endTip->getText(); + $info = sprintf($this->lang->execution->errorCommonEnd, ''); + } + + /* 获取页面返回信息中除日期外的内容 */ + preg_match_all('/(\d{4}-\d{2}-\d{2})/', $text, $matches); + $date = $matches[0]; + $params = str_replace($date, '', $text); + $params = trim($params); + + if($params != $info) return $this->failed('编辑执行表单页提示信息不正确'); + return $this->success('编辑执行表单页提示信息正确'); + } + + /** + * 关联产品必填时获取提示信息。 + * Get error info of manage products. + * + * @access public + * @return bool + */ + public function checkManageProductsInfo() + { + $form = $this->loadPage(); + $form->dom->waitElement($form->dom->xpath['productsTip'], 10); + $text = $form->dom->productsTip->getText(); + $info = $this->lang->project->errorNoProducts; + if($text != $info) return $this->failed('编辑执行表单页提示信息不正确'); + return $this->success('编辑执行表单页提示信息正确'); } /** @@ -38,12 +115,61 @@ class editExecutionTester extends tester { $form = $this->editFields($execution); /* 根据编辑弹窗中的保存按钮是否存在,判断是否编辑成功 */ - if($form->dom->submit === true) return $this->failed("编辑执行失败"); + if(is_object($form->dom->submit)) return $this->failed("编辑执行失败"); /* 查看相关内容是否正确 */ $viewPage = $this->loadPage('execution', 'view'); - if(isset($execution['name']) && ($viewPage->dom->executionName->getText() != $execution['name'])) return $this->failed('编辑后执行名称错误'); - if(isset($execution['begin']) && ($viewPage->dom->plannedBegin->getText() != $execution['begin'])) return $this->failed('编辑后计划开始时间错误'); - if(isset($execution['end']) && ($viewPage->dom->plannedEnd->getText() != $execution['end'])) return $this->failed('编辑后计划完成时间错误'); + $viewPage->wait(1); + if($this->checkFormTips('execution')) return $this->success('编辑执行表单页提示信息正确'); + if(isset($execution['name']) && ($viewPage->dom->executionName->getText() != $execution['name'])) return $this->failed('编辑后执行名称错误'); + if(isset($execution['begin']) && ($viewPage->dom->plannedBegin->getText() != $execution['begin'])) return $this->failed('编辑后计划开始时间错误'); + if(isset($execution['end']) && ($viewPage->dom->plannedEnd->getText() != $execution['end'])) return $this->failed('编辑后计划完成时间错误'); + if(isset($execution['status']) && ($viewPage->dom->status->getText() != $execution['status'])) return $this->failed('编辑后状态错误'); + if(isset($execution['product']) && ($viewPage->dom->linckedProducta->getText() != $execution['products'])) return $this->failed('编辑后产品错误'); return $this->success('编辑执行成功'); } + + /** + * 执行名称已存在编辑执行。 + * Edit execution with repeat name. + * + * @param array $execution + * @param string $type sprint|stage|kanban + * @access public + * @return object + */ + public function editWithRepeatName($execution, $type = 'sprint') + { + $this->editFields($execution); + return $this->checkRepeatInfo($type); + } + + /** + * 执行起止日期错误编辑执行。 + * Edit execution with date error. + * + * @param array $execution + * @param string $dateType begin|end + * @access public + * @return object + */ + public function editWithDateError($execution, $dateType = 'end') + { + $this->editFields($execution); + return $this->checkDateInfo($dateType); + } + + /** + * 执行关联产品必填,关联产品为空时编辑执行。 + * Edit execution with no manage products. + * + * @param array $execution + * @access public + * @return object + */ + public function editWithNoProducts($execution) + { + $this->editFields($execution); + return $this->checkManageProductsInfo(); + } + } diff --git a/module/execution/test/ui/createexecution.php b/module/execution/test/ui/createexecution.php index d1a1ccda31..3f555ffa8b 100755 --- a/module/execution/test/ui/createexecution.php +++ b/module/execution/test/ui/createexecution.php @@ -13,7 +13,7 @@ include '../lib/createexecution.ui.class.php'; $project = zenData('project'); $project->id->range('1-100'); -$project->project->range('0, 1'); +$project->project->range('0'); $project->model->range('scrum, waterfall, kanban'); $project->type->range('project'); $project->auth->range('extend'); diff --git a/module/execution/test/ui/editexecution.php b/module/execution/test/ui/editexecution.php index 883fd00ba3..c69f1e7896 100755 --- a/module/execution/test/ui/editexecution.php +++ b/module/execution/test/ui/editexecution.php @@ -12,35 +12,137 @@ chdir(__DIR__); include '../lib/editexecution.ui.class.php'; $project = zenData('project'); -$project->id->range('1-100'); -$project->project->range('0, 1'); -$project->model->range('scrum, []'); -$project->type->range('project, sprint'); -$project->auth->range('extend, []'); -$project->storyType->range('story, []'); -$project->parent->range('0, 1'); -$project->path->range('`,1,`, `,1,2,`'); +$project->id->range('1-10'); +$project->project->range('0'); +$project->model->range('scrum, waterfall, kanban'); +$project->type->range('project'); +$project->auth->range('extend'); +$project->storyType->range('story'); +$project->parent->range('0'); +$project->path->range('`,1,`, `,2,`, `,3,`'); $project->grade->range('1'); -$project->name->range('敏捷项目, 执行'); -$project->begin->range('(-2M)-(-M):1D')->type('timestamp')->format('YY/MM/DD'); -$project->end->range('(+2M)-(+3M):1D')->type('timestamp')->format('YY/MM/DD'); +$project->name->range('敏捷项目, 瀑布项目, 看板项目'); +$project->begin->range('(-6M)-(-5M):1D')->type('timestamp')->format('YY/MM/DD'); +$project->end->range('(+5M)-(+6M):1D')->type('timestamp')->format('YY/MM/DD'); $project->openedBy->range('user1'); $project->acl->range('open'); -$project->status->range('doing'); -$project->gen(2); +$project->status->range('wait'); +$project->gen(3); + +$execution = zenData('project'); +$execution->id->range('20-100'); +$execution->project->range('1{2}, 2{2}, 3{2}'); +$execution->model->range('[]'); +$execution->type->range('sprint{2}, stage{2}, kanban{2}'); +$execution->auth->range('[]'); +$execution->storyType->range('[]'); +$execution->parent->range('1{2}, 2{2}, 3{2}'); +$execution->path->range('`,1,20,`, `,1,21,`, `,2,22,`, `,2,23,`, `,3,24,`, `,3,25,`'); +$execution->grade->range('1'); +$execution->name->range('执行1, 执行2, 阶段1, 阶段2, 看板1, 看板2'); +$execution->begin->range('(-2M)-(-M):1D')->type('timestamp')->format('YY/MM/DD'); +$execution->end->range('(+2M)-(+3M):1D')->type('timestamp')->format('YY/MM/DD'); +$execution->openedBy->range('user1'); +$execution->acl->range('open'); +$execution->status->range('wait'); +$execution->gen(6, false); + +$product = zenData('product'); +$product->id->range('1-100'); +$product->name->range('产品1, 产品2'); +$product->type->range('normal'); +$product->gen(2); + +$projectProduct = zenData('projectproduct'); +$projectProduct->project->range('1-3, 20-25'); +$projectProduct->product->range('1{9}, 2{3}'); +$projectProduct->branch->range('0'); +$projectProduct->plan->range('0'); +$projectProduct->gen(12); $tester = new editExecutionTester(); $tester->login(); $execution = array( '0' => array( - 'name' => '编辑测试执行1', - 'project' => '敏捷项目', - 'begin' => date('Y-m-d', strtotime('+1 days')), - 'end' => date('Y-m-d', strtotime('+3 days')), - 'products' => '', + 'id' => '20', + 'name' => '测试执行1', + 'begin' => date('Y-m-d', strtotime('+1 days')), + 'end' => date('Y-m-d', strtotime('+3 days')), ), + '1' => array( + 'id' => '24', + 'name' => '测试看板1', + 'begin' => date('Y-m-d'), + 'end' => date('Y-m-d', strtotime('+2 days')), + ), + '2' => array( + 'id' => '20', + 'name' => '', + 'begin' => date('Y-m-d'), + 'end' => date('Y-m-d', strtotime('+2 days')), + ), + '3' => array( + 'id' => '20', + 'name' => '测试执行2', + 'begin' => '', + 'end' => date('Y-m-d', strtotime('+2 days')), + ), + '4' => array( + 'id' => '20', + 'name' => '测试执行3', + 'begin' => date('Y-m-d'), + 'end' => '', + ), + '5' => array( + 'id' => '24', + 'name' => '执行2', + 'begin' => date('Y-m-d'), + 'end' => date('Y-m-d', strtotime('+2 days')), + ), + '6' => array( + 'id' => '20', + 'name' => '执行2', + 'begin' => date('Y-m-d'), + 'end' => date('Y-m-d', strtotime('+2 days')), + ), + '7' => array( + 'id' => '24', + 'name' => '看板2', + 'begin' => date('Y-m-d'), + 'end' => date('Y-m-d', strtotime('+2 days')), + ), + '8' => array( + 'id' => '20', + 'name' => '测试执行4', + 'begin' => date('Y-m-d', strtotime('-2 years')), + 'end' => date('Y-m-d', strtotime('+2 days')), + ), + '9' => array( + 'id' => '20', + 'name' => '测试执行5', + 'begin' => date('Y-m-d'), + 'end' => date('Y-m-d', strtotime('+2 years')), + ), + '10' => array( + 'id' => '20', + 'name' => '测试执行6', + 'begin' => date('Y-m-d'), + 'end' => date('Y-m-d', strtotime('+2 days')), + 'products' => '产品2', + ) + ); -r($tester->edit($execution['0'])) && p('status,message') && e('SUCCESS,编辑执行成功'); //编辑执行成功 +r($tester->edit($execution['0'])) && p('status,message') && e('SUCCESS,编辑执行成功'); //编辑执行成功 +r($tester->edit($execution['1'], 'kanban')) && p('status,message') && e('SUCCESS,编辑执行成功'); //编辑看板成功 +r($tester->edit($execution['2'])) && p('status,message') && e('SUCCESS,编辑执行表单页提示信息正确'); //执行名称为空,编辑失败 +r($tester->edit($execution['3'])) && p('status,message') && e('SUCCESS,编辑执行表单页提示信息正确'); //计划开始时间为空,编辑失败 +r($tester->edit($execution['4'])) && p('status,message') && e('SUCCESS,编辑执行表单页提示信息正确'); //计划结束时间为空,编辑失败 +r($tester->edit($execution['5'], 'kanban')) && p('status,message') && e('SUCCESS,编辑执行成功'); //不同项目下同名执行,编辑成功 +r($tester->editWithRepeatName($execution['6'])) && p('status,message') && e('SUCCESS,编辑执行表单页提示信息正确'); //执行名称重复,编辑失败 +r($tester->editWithRepeatName($execution['7'], 'kanban')) && p('status,message') && e('SUCCESS,编辑执行表单页提示信息正确'); //看板名称重复,编辑失败 +r($tester->editWithDateError($execution['8'], 'begin')) && p('status,message') && e('SUCCESS,编辑执行表单页提示信息正确'); //执行的计划开始时间早于项目的计划开始时间,编辑失败 +r($tester->editWithDateError($execution['9'], 'end')) && p('status,message') && e('SUCCESS,编辑执行表单页提示信息正确'); //执行的计划结束时间晚于项目的计划结束时间,编辑失败 +r($tester->edit($execution['10'])) && p('status,message') && e('SUCCESS,编辑执行成功'); //编辑执行产品成功 $tester->closeBrowser(); diff --git a/module/execution/test/ui/page/view.php b/module/execution/test/ui/page/view.php index 2133ea3ef7..15aa3a7033 100755 --- a/module/execution/test/ui/page/view.php +++ b/module/execution/test/ui/page/view.php @@ -33,6 +33,7 @@ class viewPage extends page 'createDoclib' => "//*[@id='mainContent']/div[2]/div[1]/div/table[5]/tbody/tr/td/div/div[3]/a/span", 'doclibModal' => "//*[@class='modal-dialog']", /* 编辑执行弹窗中元素 */ + 'nameLabel' => "//*[@name='name']/..//span", 'products' => "//*[@name='products[0]']", 'productsTip' => "//*[@id='products[0]Tip']", 'submit' => "//*[@type='submit']/span",