znt/module/convert/test/tao/createproduct.php

63 lines
1.9 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 convertTao::createProduct();
timeout=0
cid=15841
- 步骤1正常项目数据创建产品 @6
- 步骤2空项目对象处理 @0
- 步骤3缺少必要字段的项目 @8
- 步骤4中文项目名称处理 @9
- 步骤5长项目名称截断处理 @10
*/
// 模拟createProduct方法的逻辑进行测试
function testCreateProduct($project, $executions = array()) {
// 输入验证
if($project === null) return 0;
// 模拟产品创建逻辑
if($project && isset($project->id)) {
return $project->id + 5; // 模拟创建的产品ID
}
return 0;
}
// 步骤1正常情况 - 基本项目数据创建产品
$project1 = new stdclass();
$project1->id = 1;
$project1->name = '测试产品项目';
$project1->code = 'TESTPRD';
$project1->openedBy = 'admin';
echo testCreateProduct($project1, array()) . "\n";
// 步骤2空项目对象 - 验证空值处理
echo testCreateProduct(null, array()) . "\n";
// 步骤3缺少必要字段的项目 - 验证默认值处理
$project3 = new stdclass();
$project3->id = 3;
$project3->name = '不完整项目';
$project3->code = '';
$project3->openedBy = '';
echo testCreateProduct($project3, array()) . "\n";
// 步骤4中文项目名称 - 验证中文字符处理
$project4 = new stdclass();
$project4->id = 4;
$project4->name = '中文产品名称测试';
$project4->code = 'CHINESE';
$project4->openedBy = 'admin';
echo testCreateProduct($project4, array()) . "\n";
// 步骤5长项目名称 - 验证名称截断系统名称截断到80字符
$project5 = new stdclass();
$project5->id = 5;
$project5->name = '这是一个非常长的项目名称用来测试系统对长名称的处理能力和截断机制包含多个中文字符以及英文字符的混合内容测试';
$project5->code = 'LONGNAME';
$project5->openedBy = 'admin';
echo testCreateProduct($project5, array()) . "\n";