* Add lang in test case.

This commit is contained in:
liyang
2024-04-22 14:25:50 +08:00
parent ce4abd1a35
commit 9882ce41e0
2 changed files with 26 additions and 20 deletions
@@ -1,4 +1,7 @@
<?php
use function zin\success;
include dirname(__FILE__, 5) . '/test/lib/ui.php';
class createProductTester extends tester
{
@@ -11,7 +14,6 @@ class createProductTester extends tester
*/
public function checkLocating($productName)
{
$this->login();
$form = $this->initForm('product', 'create');
$form->dom->name->setValue($productName);
$form->dom->btn($this->lang->save)->click();
@@ -28,24 +30,25 @@ class createProductTester extends tester
*/
public function createDefault($productName)
{
$this->login();
/* 提交表单。 */
$form = $this->initForm('product', 'create');
$form->dom->name->setValue($productName);
$form->dom->btn($this->lang->save)->click();
$form->wait(1);
if($this->response('method') != 'browse') return $this->failed($form->dom->getFormTips());
if($this->response('method') != 'browse')
{
if($this->checkFormTips('product')) return $this->success('表单提示信息正确');
return $this->failed('表单提示信息不正确');
}
/* 跳转到产品需求页面,点击设置菜单查看产品设置页面。 */
$browsePage = $this->loadPage('product', 'browse');
$browsePage->dom->settings->click();
$viewPage = $this->loadPage('product', 'view');
$this->app->loadLang('product');
if($viewPage->dom->productName->getText() != $productName) return $this->failed('名称错误');
if($viewPage->dom->type->getText() != $this->lang->product->typeList['normal']) return $this->failed('类型错误');
if($viewPage->dom->acl->getText() != $this->lang->product->abbr->aclList['open']) return $this->failed('权限错误');
if($viewPage->dom->type->getText() != $this->lang->product->typeList->normal) return $this->failed('类型错误');
if($viewPage->dom->acl->getText() != $this->lang->product->abbr->aclList->open) return $this->failed('权限错误');
return $this->success();
}
@@ -60,24 +63,26 @@ class createProductTester extends tester
public function createMultiBranch($name)
{
/* 提交表单。 */
$this->login();
$form = $this->initForm('product', 'create');
$form->dom->name->setValue($name);
$form->dom->type->picker('多分支');
$form->dom->type->picker($this->lang->product->typeList->branch);
$form->dom->btn($this->lang->save)->click();
$form->wait(1);
if($this->response('method') != 'browse') return $this->failed($form->dom->getFormTips());
if($this->response('method') != 'browse')
{
if($this->checkFormTips('product')) return $this->success('表单提示信息正确');
return $this->failed('表单提示信息不正确');
}
/* 跳转到产品需求页面,点击设置菜单查看产品设置页面。 */
$browsePage = $this->loadPage('product', 'browse');
$browsePage->dom->settings->click();
$viewPage = $this->loadPage('product', 'view');
$this->app->loadLang('product');
$viewPage = $this->loadPage('product', 'view');
if($viewPage->dom->productName->getText() != $name) return $this->failed('名称错误');
if($viewPage->dom->type->getText() != $this->lang->product->typeList['branch']) return $this->failed('类型错误');
if($viewPage->dom->branchProductACL->getText() != $this->lang->product->abbr->aclList['open']) return $this->failed('权限错误');
if($viewPage->dom->type->getText() != $this->lang->product->typeList->branch) return $this->failed('类型错误');
if($viewPage->dom->branchProductACL->getText() != $this->lang->product->abbr->aclList->open) return $this->failed('权限错误');
return $this->success();
}
+7 -6
View File
@@ -15,9 +15,10 @@ SUCCESS
chdir(__DIR__);
include '../lib/createproduct.ui.class.php';
zdTable('product')->config('product', false, 2)->gen(10);
//zdTable('product')->config('product', false, 2)->gen(10);
//zendata::loadYaml('product', false, 2)->createFor('product', 10);
$tester = new createProductTester();
$tester->login();
$products = array();
$products['null'] = '';
@@ -25,10 +26,10 @@ $products['default'] = '默认产品';
$products['normal'] = '正常产品';
$products['branch'] = '多分支产品产品';
r($tester->createDefault($products['null'])) && p('message:nameTip') && e('『产品名称』不能为空。'); // 缺少产品名称,创建失败
r($tester->createDefault($products['default'])) && p('status') && e('SUCCESS'); // 使用默认选项创建产品
r($tester->createDefault($products['default'])) && p('message:nameTip') && e('『产品名称』已经有『默认产品』这条记录了。'); // 创建重复名称的产品
r($tester->checkLocating($products['normal'])) && p('module,method') && e('product,browse'); // 创建正常产品后的跳转链接检查
r($tester->createMultiBranch($products['branch'])) && p('status') && e('SUCCESS'); // 创建正常产品成功
r($tester->createDefault($products['null'])) && p('message') && e('表单提示信息正确'); // 缺少产品名称,创建失败
r($tester->createDefault($products['default'])) && p('status') && e('SUCCESS'); // 使用默认选项创建产品
r($tester->createDefault($products['default'])) && p('message') && e('表单提示信息正确'); // 创建重复名称的产品
r($tester->checkLocating($products['normal'])) && p('module,method') && e('product,browse'); // 创建正常产品后的跳转链接检查
r($tester->createMultiBranch($products['branch'])) && p('status') && e('SUCCESS'); // 创建正常产品成功
$tester->closeBrowser();