znt/module/compile/test/zen/buildsearchform.php

54 lines
2.4 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=测试 compileZen::buildSearchForm();
timeout=0
cid=15760
- 步骤1测试无参数情况验证repo字段存在属性hasRepoField @1
- 步骤2测试repoID参数为1验证repo字段不存在属性hasRepoField @0
- 步骤3测试jobID参数为1验证repo字段不存在属性hasRepoField @0
- 步骤4测试queryID参数为5验证queryID被设置属性queryID @5
- 步骤5测试所有参数设置验证repo字段不存在属性hasRepoField @0
- 步骤6测试repoID和jobID同时设置验证repo字段不存在属性hasRepoField @0
- 步骤7测试大queryID值验证queryID被正确设置属性queryID @100
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zen.class.php';
// 2. zendata数据准备
$repo = zenData('repo');
$repo->id->range('1-10');
$repo->name->range('Repository1,Repository2,Repository3');
$repo->deleted->range('0');
$repo->gen(3);
$job = zenData('job');
$job->id->range('1-20');
$job->name->range('Job1,Job2,Job3');
$job->deleted->range('0');
$job->gen(3);
// 3. 用户登录(选择合适角色)
su('admin');
// 3.5. 初始化compile配置
global $tester;
$tester->loadModel('compile');
// 4. 创建测试实例(变量名与模块名一致)
$compileTest = new compileZenTest();
// 5. 🔴 强制要求必须包含至少5个测试步骤
r($compileTest->buildSearchFormTest(0, 0, 0)) && p('hasRepoField') && e('1'); // 步骤1测试无参数情况验证repo字段存在
r($compileTest->buildSearchFormTest(1, 0, 0)) && p('hasRepoField') && e('0'); // 步骤2测试repoID参数为1验证repo字段不存在
r($compileTest->buildSearchFormTest(0, 1, 0)) && p('hasRepoField') && e('0'); // 步骤3测试jobID参数为1验证repo字段不存在
r($compileTest->buildSearchFormTest(0, 0, 5)) && p('queryID') && e('5'); // 步骤4测试queryID参数为5验证queryID被设置
r($compileTest->buildSearchFormTest(1, 1, 10)) && p('hasRepoField') && e('0'); // 步骤5测试所有参数设置验证repo字段不存在
r($compileTest->buildSearchFormTest(2, 3, 0)) && p('hasRepoField') && e('0'); // 步骤6测试repoID和jobID同时设置验证repo字段不存在
r($compileTest->buildSearchFormTest(0, 0, 100)) && p('queryID') && e('100'); // 步骤7测试大queryID值验证queryID被正确设置