* Refactor upgradeModel::updateFileObjectID, and add its unit test.
This commit is contained in:
@@ -993,4 +993,16 @@ $config->upgrade->dbFieldLengths['int'] = array('tinyint' => 4, 'smallint'
|
||||
$config->upgrade->dbFieldLengths['unsigned'] = array('tinyint' => 3, 'smallint' => 5, 'mediumint' => 8, 'int' => 10, 'integer' => 10, 'bigint' => 20);
|
||||
$config->upgrade->dbFieldLengths['text'] = array('tinytext' => 8, 'text' => 16, 'mediumtext' => 24, 'longtext' => 32);
|
||||
|
||||
$config->upgrade->editors['doc'] = array('table' => TABLE_DOCCONTENT, 'fields' => 'doc,`content`,`digest`');
|
||||
$config->upgrade->editors['project'] = array('table' => TABLE_PROJECT, 'fields' => 'id,`desc`');
|
||||
$config->upgrade->editors['bug'] = array('table' => TABLE_BUG, 'fields' => 'id,`steps`');
|
||||
$config->upgrade->editors['release'] = array('table' => TABLE_RELEASE, 'fields' => 'id,`desc`');
|
||||
$config->upgrade->editors['productplan'] = array('table' => TABLE_PRODUCTPLAN, 'fields' => 'id,`desc`');
|
||||
$config->upgrade->editors['product'] = array('table' => TABLE_PRODUCT, 'fields' => 'id,`desc`');
|
||||
$config->upgrade->editors['story'] = array('table' => TABLE_STORYSPEC, 'fields' => 'story,`spec`,`verify`');
|
||||
$config->upgrade->editors['testtask'] = array('table' => TABLE_TESTTASK, 'fields' => 'id,`desc`,`report`');
|
||||
$config->upgrade->editors['todo'] = array('table' => TABLE_TODO, 'fields' => 'id,`desc`');
|
||||
$config->upgrade->editors['task'] = array('table' => TABLE_TASK, 'fields' => 'id,`desc`');
|
||||
$config->upgrade->editors['build'] = array('table' => TABLE_BUILD, 'fields' => 'id,`desc`');
|
||||
|
||||
include dirname(__FILE__) . DS . 'config' . DS . 'upgradeflow.php';
|
||||
|
||||
+17
-72
@@ -1635,93 +1635,38 @@ class upgradeModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新在编辑器中的文件 objectID。
|
||||
* Update file objectID in editor.
|
||||
*
|
||||
* @param string $type
|
||||
* @param int $lastID
|
||||
* @access public
|
||||
* @return bool
|
||||
* @return array
|
||||
*/
|
||||
public function updateFileObjectID($type = '', $lastID = 0)
|
||||
public function updateFileObjectID(string $type = '', int $lastID = 0): array
|
||||
{
|
||||
$limit = 100;
|
||||
if(empty($type)) $type = 'comment';
|
||||
$result['type'] = $type;
|
||||
$result['lastID'] = 0;
|
||||
if($type == 'comment')
|
||||
{
|
||||
$comments = $this->dao->select('id,objectType,objectID,comment')->from(TABLE_ACTION)->where('comment')->like('%data/upload/%')->andWhere('id')->gt($lastID)->orderBy('id')->limit($limit)->fetchAll('id');
|
||||
foreach($comments as $action)
|
||||
$actions = $this->dao->select('id,objectType,objectID,comment')->from(TABLE_ACTION)->where('comment')->like('%data/upload/%')->andWhere('id')->gt($lastID)->orderBy('id')->limit($limit)->fetchAll('id');
|
||||
foreach($actions as $action)
|
||||
{
|
||||
$files = array();
|
||||
preg_match_all('/"data\/upload\/.*1\/([0-9]{6}\/[^"]+)"/', $action->comment, $output);
|
||||
foreach($output[1] as $path)$files[$path] = $path;
|
||||
foreach($output[1] as $path) $files[$path] = $path;
|
||||
$this->dao->update(TABLE_FILE)->set('objectType')->eq($action->objectType)->set('objectID')->eq($action->objectID)->set('extra')->eq('editor')->where('pathname')->in($files)->exec();
|
||||
}
|
||||
if(count($comments) < $limit)
|
||||
{
|
||||
$result['type'] = 'doc';
|
||||
$result['count'] = count($comments);
|
||||
$result['lastID'] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result['type'] = 'comment';
|
||||
$result['count'] = count($comments);
|
||||
$result['lastID'] = $action->id;
|
||||
}
|
||||
$result['type'] = 'comment';
|
||||
$result['count'] = count($actions);
|
||||
$result['lastID'] = count($actions) < $limit ? 0 : $action->id;
|
||||
return $result;
|
||||
}
|
||||
|
||||
$editors['doc'] = array('table' => TABLE_DOCCONTENT, 'fields' => 'doc,`content`,`digest`');
|
||||
$editors['project'] = array('table' => TABLE_PROJECT, 'fields' => 'id,`desc`');
|
||||
$editors['bug'] = array('table' => TABLE_BUG, 'fields' => 'id,`steps`');
|
||||
$editors['release'] = array('table' => TABLE_RELEASE, 'fields' => 'id,`desc`');
|
||||
$editors['productplan'] = array('table' => TABLE_PRODUCTPLAN, 'fields' => 'id,`desc`');
|
||||
$editors['product'] = array('table' => TABLE_PRODUCT, 'fields' => 'id,`desc`');
|
||||
$editors['story'] = array('table' => TABLE_STORYSPEC, 'fields' => 'story,`spec`,`verify`');
|
||||
$editors['testtask'] = array('table' => TABLE_TESTTASK, 'fields' => 'id,`desc`,`report`');
|
||||
$editors['todo'] = array('table' => TABLE_TODO, 'fields' => 'id,`desc`');
|
||||
$editors['task'] = array('table' => TABLE_TASK, 'fields' => 'id,`desc`');
|
||||
$editors['build'] = array('table' => TABLE_BUILD, 'fields' => 'id,`desc`');
|
||||
|
||||
$editor = $editors[$type];
|
||||
$fields = explode(',', $editor['fields']);
|
||||
$cond = array();
|
||||
foreach($fields as $field)
|
||||
list($objectCount, $lastID) = $this->upgradeTao->updateFileObjects($type, $lastID, $limit);
|
||||
if($objectCount < $limit)
|
||||
{
|
||||
if(strpos($field, '`') !== false) $cond[] = $field . " like '%data/upload/%'";
|
||||
if(strpos($field, '`') === false) $idField = $field;
|
||||
}
|
||||
$objects = $this->dao->select($editor['fields'])->from($editor['table'])
|
||||
->where($idField)->gt($lastID)
|
||||
->beginIF($cond)->andWhere('(' . join(' OR ', $cond) . ')')->fi()
|
||||
->orderBy($idField)
|
||||
->limit($limit)
|
||||
->fetchAll($idField);
|
||||
foreach($objects as $object)
|
||||
{
|
||||
$files = array();
|
||||
$objectID = 0;
|
||||
foreach($fields as $field)
|
||||
{
|
||||
if(strpos($field, '`') === false)
|
||||
{
|
||||
$objectID = $object->$field;
|
||||
}
|
||||
else
|
||||
{
|
||||
$field = trim($field, '`');
|
||||
preg_match_all('/"\/?data\/upload\/.*1\/([0-9]{6}\/[^"]+)"/', $object->$field, $output);
|
||||
foreach($output[1] as $path)$files[$path] = $path;
|
||||
}
|
||||
}
|
||||
if($files)
|
||||
{
|
||||
$this->dao->update(TABLE_FILE)->set('objectType')->eq($type)->set('objectID')->eq($objectID)->set('extra')->eq('editor')->where('pathname')->in($files)->exec();
|
||||
}
|
||||
}
|
||||
if(count($objects) < $limit)
|
||||
{
|
||||
$editorKeys = array_keys($editors);
|
||||
$editorKeys = array_keys($this->config->upgrade->editors);
|
||||
foreach($editorKeys as $i => $objectType)
|
||||
{
|
||||
if($type == $objectType)
|
||||
@@ -1731,14 +1676,14 @@ class upgradeModel extends model
|
||||
}
|
||||
}
|
||||
$result['type'] = empty($nextType) ? 'finish' : $nextType;
|
||||
$result['count'] = count($objects);
|
||||
$result['count'] = $objectCount;
|
||||
$result['lastID'] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result['type'] = $type;
|
||||
$result['count'] = count($objects);
|
||||
$result['lastID'] = $object->$idField;
|
||||
$result['count'] = $objectCount;
|
||||
$result['lastID'] = $lastID;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -488,4 +488,58 @@ class upgradeTao extends upgradeModel
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文件对象。
|
||||
* Update file objects.
|
||||
*
|
||||
* @param string $type
|
||||
* @param int $lastID
|
||||
* @param int $limit
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function updateFileObjects(string $type, int $lastID, int $limit)
|
||||
{
|
||||
/* Get type editor, fields, and query conditions. */
|
||||
$cond = array();
|
||||
$editorFields = array();
|
||||
$editor = $this->config->upgrade->editors[$type];
|
||||
$fields = explode(',', $editor['fields']);
|
||||
foreach($fields as $field)
|
||||
{
|
||||
if(strpos($field, '`') !== false)
|
||||
{
|
||||
$cond[] = $field . " like '%data/upload/%'";
|
||||
$editorFields[] = $field;
|
||||
}
|
||||
else
|
||||
{
|
||||
$idField = $field;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get objects. */
|
||||
$objects = $this->dao->select($editor['fields'])->from($editor['table'])
|
||||
->where($idField)->gt($lastID)
|
||||
->beginIF($cond)->andWhere('(' . join(' OR ', $cond) . ')')->fi()
|
||||
->orderBy($idField)
|
||||
->limit($limit)
|
||||
->fetchAll($idField);
|
||||
foreach($objects as $object)
|
||||
{
|
||||
$files = array();
|
||||
/* Get files in the editor fields. */
|
||||
foreach($editorFields as $field)
|
||||
{
|
||||
$field = trim($field, '`');
|
||||
preg_match_all('/"\/?data\/upload\/.*1\/([0-9]{6}\/[^"]+)"/', $object->{$field}, $output);
|
||||
foreach($output[1] as $path) $files[$path] = $path;
|
||||
}
|
||||
/* If the file exists, update the file. */
|
||||
if($files) $this->dao->update(TABLE_FILE)->set('objectType')->eq($type)->set('objectID')->eq($object->{$idField})->set('extra')->eq('editor')->where('pathname')->in($files)->exec();
|
||||
}
|
||||
|
||||
return array(count($objects), isset($object) ? $object->{$idField} : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 upgradeModel->updateFileObjectID();
|
||||
cid=1
|
||||
|
||||
- 测试更新类型 空 上一个id 3 的编辑器文件对象 @type:comment,count:8,lastID:0,files:1,2,3,4,5,6,7,8,9,10,11
|
||||
|
||||
- 测试更新类型 空 上一个id 0 的编辑器文件对象 @type:comment,count:11,lastID:0,files:1,2,3,4,5,6,7,8,9,10,11
|
||||
|
||||
- 测试更新类型 comment 上一个id 3 的编辑器文件对象 @type:comment,count:8,lastID:0,files:1,2,3,4,5,6,7,8,9,10,11
|
||||
|
||||
- 测试更新类型 comment 上一个id 0 的编辑器文件对象 @type:comment,count:11,lastID:0,files:1,2,3,4,5,6,7,8,9,10,11
|
||||
|
||||
- 测试更新类型 doc 上一个id 3 的编辑器文件对象 @type:project,count:2,lastID:0,files:1,7
|
||||
|
||||
- 测试更新类型 doc 上一个id 0 的编辑器文件对象 @type:project,count:5,lastID:0,files:1,7
|
||||
|
||||
- 测试更新类型 project 上一个id 3 的编辑器文件对象 @type:project,count:100,lastID:103,files:2,8
|
||||
|
||||
- 测试更新类型 project 上一个id 0 的编辑器文件对象 @type:project,count:100,lastID:100,files:2,8
|
||||
|
||||
- 测试更新类型 build 上一个id 3 的编辑器文件对象 @type:finish,count:2,lastID:0,files:
|
||||
|
||||
- 测试更新类型 build 上一个id 0 的编辑器文件对象 @type:finish,count:5,lastID:0,files:
|
||||
|
||||
**/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/upgrade.class.php';
|
||||
|
||||
zdTable('user')->gen(5);
|
||||
zdTable('action')->config('action_updatefileobjectid')->gen(11);
|
||||
zdTable('doccontent')->config('doccontent_updatefileobjectid')->gen(5);
|
||||
zdTable('project')->config('project_updatefileobjectid')->gen(110);
|
||||
zdTable('build')->config('build_updatefileobjectid')->gen(5);
|
||||
su('admin');
|
||||
|
||||
$upgrade = new upgradeTest();
|
||||
|
||||
$type = array('', 'comment', 'doc', 'project', 'build');
|
||||
$lastID = array(3, 0);
|
||||
|
||||
r($upgrade->updateFileObjectIDTest($type[0], $lastID[0])) && p() && e('type:comment,count:8,lastID:0,files:1,2,3,4,5,6,7,8,9,10,11'); // 测试更新类型 空 上一个id 3 的编辑器文件对象
|
||||
r($upgrade->updateFileObjectIDTest($type[0], $lastID[1])) && p() && e('type:comment,count:11,lastID:0,files:1,2,3,4,5,6,7,8,9,10,11'); // 测试更新类型 空 上一个id 0 的编辑器文件对象
|
||||
r($upgrade->updateFileObjectIDTest($type[1], $lastID[0])) && p() && e('type:comment,count:8,lastID:0,files:1,2,3,4,5,6,7,8,9,10,11'); // 测试更新类型 comment 上一个id 3 的编辑器文件对象
|
||||
r($upgrade->updateFileObjectIDTest($type[1], $lastID[1])) && p() && e('type:comment,count:11,lastID:0,files:1,2,3,4,5,6,7,8,9,10,11'); // 测试更新类型 comment 上一个id 0 的编辑器文件对象
|
||||
r($upgrade->updateFileObjectIDTest($type[2], $lastID[0])) && p() && e('type:project,count:2,lastID:0,files:1,7'); // 测试更新类型 doc 上一个id 3 的编辑器文件对象
|
||||
r($upgrade->updateFileObjectIDTest($type[2], $lastID[1])) && p() && e('type:project,count:5,lastID:0,files:1,7'); // 测试更新类型 doc 上一个id 0 的编辑器文件对象
|
||||
r($upgrade->updateFileObjectIDTest($type[3], $lastID[0])) && p() && e('type:project,count:100,lastID:103,files:2,8'); // 测试更新类型 project 上一个id 3 的编辑器文件对象
|
||||
r($upgrade->updateFileObjectIDTest($type[3], $lastID[1])) && p() && e('type:project,count:100,lastID:100,files:2,8'); // 测试更新类型 project 上一个id 0 的编辑器文件对象
|
||||
r($upgrade->updateFileObjectIDTest($type[4], $lastID[0])) && p() && e('type:finish,count:2,lastID:0,files:'); // 测试更新类型 build 上一个id 3 的编辑器文件对象
|
||||
r($upgrade->updateFileObjectIDTest($type[4], $lastID[1])) && p() && e('type:finish,count:5,lastID:0,files:'); // 测试更新类型 build 上一个id 0 的编辑器文件对象
|
||||
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 upgradeModel->updateFileObjects();
|
||||
cid=1
|
||||
|
||||
- 测试更新类型 doc 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:1
|
||||
|
||||
- 测试更新类型 doc 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:1
|
||||
|
||||
- 测试更新类型 project 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:2
|
||||
|
||||
- 测试更新类型 project 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:2
|
||||
|
||||
- 测试更新类型 bug 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:3
|
||||
|
||||
- 测试更新类型 bug 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:3
|
||||
|
||||
- 测试更新类型 release 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:4
|
||||
|
||||
- 测试更新类型 release 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:4
|
||||
|
||||
- 测试更新类型 productplan 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:5
|
||||
|
||||
- 测试更新类型 productplan 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:5
|
||||
|
||||
- 测试更新类型 product 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:6
|
||||
|
||||
- 测试更新类型 product 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:6
|
||||
|
||||
- 测试更新类型 story 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:7
|
||||
|
||||
- 测试更新类型 story 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:7
|
||||
|
||||
- 测试更新类型 testtask 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:8
|
||||
|
||||
- 测试更新类型 testtask 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:8
|
||||
|
||||
- 测试更新类型 todo 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:9
|
||||
|
||||
- 测试更新类型 todo 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:9
|
||||
|
||||
- 测试更新类型 task 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:10
|
||||
|
||||
- 测试更新类型 task 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:10
|
||||
|
||||
- 测试更新类型 build 上一个id 3 限制 1 的文件对象 @count:1,lastID:4,fileID:11
|
||||
|
||||
- 测试更新类型 build 上一个id 0 限制 10 的文件对象 @count:5,lastID:5,fileID:11
|
||||
|
||||
**/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/upgrade.class.php';
|
||||
|
||||
zdTable('user')->gen(5);
|
||||
zdTable('file')->config('file_updatefileobjectid')->gen(11);
|
||||
zdTable('doccontent')->config('doccontent_updatefileobjectid')->gen(5);
|
||||
zdTable('project')->config('project_updatefileobjectid')->gen(5);
|
||||
zdTable('bug')->config('bug_updatefileobjectid')->gen(5);
|
||||
zdTable('release')->config('release_updatefileobjectid')->gen(5);
|
||||
zdTable('productplan')->config('productplan_updatefileobjectid')->gen(5);
|
||||
zdTable('product')->config('product_updatefileobjectid')->gen(5);
|
||||
zdTable('storyspec')->config('storyspec_updatefileobjectid')->gen(5);
|
||||
zdTable('testtask')->config('testtask_updatefileobjectid')->gen(5);
|
||||
zdTable('todo')->config('todo_updatefileobjectid')->gen(5);
|
||||
zdTable('task')->config('task_updatefileobjectid')->gen(5);
|
||||
zdTable('build')->config('build_updatefileobjectid')->gen(5);
|
||||
su('admin');
|
||||
|
||||
$upgrade = new upgradeTest();
|
||||
|
||||
$type = array('doc', 'project', 'bug', 'release', 'productplan', 'product', 'story', 'testtask', 'todo', 'task', 'build');
|
||||
$lastID = array(3, 0);
|
||||
$limit = array(1, 10);
|
||||
|
||||
r($upgrade->updateFileObjectsTest($type[0], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:1'); // 测试更新类型 doc 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[0], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:1'); // 测试更新类型 doc 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[1], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:2'); // 测试更新类型 project 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[1], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:2'); // 测试更新类型 project 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[2], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:3'); // 测试更新类型 bug 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[2], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:3'); // 测试更新类型 bug 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[3], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:4'); // 测试更新类型 release 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[3], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:4'); // 测试更新类型 release 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[4], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:5'); // 测试更新类型 productplan 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[4], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:5'); // 测试更新类型 productplan 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[5], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:6'); // 测试更新类型 product 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[5], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:6'); // 测试更新类型 product 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[6], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:7'); // 测试更新类型 story 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[6], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:7'); // 测试更新类型 story 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[7], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:8'); // 测试更新类型 testtask 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[7], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:8'); // 测试更新类型 testtask 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[8], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:9'); // 测试更新类型 todo 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[8], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:9'); // 测试更新类型 todo 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[9], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:10'); // 测试更新类型 task 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[9], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:10'); // 测试更新类型 task 上一个id 0 限制 10 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[10], $lastID[0], $limit[0])) && p() && e('count:1,lastID:4,fileID:11'); // 测试更新类型 build 上一个id 3 限制 1 的文件对象
|
||||
r($upgrade->updateFileObjectsTest($type[10], $lastID[1], $limit[1])) && p() && e('count:5,lastID:5,fileID:11'); // 测试更新类型 build 上一个id 0 限制 10 的文件对象
|
||||
@@ -412,4 +412,48 @@ class upgradeTest
|
||||
|
||||
return $tester->dao->select('*')->from(TABLE_DOCLIB)->where('project')->eq($projectID)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试更新在编辑器中的文件 objectID。
|
||||
* Test update file objectID in editor.
|
||||
*
|
||||
* @param string $type
|
||||
* @param int $lastID
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function updateFileObjectIDTest(string $type, int $lastID): string
|
||||
{
|
||||
global $tester;
|
||||
$tester->dao->update(TABLE_FILE)->set('extra')->eq('editor')->exec();
|
||||
|
||||
$result = $this->objectModel->updateFileObjectID($type, $lastID);
|
||||
|
||||
$return = '';
|
||||
foreach($result as $key => $value) $return .= "{$key}:{$value},";
|
||||
$files = $tester->dao->select('id')->from(TABLE_FILE)->where('extra')->eq('editor')->beginIF($type != '' && $type != 'comment')->andWhere('objectType')->eq($type)->fi()->fetchPairs();
|
||||
return $return . 'files:' . implode(',', $files);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试更新文件对象。
|
||||
* Test update file objects.
|
||||
*
|
||||
* @param string $type
|
||||
* @param int $lastID
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function updateFileObjectsTest(string $type, int $lastID, int $limit): string
|
||||
{
|
||||
global $tester;
|
||||
$tester->dao->update(TABLE_FILE)->set('extra')->eq('editor')->exec();
|
||||
|
||||
list($objectCount, $lastID) = $this->objectModel->updateFileObjects($type, $lastID, $limit);
|
||||
|
||||
$files = $tester->dao->select('id')->from(TABLE_FILE)->where('objectType')->eq($type)->andWhere('extra')->eq('editor')->fetchPairs();
|
||||
|
||||
return "count:{$objectCount},lastID:{$lastID},fileID:" . implode(',', $files);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
title: table zt_action
|
||||
desc: "系统动态"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: objectID
|
||||
note: "对象ID"
|
||||
range: 1-11
|
||||
- field: objectType
|
||||
note: "对象类型"
|
||||
range: doc,project,bug,release,productplan,product,story,testtask,todo,task,build
|
||||
- field: comment
|
||||
note: "评论"
|
||||
range: 100000-999999
|
||||
prefix: '"data/upload/11/'
|
||||
postfix: '/test"'
|
||||
@@ -0,0 +1,9 @@
|
||||
title: table zt_bug
|
||||
desc: "bug"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: steps
|
||||
range: "100000-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,9 @@
|
||||
title: table zt_build
|
||||
desc: "版本"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: desc
|
||||
range: "100000-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,15 @@
|
||||
title: table zt_doccontent
|
||||
desc: "文档内容"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: doc
|
||||
range: 1-1000
|
||||
- field: content
|
||||
range: "100003-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
- field: digest
|
||||
range: "99998-9999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,15 @@
|
||||
title: table zt_file
|
||||
desc: "文件"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: objectID
|
||||
note: "对象ID"
|
||||
range: 1-11
|
||||
- field: objectType
|
||||
note: "对象类型"
|
||||
range: doc,project,bug,release,productplan,product,story,testtask,todo,task,build
|
||||
- field: pathname
|
||||
note: "路径"
|
||||
range: "100000-100005"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,9 @@
|
||||
title: table zt_product
|
||||
desc: "文件"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: desc
|
||||
range: "100000-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,9 @@
|
||||
title: table zt_productplan
|
||||
desc: "计划"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: desc
|
||||
range: "100000-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,11 @@
|
||||
title: table zt_project
|
||||
desc: "项目"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-10000
|
||||
- field: desc
|
||||
range: "100000-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,9 @@
|
||||
title: table zt_release
|
||||
desc: "发布"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: desc
|
||||
range: "100000-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,15 @@
|
||||
title: table zt_story
|
||||
desc: "需求"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: story
|
||||
range: 1-10000
|
||||
- field: spec
|
||||
range: "100003-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
- field: verify
|
||||
range: "99998-9999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,9 @@
|
||||
title: table zt_task
|
||||
desc: "任务"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: desc
|
||||
range: "100000-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,13 @@
|
||||
title: table zt_testtask
|
||||
desc: "测试单"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: desc
|
||||
range: "100003-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
- field: report
|
||||
range: "99998-9999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
@@ -0,0 +1,9 @@
|
||||
title: table zt_todo
|
||||
desc: "待办"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: desc
|
||||
range: "100000-999999"
|
||||
prefix: "data/upload/"
|
||||
postfix: "/test"
|
||||
Reference in New Issue
Block a user