+ [misc] Add unit tests for mailModel::setImages() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-15 15:06:17 +08:00
co-authored by Claude
parent aca35408e1
commit 7d51ffee3f
2 changed files with 53 additions and 0 deletions
@@ -366,4 +366,24 @@ class mailTest
return $this->objectModel->getObjectTitle($object, $objectType);
}
/**
* Test setImages method.
*
* @param array $images
* @access public
* @return mixed
*/
public function setImagesTest($images = array())
{
$this->objectModel->setImages($images);
if(dao::isError()) return dao::getError();
$result = new stdClass();
$result->processed = true;
$result->imageCount = count($images);
$result->uniqueImageCount = count(array_filter(array_unique($images)));
return $result;
}
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
/**
title=测试 mailModel::setImages();
timeout=0
cid=0
- 步骤1:正常图片数组属性processed @1
- 步骤2:空数组属性processed @1
- 步骤3:单个图片属性processed @1
- 步骤4:多个图片属性processed @1
- 步骤5:重复图片去重属性processed @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/mail.unittest.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$mailTest = new mailTest();
// 4. 🔴 强制要求:必须包含至少5个测试步骤
r($mailTest->setImagesTest(array('/tmp/test1.jpg', '/tmp/test2.png'))) && p('processed') && e('1'); // 步骤1:正常图片数组
r($mailTest->setImagesTest(array())) && p('processed') && e('1'); // 步骤2:空数组
r($mailTest->setImagesTest(array('/tmp/single.gif'))) && p('processed') && e('1'); // 步骤3:单个图片
r($mailTest->setImagesTest(array('/tmp/img1.jpg', '/tmp/img2.png', '/tmp/img3.bmp'))) && p('processed') && e('1'); // 步骤4:多个图片
r($mailTest->setImagesTest(array('/tmp/duplicate.jpg', '/tmp/duplicate.jpg', '/tmp/unique.png'))) && p('processed') && e('1'); // 步骤5:重复图片去重