znt/module/project/test/model/checkbranchandproduct.php

38 lines
1.7 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=测试 projectModel::checkBranchAndProduct();
timeout=0
cid=17805
- 步骤1正常情况-有产品有分支 @1
- 步骤2边界值-空产品数组 @1
- 步骤3异常输入-分支ID为空字符串属性branch[0][] @1
- 步骤4异常输入-多产品分支为空属性branch[0][] @1
- 步骤5正常情况-多产品多分支 @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. zendata数据准备
zenData('project')->gen(10);
zenData('product')->gen(10);
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$projectTest = new projectModelTest();
// 5. 🔴 强制要求必须包含至少5个测试步骤
r($projectTest->checkBranchAndProductTest(1, array(1, 2), array(array(1), array(2)))) && p() && e('1'); // 步骤1正常情况-有产品有分支
r($projectTest->checkBranchAndProductTest(1, array(), array())) && p() && e('1'); // 步骤2边界值-空产品数组
r($projectTest->checkBranchAndProductTest(0, array(1), array(array('')))) && p('branch[0][]') && e('1'); // 步骤3异常输入-分支ID为空字符串
r($projectTest->checkBranchAndProductTest(1, array(3, 4), array(array(''), array('')))) && p('branch[0][]') && e('1'); // 步骤4异常输入-多产品分支为空
r($projectTest->checkBranchAndProductTest(2, array(1, 2, 3), array(array(1), array(2), array(3)))) && p() && e('1'); // 步骤5正常情况-多产品多分支