diff --git a/test/api/bugs/browse.php b/test/api/bugs/browse.php new file mode 100644 index 0000000000..8628196c45 --- /dev/null +++ b/test/api/bugs/browse.php @@ -0,0 +1,34 @@ +#!/usr/bin/env php +> 200 +通过错误的productID获取bug列表的状态码 >> 200 +通过正确的productID获取bug列表的数量 >> 10 +通过错误的productID获取bug列表的数量 >> 0 + +*/ + +global $token; +$header = array('token' => $token->token); + +$existProductBugs = $rest->get('/products/1/bugs?limit=10&id_desc', $header); +$notExistProductBugs = $rest->get('/products/10/bugs?limit=10&id_desc', $header); + +r($existProductBugs->status_code) && p() && e('200'); // 通过正确的productID获取bug列表的状态码 +r($notExistProductBugs->status_code) && p() && e('200'); //通过错误的productID获取bug列表的状态码 + + +$existbugs = $existProductBugs->body->bugs; +$emptybugs = $notExistProductBugs->body->bugs; +r(count($existbugs)) && p() && e('10'); // 通过正确的productID获取bug列表的数量 +r(count($emptybugs)) && p() && e('0'); // 通过错误的productID获取bug列表的数量 + +$firstBug = $existProductBugs->body->bugs[0]; +r($firstBug) && p('title') && ('bug80'); // 获取第一个bug的标题 \ No newline at end of file diff --git a/test/api/bugs/create.php b/test/api/bugs/create.php new file mode 100644 index 0000000000..57fc256f67 --- /dev/null +++ b/test/api/bugs/create.php @@ -0,0 +1,66 @@ +#!/usr/bin/env php +> Need product id. +bug名称必填项检查 >> 『Bug标题』不能为空。 +bug版本必填项检查 >> 『影响版本』不能为空。 + +*/ + +global $token; +$header = array('token' => $token->token); +$title = '测试bug' . helper::now(); + +$data = array( + 'product' => '1', + 'title' => $title, + 'openedBuild' => '1', + 'project' => '131', + 'module' => '0', + 'execution' => '391', + 'assignedTo' => '', + 'deadline' => '0000-00-00', + 'type' => 'codeerror', + 'os' => '', + 'browser' => '', + 'color' => '', + 'severity' => '1', + 'pri' => '1', + 'steps' => '', + 'story' => '0', + 'task' => '0', + 'mailto' => '', + 'keywords' => '', + 'status' => 'active', + 'case' => '0', + 'caseVersion' => '0', + 'result' => '0', + 'testtask' => '0', +); + +$bug = $rest->post('/bugs', $data, $header); +$bug->body = array($bug->body); + +$noNameData = $data; +unset($noNameData['title']); +$noNameBug = $rest->post('/bugs', $noNameData, $header); + +$noBuildData = $data; +unset($noBuildData['openedBuild']); +$noBuildBug = $rest->post('/bugs', $noBuildData, $header); + +unset($data['product']); +$noProductBug = $rest->post('/bugs', $data, $header); + +r($noProductBug) && c(400) && p('error') && e('Need product id.'); // 产品ID检查 +r($noNameBug) && c(400) && p('error') && e('『Bug标题』不能为空。'); // bug名称必填项检查 +r($noBuildBug) && c(400) && p('error') && e('『影响版本』不能为空。'); // bug版本必填项检查 + +r($bug) && c(201) && p('title') && e($title); // 创建一个bug \ No newline at end of file diff --git a/test/api/bugs/deleted.php b/test/api/bugs/deleted.php new file mode 100644 index 0000000000..f814dc3248 --- /dev/null +++ b/test/api/bugs/deleted.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +> {"message":"success"} +使用错误的bugID删除bug >> {"message":"success"} +查询bug是否被成功删除 >> 10,1 + +*/ + +global $token; +$header = array('token' => $token->token); + +$deleteExistBug = $rest->delete('/bugs/10' , $header); +$deleteNotExistBug = $rest->delete('/bugs/201', $header); + +r($deleteExistBug) && c(200) && p() && e('{"message":"success"}'); // 使用正确的bugID删除bug +r($deleteNotExistBug) && c(200) && p() && e('{"message":"success"}'); // 使用错误的bugID删除bug + +$existBug = $rest->get('/bugs/10', $header); +$existBug->body = array($existBug->body); + +r($existBug) && c(200) && p('id,deleted') && e('10,1'); // 查询bug是否被成功删除 \ No newline at end of file diff --git a/test/api/bugs/view.php b/test/api/bugs/view.php new file mode 100644 index 0000000000..273528ed27 --- /dev/null +++ b/test/api/bugs/view.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +> BUG1 +使用错误的bugID获取bug信息 >> 404 Not found + +*/ + +global $token; +$existBug = $rest->get('/bugs/1', array('token' => $token->token)); +$existBug->body = array($existBug->body); + +$notExistBug = $rest->get('/bugs/200', array('token' => $token->token)); + +r($existBug) && c(200) && p('title') && e('BUG1'); // 使用正确的bugID获取bug信息 +r($notExistBug) && c(404) && p('error') && e('404 Not found'); // 使用错误的bugID获取bug信息 \ No newline at end of file diff --git a/test/data/bug.yaml b/test/data/bug.yaml new file mode 100644 index 0000000000..b469c4b4b7 --- /dev/null +++ b/test/data/bug.yaml @@ -0,0 +1,122 @@ +title: zt_bug +desc: Bug表 +version: 1.0 +fields: + - field: id + range: 1-10000 + - field: project + range: 131{2},0{97} + - field: product + range: 1{20} + - field: branch + range: 0 + - field: module + range: 0 + - field: execution + range: 391,0,391,0{97} + - field: plan + range: 0 + - field: story + range: 0 + - field: storyVersion + range: 0 + - field: task + range: 0 + - field: toTask + range: 0 + - field: toStory + range: 0 + - field: title + fields: + - field: title1 + range: BUG{6},`缺陷!@()[]{}|\+=%^&*$#测试bug名称到底可以有多长!@#¥%&*'":.<>。?/();`,bug + - field: title2 + range: 1-10000 + - field: keywords + range: + - field: severity + range: 1-4:R + - field: pri + range: 1-4:R + - field: type + range: [codeerror,config,install,security,performance,standard,automation,designdefect,others] + - field: os + range: []{2},[all,ie,ie11,ie10,ie9,ie8,ie7,ie6,chrome,firefox,firefox4,firefox3,firefox2,opera,oprea11,oprea10,opera9,safari,maxthon,uc,other] + - field: browser + range: + - field: hardware + range: + - field: found + range: + - field: steps + range: ["

