";
$html .= "
";
- $html .= "";
+ $html .= "";
$html .= "";
$html .= ".{$file->extension}
";
$html .= "
";
diff --git a/module/file/test/lib/file.unittest.class.php b/module/file/test/lib/file.unittest.class.php
index 911c9e870d..2e7c888444 100644
--- a/module/file/test/lib/file.unittest.class.php
+++ b/module/file/test/lib/file.unittest.class.php
@@ -460,4 +460,20 @@ class fileTest
$file = $this->objectModel->dao->select('*')->from(TABLE_FILE)->where('id')->eq($fileID)->fetch();
return $this->objectModel->printFile($file, $method, $showDelete, $showEdit, null);
}
+
+ /**
+ * Build file actions.
+ *
+ * @param int $fileID
+ * @param bool $showEdit
+ * @param bool $showDelete
+ * @access public
+ * @return string
+ */
+ public function buildFileActionsTest(int $fileID, bool $showEdit, bool $showDelete): string
+ {
+ $file = $this->objectModel->dao->select('*')->from(TABLE_FILE)->where('id')->eq($fileID)->fetch();
+ $downloadLink = helper::createLink('file', 'download', "fileID=$fileID");
+ return $this->objectModel->buildFileActions('', $downloadLink, 0, $showEdit, $showDelete, $file, null);
+ }
}
diff --git a/module/file/test/model/buildfileactions.php b/module/file/test/model/buildfileactions.php
new file mode 100755
index 0000000000..22e075cf02
--- /dev/null
+++ b/module/file/test/model/buildfileactions.php
@@ -0,0 +1,39 @@
+#!/usr/bin/env php
+printFile();
+timeout=0
+cid=0
+
+- 测试非详情/编辑页面的情况 @1
+- 测试编辑页面不展示删除按钮的情况 @0
+- 测试编辑页面不展示编辑按钮的情况 @1
+- 测试详情页面不展示删除按钮的情况 @0
+- 测试详情页面不展示编辑按钮的情况 @1
+
+*/
+
+include dirname(__FILE__, 5) . '/test/lib/init.php';
+include dirname(__FILE__, 2) . '/lib/file.unittest.class.php';
+su('admin');
+
+zenData('file')->gen(5);
+
+$fileIdList = range(1, 5);
+$showDeleteList = array(true, false);
+$showEdit = array(true, false);
+
+$fileTester = new fileTest();
+
+$result1 = $fileTester->buildFileActionsTest($fileIdList[0], $showDeleteList[0], $showEdit[0]);
+$result2 = $fileTester->buildFileActionsTest($fileIdList[1], $showDeleteList[1], $showEdit[0]);
+$result3 = $fileTester->buildFileActionsTest($fileIdList[2], $showDeleteList[0], $showEdit[1]);
+$result4 = $fileTester->buildFileActionsTest($fileIdList[3], $showDeleteList[1], $showEdit[0]);
+$result5 = $fileTester->buildFileActionsTest($fileIdList[4], $showDeleteList[0], $showEdit[1]);
+
+r(strpos($result1, '文件标题1') !== false) && p() && e('1'); // 测试非详情/编辑页面的情况
+r(strpos($result2, '删除') === false) && p() && e('0'); // 测试编辑页面不展示删除按钮的情况
+r(strpos($result3, '编辑') === false) && p() && e('1'); // 测试编辑页面不展示编辑按钮的情况
+r(strpos($result4, '删除') === false) && p() && e('0'); // 测试详情页面不展示删除按钮的情况
+r(strpos($result5, '编辑') === false) && p() && e('1'); // 测试详情页面不展示编辑按钮的情况