* [misc] Enhance unit tests for compileModel::getByID() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,24 +1,41 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/compile.unittest.class.php';
|
||||
|
||||
zenData('compile')->gen(1);
|
||||
zenData('job')->loadYaml('job')->gen(1);
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 compileModel->getByID();
|
||||
title=测试 compileModel::getByID();
|
||||
timeout=0
|
||||
cid=1
|
||||
cid=0
|
||||
|
||||
- 检查当id存在的时候是否能拿到数据属性name @构建1
|
||||
- 检查当id不存在的时候返回的结果属性name @0
|
||||
- 执行compileTest模块的getByIDTest方法,参数是1
|
||||
- 属性id @1
|
||||
- 属性name @构建1
|
||||
- 属性status @success
|
||||
- 执行compileTest模块的getByIDTest方法,参数是999 @alse
|
||||
- 执行compileTest模块的getByIDTest方法 @alse
|
||||
- 执行compileTest模块的getByIDTest方法,参数是-1 @alse
|
||||
- 执行compileTest模块的getByIDTest方法,参数是'abc' @alse
|
||||
|
||||
*/
|
||||
|
||||
$compile = new compileTest();
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/compile.unittest.class.php';
|
||||
|
||||
r($compile->getByIDTest('1')) && p('name') && e('构建1'); //检查当id存在的时候是否能拿到数据
|
||||
r($compile->getByIDTest('2')) && p('name') && e('0'); //检查当id不存在的时候返回的结果
|
||||
$table = zenData('compile');
|
||||
$table->id->range('1-5');
|
||||
$table->name->range('构建1,构建2,构建3,构建4,构建5');
|
||||
$table->job->range('1-5');
|
||||
$table->status->range('success,failure,running,pending,created');
|
||||
$table->queue->range('101-105');
|
||||
$table->createdBy->range('admin');
|
||||
$table->gen(5);
|
||||
|
||||
su('admin');
|
||||
|
||||
$compileTest = new compileTest();
|
||||
|
||||
r($compileTest->getByIDTest(1)) && p('id,name,status') && e('1,构建1,success');
|
||||
r($compileTest->getByIDTest(999)) && p() && e(false);
|
||||
r($compileTest->getByIDTest(0)) && p() && e(false);
|
||||
r($compileTest->getByIDTest(-1)) && p() && e(false);
|
||||
r($compileTest->getByIDTest('abc')) && p() && e(false);
|
||||
Reference in New Issue
Block a user