* add project api test.
This commit is contained in:
@@ -57,6 +57,7 @@ class projectsEntry extends entry
|
||||
$fields = 'name,begin,end,products';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$this->setPost('code', $this->request('code', ''));
|
||||
$this->setPost('acl', $this->request('acl', 'private'));
|
||||
$this->setPost('parent', $this->request('program', 0));
|
||||
$this->setPost('whitelist', $this->request('whitelist', array()));
|
||||
@@ -64,7 +65,7 @@ class projectsEntry extends entry
|
||||
$this->setPost('model', $this->request('model', 'scrum'));
|
||||
|
||||
$control = $this->loadController('project', 'create');
|
||||
$this->requireFields('name,begin,end,products');
|
||||
$this->requireFields('name,code,begin,end,products');
|
||||
|
||||
$control->create($this->request('model', 'scrum'));
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=获取项目列表;
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取条目的project和type字段 >> 0,project
|
||||
获取不存在的项目 >> 404 Not found
|
||||
获取错误ID的项目 >> 404 Not found
|
||||
|
||||
*/
|
||||
$token = $rest->post('/tokens', array('account' => 'admin', 'password' => '123456'));
|
||||
$project = $rest->get('/projects/712', array("Token" => $token->body->token));
|
||||
$zeroIdError = $rest->get('/projects/0', array("Token" => $token->body->token));
|
||||
$stringIdError = $rest->get('/projects/test', array("Token" => $token->body->token));
|
||||
|
||||
r($project) && c('200') && p('project,type', ',') && e('0,project'); // 获取条目的project和type字段
|
||||
r($zeroIdError) && c('404') && p('error') && e('404 Not found'); // 获取不存在的项目
|
||||
r($stringIdError) && c('404') && p('error') && e('404 Not found'); // 获取错误ID的项目
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=获取项目列表;
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取条目的project和type字段 >> 0,project
|
||||
|
||||
*/
|
||||
global $token;
|
||||
$projects = $rest->get('/projects', array("Token" => $token));
|
||||
|
||||
$project = array(reset($projects->body->projects));
|
||||
r($project) && p('project,type', ',') && e('0,project'); // 获取条目的project和type字段
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=创建项目;
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
创建失败,没有name字段 >> `『项目名称』`
|
||||
创建失败,没有code字段 >> `『项目代号』`
|
||||
创建失败,没有end字段 >> `『计划完成』`
|
||||
创建成功,获取创建的name和code字段 >> test111,test222
|
||||
创建失败,获取错误信息 >> `『test111』`
|
||||
|
||||
*/
|
||||
global $token;
|
||||
|
||||
$postData = array();
|
||||
$postData['parent'] = '0';
|
||||
$postData['name'] = 'test111';
|
||||
$postData['code'] = '';
|
||||
$postData['PM'] = '';
|
||||
$postData['budget'] = '';
|
||||
$postData['budgetUnit'] = 'CNY';
|
||||
$postData['begin'] = date('Y-m-d');
|
||||
$postData['end'] = date('Y-m-d', time() + 10 * 24 * 3600);
|
||||
$postData['days'] = '10';
|
||||
$postData['acl'] = 'private';
|
||||
$postData['auth'] = 'extend';
|
||||
$postData['model'] = 'scrum';
|
||||
$postData['products'][] = 1;
|
||||
$postData['plan'][] = '';
|
||||
$postData['whitelist'][] = '';
|
||||
|
||||
$postData['name'] = '';
|
||||
$postData['code'] = 'test222';
|
||||
$noNameError = $rest->post('/projects', $postData, array("Token" => $token));
|
||||
$noNameError = $noNameError->body->error->name[0];
|
||||
|
||||
$postData['name'] = 'test111';
|
||||
$postData['code'] = '';
|
||||
$noCodeError = $rest->post('/projects', $postData, array("Token" => $token));
|
||||
$noCodeError = $noCodeError->body->error->code[0];
|
||||
|
||||
$postData['code'] = 'test222';
|
||||
$postData['end'] = '';
|
||||
$noEndError = $rest->post('/projects', $postData, array("Token" => $token));
|
||||
$noEndError = $noEndError->body->error->end[0];
|
||||
|
||||
$postData['end'] = date('Y-m-d', time() + 10 * 24 * 3600);
|
||||
$project = $rest->post('/projects', $postData, array("Token" => $token));
|
||||
$error = $rest->post('/projects', $postData, array("Token" => $token));
|
||||
$error = $error->body->error->name[0];
|
||||
|
||||
r($noNameError) && p('error') && e('`『项目名称』`'); // 创建失败,没有name字段
|
||||
r($noCodeError) && p('error') && e('`『项目代号』`'); // 创建失败,没有code字段
|
||||
r($noEndError) && p('error') && e('`『计划完成』`'); // 创建失败,没有end字段
|
||||
r($project) && c('201') && p('name,code', ',') && e('test111,test222'); // 创建成功,获取创建的name和code字段
|
||||
r($error) && p('error') && e('`『test111』`'); // 创建失败,获取错误信息
|
||||
Reference in New Issue
Block a user