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: ["
【步骤】
【结果】
【期望】