* Add unit test of file.
This commit is contained in:
+30
-129
@@ -7,15 +7,6 @@ class fileTest
|
||||
$this->objectModel = $tester->loadModel('file');
|
||||
}
|
||||
|
||||
public function __constructTest()
|
||||
{
|
||||
$objects = $this->objectModel->construct();
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get files of an object.
|
||||
*
|
||||
@@ -55,15 +46,6 @@ class fileTest
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function saveUploadTest($objectType = '', $objectID = '', $extra = '', $filesName = 'files', $labelsName = 'labels')
|
||||
{
|
||||
$objects = $this->objectModel->saveUpload($objectType = '', $objectID = '', $extra = '', $filesName = 'files', $labelsName = 'labels');
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get counts of uploaded files.
|
||||
*
|
||||
@@ -134,15 +116,6 @@ class fileTest
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function saveUploadFileTest($file, $uid)
|
||||
{
|
||||
$objects = $this->objectModel->saveUploadFile($file, $uid);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get extension of a file.
|
||||
*
|
||||
@@ -159,6 +132,13 @@ class fileTest
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get save name.
|
||||
*
|
||||
* @param string $pathName
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getSaveNameTest($pathName)
|
||||
{
|
||||
$objects = $this->objectModel->getSaveName($pathName);
|
||||
@@ -184,13 +164,20 @@ class fileTest
|
||||
return $realpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get export tpl.
|
||||
*
|
||||
* @param string $module
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getExportTemplateTest($module)
|
||||
{
|
||||
$objects = $this->objectModel->getExportTemplate($module);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
return count($objects);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,22 +196,26 @@ class fileTest
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function saveExportTemplateTest($module)
|
||||
/**
|
||||
* Test save export template.
|
||||
*
|
||||
* @param string $module
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function saveExportTemplateTest($module, $file)
|
||||
{
|
||||
$objects = $this->objectModel->saveExportTemplate($module);
|
||||
foreach($file as $key => $value) $_POST[$key] = $value;
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
$objectID = $this->objectModel->saveExportTemplate($module);
|
||||
|
||||
return $objects;
|
||||
}
|
||||
unset($_POST);
|
||||
|
||||
public function setPathNameTest($fileID, $extension)
|
||||
{
|
||||
$objects = $this->objectModel->setPathName($fileID, $extension);
|
||||
if(dao::isError()) return dao::getError()['title'][0];
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
global $tester;
|
||||
$object = $tester->dao->select('*')->from(TABLE_USERTPL)->where('id')->eq($objectID)->fetch();
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,60 +253,6 @@ class fileTest
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function setImgSizeTest($content, $maxSize = 0)
|
||||
{
|
||||
$objects = $this->objectModel->setImgSize($content, $maxSize = 0);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
public function replaceFileTest($fileID, $postName = 'upFile')
|
||||
{
|
||||
$objects = $this->objectModel->replaceFile($fileID, $postName = 'upFile');
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
public function cropImageTest($rawImage, $target, $x, $y, $width, $height, $resizeWidth = 0, $resizeHeight = 0)
|
||||
{
|
||||
$objects = $this->objectModel->cropImage($rawImage, $target, $x, $y, $width, $height, $resizeWidth = 0, $resizeHeight = 0);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
public function pasteImageTest($data, $uid = '', $safe = false)
|
||||
{
|
||||
$objects = $this->objectModel->pasteImage($data, $uid = '', $safe = false);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
public function parseCSVTest($fileName)
|
||||
{
|
||||
$objects = $this->objectModel->parseCSV($fileName);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
public function processImgURLTest($data, $editorList, $uid = '')
|
||||
{
|
||||
$objects = $this->objectModel->processImgURL($data, $editorList, $uid = '');
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test compress image.
|
||||
*
|
||||
@@ -332,15 +269,6 @@ class fileTest
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function imagecreatefrombmpTest($filename)
|
||||
{
|
||||
$objects = $this->objectModel->imagecreatefrombmp($filename);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update objectID.
|
||||
*
|
||||
@@ -367,33 +295,6 @@ class fileTest
|
||||
return $objects;
|
||||
}
|
||||
|
||||
public function replaceImgURLTest($data, $fields)
|
||||
{
|
||||
$objects = $this->objectModel->replaceImgURL($data, $fields);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
public function sendDownHeaderTest($fileName, $fileType, $content, $type = 'content')
|
||||
{
|
||||
$objects = $this->objectModel->sendDownHeader($fileName, $fileType, $content, $type = 'content');
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
public function getImageSizeTest($file)
|
||||
{
|
||||
$objects = $this->objectModel->getImageSize($file);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get file pairs.
|
||||
*
|
||||
|
||||
@@ -19,7 +19,7 @@ fields:
|
||||
format: ""
|
||||
- field: type
|
||||
note: "类型"
|
||||
range: task,story,bug,exportstory
|
||||
range: exporttask,story,exportbug,exportstory
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/file.class.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 fileModel->getExportTemplate();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试获取 用户admin task 模块的用户模板 >> 1
|
||||
测试获取 用户admin bug 模块的用户模板 >> 0
|
||||
测试获取 用户admin story 模块的用户模板 >> 2
|
||||
测试获取 用户dev10 task 模块的用户模板 >> 0
|
||||
测试获取 用户dev10 bug 模块的用户模板 >> 1
|
||||
测试获取 用户dev10 story 模块的用户模板 >> 2
|
||||
测试获取 用户test10 task 模块的用户模板 >> 1
|
||||
测试获取 用户test10 bug 模块的用户模板 >> 0
|
||||
测试获取 用户test10 story 模块的用户模板 >> 2
|
||||
|
||||
*/
|
||||
$moduleName = array('task', 'bug', 'story');
|
||||
|
||||
$file = new fileTest();
|
||||
|
||||
su('admin');
|
||||
r($file->getExportTemplateTest($moduleName[0])) && p() && e('1'); // 测试获取 用户admin task 模块的用户模板
|
||||
r($file->getExportTemplateTest($moduleName[1])) && p() && e('0'); // 测试获取 用户admin bug 模块的用户模板
|
||||
r($file->getExportTemplateTest($moduleName[2])) && p() && e('2'); // 测试获取 用户admin story 模块的用户模板
|
||||
su('dev10');
|
||||
r($file->getExportTemplateTest($moduleName[0])) && p() && e('0'); // 测试获取 用户dev10 task 模块的用户模板
|
||||
r($file->getExportTemplateTest($moduleName[1])) && p() && e('1'); // 测试获取 用户dev10 bug 模块的用户模板
|
||||
r($file->getExportTemplateTest($moduleName[2])) && p() && e('2'); // 测试获取 用户dev10 story 模块的用户模板
|
||||
su('test10');
|
||||
r($file->getExportTemplateTest($moduleName[0])) && p() && e('1'); // 测试获取 用户test10 task 模块的用户模板
|
||||
r($file->getExportTemplateTest($moduleName[1])) && p() && e('0'); // 测试获取 用户test10 bug 模块的用户模板
|
||||
r($file->getExportTemplateTest($moduleName[2])) && p() && e('2'); // 测试获取 用户test10 story 模块的用户模板
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/file.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 fileModel->saveExportTemplate();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试新建 公共 bug 模板 >> 新建的公共bug模板,1
|
||||
测试新建 私有 bug 模板 >> 新建的私有bug模板,0
|
||||
测试新建 公共 task 模板 >> 新建的公共task模板,1
|
||||
测试新建 私有 task 模板 >> 新建的私有task模板,0
|
||||
测试新建 重名 模板 >> 『模板名称』已经有『新建的公共bug模板』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。
|
||||
|
||||
*/
|
||||
$module = array('bug', 'task');
|
||||
|
||||
$file1 = new stdclass();
|
||||
$file1->title = '新建的公共bug模板';
|
||||
$file1->content = array('id', 'product', 'branch', 'module', 'project', 'execution', 'story', 'task', 'title', 'keywords', 'severity', 'pri', 'type', 'os', 'browser', 'steps', 'status', 'deadline', 'activatedCount', 'confirmed', 'mailto', 'openedBy', 'openedDate', 'openedBuild', 'assignedTo', 'assignedDate', 'resolvedBy', 'resolution', 'resolvedBuild', 'resolvedDate', 'closedBy', 'closedDate', 'duplicateBug', 'linkBug', 'case', 'lastEditedBy', 'lastEditedDate', 'files', 'identify');
|
||||
$file1->public = 1;
|
||||
|
||||
$file2 = new stdclass();
|
||||
$file2->title = '新建的私有bug模板';
|
||||
$file2->content = array('id', 'product', 'branch', 'module', 'project', 'execution', 'story', 'task', 'title', 'keywords', );
|
||||
$file2->public = 0;
|
||||
|
||||
$file3 = new stdclass();
|
||||
$file3->title = '新建的公共task模板';
|
||||
$file3->content = array('id', 'product', 'type', 'status', 'deadline', 'openedBy', 'openedDate', 'openedBuild', 'assignedTo', 'assignedDate', 'closedBy', 'closedDate', 'duplicateBug', 'linkBug', 'case', 'lastEditedBy', 'lastEditedDate');
|
||||
$file3->public = 1;
|
||||
|
||||
$file4 = new stdclass();
|
||||
$file4->title = '新建的私有task模板';
|
||||
$file4->content = array('id', 'product', 'type', 'status', 'deadline', 'lastEditedBy', 'lastEditedDate');
|
||||
$file4->public = 0;
|
||||
|
||||
$file5 = new stdclass();
|
||||
$file5->title = '新建的公共bug模板';
|
||||
$file5->content = array('id', 'product', 'branch', 'module', 'project', 'execution', 'story', 'task', 'title', 'keywords', 'severity', 'pri', 'type', 'os', 'browser', 'steps', 'status', 'deadline', 'activatedCount', 'confirmed', 'mailto', 'openedBy', 'openedDate', 'openedBuild', 'assignedTo', 'assignedDate', 'resolvedBy', 'resolution', 'resolvedBuild', 'resolvedDate', 'closedBy', 'closedDate', 'duplicateBug', 'linkBug', 'case', 'lastEditedBy', 'lastEditedDate', 'files', 'identify');
|
||||
$file5->public = 1;
|
||||
|
||||
$file = new fileTest();
|
||||
|
||||
r($file->saveExportTemplateTest($module[0], $file1)) && p('title,public') && e('新建的公共bug模板,1'); // 测试新建 公共 bug 模板
|
||||
r($file->saveExportTemplateTest($module[0], $file2)) && p('title,public') && e('新建的私有bug模板,0'); // 测试新建 私有 bug 模板
|
||||
r($file->saveExportTemplateTest($module[1], $file3)) && p('title,public') && e('新建的公共task模板,1'); // 测试新建 公共 task 模板
|
||||
r($file->saveExportTemplateTest($module[1], $file4)) && p('title,public') && e('新建的私有task模板,0'); // 测试新建 私有 task 模板
|
||||
r($file->saveExportTemplateTest($module[0], $file5)) && p() && e('『模板名称』已经有『新建的公共bug模板』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。'); // 测试新建 重名 模板
|
||||
Reference in New Issue
Block a user