【步骤】


【结果】


【期望】


","【步骤】进入成果展示
【结果】乱码
【期望】正常显示
"] + - field: status + range: active{50},resolved{30},closed{20} + - field: subStatus + range: + - field: color + range: [#3da7f5,#75c941,#2dbdb2,#797ec9,#ffaf38,#ff4e3e] + - field: confirmed + range: [0,1]:R + - field: activatedCount + range: 0 + - field: mailto + range: + - field: openedBy + range: admin + - field: openedDate + range: "(-1M)-(+1w):60" + type: timestamp + format: "YYYY-MM-DD hh:mm:ss" + - field: openedBuild + range: 1,0,1,trunk{97} + - field: assignedTo + range: [admin,dev1,test1]{30},[]{20},[admin,dev1,test1]{20},[]{10},closed{20} + - field: assignedDate + range: $openedDate + - field: deadline + range: "(+2w):60" + type: timestamp + format: "YYYY-MM-DD" + - field: resolvedBy + range: []{50},$assignedTo{30},admin{20} + - field: resolution + range: []{50},bydesign{5},duplicate{5},external{5},fixed{5},notrepro{2},postponed{3},willnotfix{5},fixed{10},bydesign,external,notrepro,postponed,willnotfix,duplicate{5} + - field: resolvedBuild + range: []{55},trunk{15},[]{25},trunk{5} + - field: resolvedDate + range: + - field: closedBy + range: []{80},admin{20} + - field: closedDate + range: + - field: duplicateBug + range: 0{55},1-5,0{40},10-15 + - field: linkBug + range: + - field: case + range: 0 + - field: caseVersion + range: 0 + - field: result + range: 0 + - field: repo + range: 0 + - field: entry + range: + - field: lines + range: + - field: v1 + range: + - field: v2 + range: + - field: repoType + range: + - field: testtask + range: 0 + - field: lastEditedBy + range: + - field: lastEditedDate + range: + - field: deleted + range: 0{40},1{10},0{50} diff --git a/test/data/zentao/config.php b/test/data/zentao/config.php index 41723fbf8e..af1441d34a 100644 --- a/test/data/zentao/config.php +++ b/test/data/zentao/config.php @@ -28,3 +28,4 @@ $builder->blockRandom = array('rows' => 120, 'data' => array('block', 'blockr $builder->projectProduct = array('rows' => 21, 'data' => array('projectproduct')); $builder->case = array('rows' => 10000, 'data' => array('case')); +$builder->bug = array('rows' => 100, 'data' => array('bug'));