* Optimize api getStructByID function and finish unit test script.
This commit is contained in:
@@ -1,29 +1,34 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/api.class.php';
|
||||
su('admin');
|
||||
|
||||
zdTable('apistruct')->gen(10);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 apiModel->getStructByID();
|
||||
timeout=0
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取刚创建的数据结构 >> struct
|
||||
- 获取数据结构ID为1的数据结构。
|
||||
- 属性id @1
|
||||
- 属性name @数据接口1
|
||||
- 属性type @formData
|
||||
- 获取数据结构ID为2的数据结构。
|
||||
- 属性id @2
|
||||
- 属性name @数据接口2
|
||||
- 属性type @json
|
||||
- 获取不存在的数据结构ID为22的数据结构。
|
||||
- 属性id @0
|
||||
- 属性name @0
|
||||
- 属性type @0
|
||||
|
||||
*/
|
||||
|
||||
global $tester;
|
||||
$api = new apiTest();
|
||||
$tester->loadModel('api');
|
||||
|
||||
$normalStruct = new stdclass();
|
||||
$normalStruct->name = 'struct';
|
||||
$normalStruct->type = 'formData';
|
||||
$normalStruct->attribute = '[{"field":"field1","paramsType":"string","required":true,"desc":"desc","structType":"formData","sub":1,"key":"l2u5qy3jc1se6ghigll","children":[]}]';
|
||||
$normalStruct->desc = '';
|
||||
$normalStruct->addedBy = $tester->app->user->account;
|
||||
$normalStruct->addedDate = helper::now();
|
||||
|
||||
$struct = $api->createStructTest($normalStruct, false);
|
||||
r($api->getStructByIDTest($struct->id)) && p('name') && e('struct'); //获取刚创建的数据结构
|
||||
r($tester->api->getStructByID(1)) && p('id,name,type') && e('1,数据接口1,formData'); //获取数据结构ID为1的数据结构。
|
||||
r($tester->api->getStructByID(2)) && p('id,name,type') && e('2,数据接口2,json'); //获取数据结构ID为2的数据结构。
|
||||
r($tester->api->getStructByID(22)) && p('id,name,type') && e('0,0,0'); //获取不存在的数据结构ID为22的数据结构。
|
||||
|
||||
Reference in New Issue
Block a user